-
Notifications
You must be signed in to change notification settings - Fork 1
Add ContentFolders crud and category show #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ContentFolders crud and category show #15
Conversation
041c8b0 to
24c61ba
Compare
|
Thanks for the MR! Initial feedback:
|
080b2a5 to
d89f700
Compare
|
@angrynode Yes, I didn't use flash because the breadcrumb was changing and it seemed unnecessary to me, but OK, I added it. |
|
Thanks! Some more early feedback before review:
|
|
d89f700 to
23de41a
Compare
Great idea, i just don't see where you're doing this. Maybe we should add a
Throwing an idea, let me know what you think. What about storing content paths as relative paths from the category dir? I think it may make more sense, and would help to change a category's path without rewriting all children paths recursively (it would not help with changing a content folder's path, though). Alternatively, you can just use Utf8Path::strip_prefix. I will be happy to accept this option if it's less troublesome for you :-) |
| // Normalized path to avoid trailing slash | ||
| let normalized_path = dir.components().collect::<Utf8PathBuf>(); | ||
| let model = ActiveModel { | ||
| name: Set(f.name.clone()), | ||
| path: Set(f.path.clone()), | ||
| path: Set(normalized_path.into_string()), | ||
| ..Default::default() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, i just don't see where you're doing this. Maybe we should add a TrimmedString extractor so that it's performed before reaching the form?
This is where I normalize the path when creating the category
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use NormalizedPathAbsolute from #20
I implemented this part, it's actually a good idea to do that. I store the folder path in the database, for example: |
23de41a to
475b17a
Compare
475b17a to
5cd4c34
Compare
|
@angrynode I added an error when creating the folder if the name contains a “/” :
And I also normalized the path (before I just form.path = Utf8PathBuf::from(format!("{}/{}", parent_path, form.path))
.components()
.collect::<Utf8PathBuf>()
.into_string(); |
5cd4c34 to
822ef09
Compare
| pub async fn show( | ||
| State(app_state): State<AppState>, | ||
| user: Option<User>, | ||
| Path((_category_name, folder_path)): Path<(String, String)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that the category name matches the category ID? When moving stuff between categories we should probably have an integrity check somewhere, but maybe it doesn't have to be here and we can just assume everything is fine?
| .context(CategorySnafu)?; | ||
|
|
||
| // If name contains "/" returns an error | ||
| if form.name.contains("/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use NormalizedPathComponent here
|
Thanks a lot for this contribution! I added review comments here and there, but overall i think this is too big to review properly. I think this can be decoupled into a few different PRs for easier review:
Additionally i think it would be useful to:
Potentially, it may even makes sense to implement renaming/moving PR by PR so that we make sure those expectations are sensible before adding too much code. What do you think? If you don't have too much time to contribute, i can take on some of the decoupling into smaller PRs, just let me know. |


Uh oh!
There was an error while loading. Please reload this page.