akosbalasko / zoottelkeeper-obsidian-plugin

Obsidian plugin of Zoottelkeeper: An automated folder-level index file generator and maintainer.
186 stars 13 forks source link

Feature Request: Zootel Templates #17

Closed brimwats1 closed 2 years ago

brimwats1 commented 3 years ago

Zoottelkeeper works with both the original Folder Note and the AidenLX Folder Note Plugins. However, because Zootelkeeper is "faster" than other plugins, it ends up making a note before I can manually make a folder note.

Do you think there is any way you could add a template feature that is similar to folder note? It wouldn't have to support all of these things, but it would be nice if it could support FOLDER_NAME and FOLDER_PATH like this:

image

Originally posted by @brimwats in https://github.com/akosbalasko/zoottelkeeper-obsidian-plugin/issues/6#issuecomment-907814982

kquinsland commented 3 years ago

I would love to see something like this! I use the super powerful templater plugin by silentvoid13 for a lot of things.

The zoottelkeeper plugin could leverage the work done in existing template plugins rather than re-invent the wheel. Allow for configuration tweaks to zoottelkeeper via the frontmatter of the index file similar to how the dynamic-toc plugin uses the codeblock.

Example:

Let's say that I have my prefix set to 000_idx_. In the Projects folder, the zoottelkeeper plugin would generate a 000_idx_Projects.md file. I would then adjust the content of this file to tweak the way the index file in Projects is generated:

---
tags: MOC/Index, MOC/Projects

# Tweak the index file for Projects
zoottelkeeper:
  # Use the https://silentvoid13.github.io/Templater/docs/commands/dynamic-command/
  indexTemplate: templates/projectIndex.tmpl.md

  # A list of regex. Any sub dir in Projects that matches will be part of the index
  indexSubDirs:
     - "*"

---

%% After filtering all of the sub dirs in Projects against indexSubDirs, the final list of files/dirs is fed to the file specified in indexTemplate .... %%

Moving most settings to the frontmatter of the index file keeps the settings page clean as features are added / the plugin grows and allows for customization per index.

brimwats1 commented 3 years ago

@kquinsland's solution sounds like a good one!

akosbalasko commented 3 years ago

Hi @kquinsland , hi @brimwats ,

I added an option to do not regenerate the whole index file, just update a dedicated place (specified by %% placeholders) only and the frontmatter. In this case everything outside from the placeholders can be customized. So I currently don't really see the added value of supporting templates. But it's probably because I misunderstood the concept, could you please enlight it with an other example? What do FOLDER_NAME and FOLDER_PATH stand for in the original feat. request?

matclab commented 3 years ago

I wonder if it is not a problem of concurrence : several plugins trying to create the file (Note Folder and Zoottelkeeper), but Zoottelkeeper win, and as such the template defined in Folder Note is not used. This is why people are asking for templates in zootlekeeper (i.e for the first creation of the file).

brimwats1 commented 3 years ago

well stated @matclab this is 💯% the reason I am. I make a folder and then try to make a folder note but zootel beats me always so then I have to delete it really fast and then try again and hope I make it.

maybe another alternative would be for people to limit zootel to "only run on startup" @akosbalasko

kquinsland commented 3 years ago

Hi @kquinsland , hi @brimwats ,

I added an option to do not regenerate the whole index file, just update a dedicated place (specified by %% placeholders) only and the frontmatter. In this case everything outside from the placeholders can be customized. So I currently don't really see the added value of supporting templates. But it's probably because I misunderstood the concept, could you please enlight it with an other example? What do FOLDER_NAME and FOLDER_PATH stand for in the original feat. request?

When i typed up that example, i wasn't 100% sure how one plugin could call another. My assumption/hope was that it was possible.

Basically, zoottelkeeper would call the templater plugin with two arguments:

This way, the zoottelkeeper plugin does not need to care about how the user might want the index to look like... let the template worry about that. If a user wants an index with every other file to be in Camel Case and every 5th file to be in all caps and every 7th file to be prefixed with an icon.... the template can do that :D.

I could see users opening endless requests to tweak how zoottelkeeper does the render of the index and wanted to suggest an approach that would prevent users asking for a zillion tweaks.

The example i gave above with the template file was more of an idea / wishful thinking. I don't know if obsidian allows for one plugin to interact with another via an API.

claremacrae commented 3 years ago

Just to note another use case for this:

The Obsidian Hub is currently undergoing a big rearrangement, and is looking at having to script creating many new MOC/Index files from its template, before running zoottelkeeper to generate the new indexes...

Being able to let zoottelkeeper just run - and create files with the correct template - would be really helpful.

claremacrae commented 3 years ago

Here's what the Obsidian Hub MOC template currently looks like:

https://raw.githubusercontent.com/obsidian-community/obsidian-hub/1f941856c5a2f42fbc56ab885accd83f51020548/00%20-%20Meta/00.01%20-%20Meta%20OCV%20templates/T%20-%20MOCs.md

Tuo-Luo commented 1 year ago

Template file is specified, but the code block does not work.

This is template file. This is template file

This is the wrong result of Zoottelkeeper Template File. This is result

This is the correct result of my direct use of Templater. This is the correct result