obsidian-folder-index icon indicating copy to clipboard operation
obsidian-folder-index copied to clipboard

[WIP] Properly exclude folders

Open Eco-Gaming opened this issue 1 year ago • 10 comments

I made a very small change, which will properly exclude folders (and therefore somewhat fix #68). This will only exclude the "actual" folder though, subfolders still get treated normally. Depending on use-case, this could be favorable or annoying.

I would propose keeping it this way, and adding some basic form of regex (ie. media/*) for also excluding subfolders, but I haven't looked into how that should get implemented yet.

Eco-Gaming avatar Apr 12 '24 09:04 Eco-Gaming

Hey! Thanks for your work, i marked this PR as a draft while it is still WIP :)

turulix avatar Apr 12 '24 13:04 turulix

I just figured out that as the excludedFolders are treated as regex, my suggestion already works. It just has to be proper regex. For example, unsorted/.* excludes 'unsorted' and all its subfolders.

You can decided if you want to keep it proper regex, or maybe add a little .replace("*", ".*") (or something a bit more robust) in there so that "more obvious" wildcards like unsorted/* are supported.


If you want to keep the proper regex, this PR should be ready to merge.

Edit: I would change the placeholder in PluginSettingsTab.ts in line 113 to include a line with either * or .* before merging this.

Eco-Gaming avatar Apr 12 '24 17:04 Eco-Gaming

I think adding the placeholder is a really good idea, mind adding that for me? :) I think most ppl aren't aware that it requires to be a valid regex that matches the entire path to be excluded, maybe even add a message in it that it does infact only support regex

turulix avatar Apr 12 '24 18:04 turulix

Sorry I was busy, I added if (excludedFolder.endsWith("/*")) excludedFolder = excludedFolder.slice(0, -1) + ".*"; which seems to work. I don't know if there's a more "proper" way to implement this, but I think it should be fine this way.

Eco-Gaming avatar Apr 19 '24 18:04 Eco-Gaming

Just not sure if its the right move to simply modify the expressions, i think adding more awareness is more important?

turulix avatar Apr 25 '24 08:04 turulix

Oh oops I forgot to mention, I also changed one of the lines in the Excluded Folders box: Screenshot from 2024-04-25 10-24-20 I guess for even more awareness you could add another bullet point to the Features in the README, maybe something like

  • regex support for excluding folders

Eco-Gaming avatar Apr 25 '24 08:04 Eco-Gaming

Would just add it in the description of the option i guess

turulix avatar Apr 26 '24 14:04 turulix

If you tell me what you want the description to be I can change it to that, I suck at formulating concise descriptions lol

Eco-Gaming avatar May 03 '24 13:05 Eco-Gaming

I'm still not sure how to get this to work. No matter what I do, the folders continue to allow TOC to appear. image image

I've tried both ways - what I can't do is add hundreds of folders to this list and manually update it. I really need a method of restricting the TOC creation at the top level so it never spawns in certain locations.

Or, even better, a way to turn off the automatic creation and just spawn a TOC via hotkey.

SyndicatedPillbug avatar Aug 31 '24 14:08 SyndicatedPillbug

I'm still not sure how to get this to work. No matter what I do, the folders continue to allow TOC to appear. image image

I've tried both ways - what I can't do is add hundreds of folders to this list and manually update it. I really need a method of restricting the TOC creation at the top level so it never spawns in certain locations.

Or, even better, a way to turn off the automatic creation and just spawn a TOC via hotkey.

It's been a while since I used this / looked at the code, but this should work on the normal release:

  • attachments/attachments.md or
  • attachments/.*

Additionally, when using my fork, this should also work:

  • attachments/*

I have no idea how spaces are handled, but this should also work for your other folder.

Eco-Gaming avatar Aug 31 '24 16:08 Eco-Gaming