Skip to content

Conversation

@Gabatxo1312
Copy link
Collaborator

@Gabatxo1312 Gabatxo1312 commented Nov 14, 2025

  • Added File system page
  • Added category show
  • Added ContentFolder table
  • Added navigation in folders
  • Created new Sub Folders

@Gabatxo1312 Gabatxo1312 self-assigned this Nov 14, 2025
@Gabatxo1312 Gabatxo1312 force-pushed the add-content-files-and-content-folder branch 4 times, most recently from 041c8b0 to 24c61ba Compare November 15, 2025 17:33
@Gabatxo1312 Gabatxo1312 marked this pull request as ready for review November 15, 2025 18:21
@Gabatxo1312 Gabatxo1312 changed the title Add ContentFiles and ContentFolders Add ContentFolders crud and category show Nov 15, 2025
@angrynode
Copy link
Owner

Thanks for the MR! Initial feedback:

  • there is no "flash" announcing that the new subfolder was created
  • the name of the current folder should probably be highlighted somewhere under the bread crumbs (in bold)
  • the breadcrumbs are not obvious for those not familiar with the pattern (not sure what to do here)
  • maybe a "go up" button would be helpful, too?

@Gabatxo1312 Gabatxo1312 force-pushed the add-content-files-and-content-folder branch from 080b2a5 to d89f700 Compare November 16, 2025 15:49
@Gabatxo1312
Copy link
Collaborator Author

Gabatxo1312 commented Nov 16, 2025

@angrynode Yes, I didn't use flash because the breadcrumb was changing and it seemed unnecessary to me, but OK, I added it.
I've addressed the rest of the comments. The UI still needs improvement, but the UX works well

@angrynode
Copy link
Owner

angrynode commented Nov 16, 2025

Thanks!

Some more early feedback before review:

  • the breadcrumbs are not clickable links
  • i have two slashes in my URL, which is technically not an error but we should make it uniform: http://localhost:8000/folders/var/www//foo2/foo3 (this could be because i had a trailing slash when creating the category, and it has not been normalized)
  • i think it would be better to have the category name instead of the category path in the URL: like folders/datasets/example_2025, but i'm not sure how that plays with future localization efforts

@Gabatxo1312
Copy link
Collaborator Author

@angrynode

  • I implemented the clickable breadcrumb
  • I made the decision (let me know if you agree) to perform normalization when creating the category, to avoid trailing whitespace at that point!
  • As for your third point, it's tricky because I use folder.path in an Axum wildcard, and I don't see how we could simply subtract the category path from the folder path each time. If you have a simple idea, I'm all ears.

@Gabatxo1312 Gabatxo1312 force-pushed the add-content-files-and-content-folder branch from d89f700 to 23de41a Compare November 18, 2025 22:17
@angrynode
Copy link
Owner

I made the decision (let me know if you agree) to perform normalization when creating the category, to avoid trailing whitespace at that point!

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?

I don't see how we could simply subtract the category path from the folder path each time

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 :-)

Comment on lines +155 to 181
// 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()
}
Copy link
Collaborator Author

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

Copy link
Owner

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

@Gabatxo1312
Copy link
Collaborator Author

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).

I implemented this part, it's actually a good idea to do that. I store the folder path in the database, for example: /season1/hello/etc, so I can easily create the full path with something like this: format!(“{}{}”, category_path, folder_path)

@Gabatxo1312 Gabatxo1312 force-pushed the add-content-files-and-content-folder branch from 23de41a to 475b17a Compare November 22, 2025 09:23
@angrynode
Copy link
Owner

Nice, that's much better!

One nitpick: i noticed i can create a path with a / contained. It should either create two nested sub-paths, or produce an error to avoid this situation:

image

We should probably use Utf8PathBuf wherever we can.

@Gabatxo1312 Gabatxo1312 force-pushed the add-content-files-and-content-folder branch from 475b17a to 5cd4c34 Compare November 29, 2025 23:51
@Gabatxo1312
Copy link
Collaborator Author

Gabatxo1312 commented Nov 29, 2025

@angrynode I added an error when creating the folder if the name contains a “/” :

Capture d’écran du 2025-11-30 00-52-14

And I also normalized the path (before I just format! it) while waiting for you to add your NormalizedPath object :

 form.path = Utf8PathBuf::from(format!("{}/{}", parent_path, form.path))
        .components()
        .collect::<Utf8PathBuf>()
        .into_string();

@Gabatxo1312 Gabatxo1312 force-pushed the add-content-files-and-content-folder branch from 5cd4c34 to 822ef09 Compare December 1, 2025 09:16
pub async fn show(
State(app_state): State<AppState>,
user: Option<User>,
Path((_category_name, folder_path)): Path<(String, String)>,
Copy link
Owner

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("/") {
Copy link
Owner

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

@angrynode
Copy link
Owner

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:

  • adding the category list (filesystem) view and making it the homepage (you can move the upload form to /upload or something)
  • fixing flash message cookie handling
  • adding folders to a category with the basic category view
  • adding folders to folders with the content folder view

Additionally i think it would be useful to:

  • use new path types from feat: Normalized path types #20
  • document expectations regarding category ID / paths: at some point we're gonna support renaming/moving things so it's important for future contributors to understand what code paths hold specific expectations and will fail if they're not held

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.

@Gabatxo1312 Gabatxo1312 closed this Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants