srid / neuron

Future-proof note-taking and publishing based on Zettelkasten (superseded by Emanote: https://github.com/srid/emanote)
https://neuron.zettel.page
GNU Affero General Public License v3.0
1.52k stars 150 forks source link

Bring back dirtree tagging option #569

Closed flyinggrizzly closed 3 years ago

flyinggrizzly commented 3 years ago

I've been using the now deprecated dirtree behavior of tagging directory content zettels with their path (eg root/blog on blog/2021-02-01-slug.md) in order to create listings by tag in notes other than blog.md.

Is there a possibility of bringing back the auto-tagging behavior of the dirtree plugin if both it and the tags plugin are enabled, or as a third plugin that depends on both?

My usecase is using a directory zettel tree as a blog, and showing the n most recent entries on index.md:

// index.md

# My Cool Neuron site

// Some splash page content

## Blog

Here are the 10 most recent entries:

[[z:zettels?tag=root/blog&timeline]]

If not, I'm sure I can figure out a workaround/some other solution, but it has been a very useful feature to have.

srid commented 3 years ago

The change was originally done in the process of making tags a plugin (rather than a core feature). Architecturally if we are to do this, then the dirtree plugin would depend on the tags plugin (thus necessitating the notion of plugin dependencies; and it is not clear if this complexity is worth allowing for one use-case).

I do think that your specific use case of a blog timeline can also be implemented by extending the query to support, say, downlinks (equivalent to neuron query --downlinks-of):

[[z:zettels?downlinks-of=Blog]]

Alternatively, we can make tags a core feature of neuron (i.e, revert the tags plugin change; or, better, rename it to query plugin, dealing only with z:zettels queries which, now, can do more than tag querying), and have other plugins operate on tags. I'll have to think about this for a bit.

flyinggrizzly commented 3 years ago

Oh that down-link syntax looks like it would absolutely work for me.

If this issue would create a coupling between two of the plugins I’m not sure it’s worth it to me as a user to increase the maintenance burden—I’m struggling to think of a case where going directly to the zettel structure would be a worse idea than querying the tag structure as a proxy...

srid commented 3 years ago

I figured out a way to do it without tight coupling. #571 (zettel metadata as generic map) allows us to have multiple plugins manipulate this metadata (key=tags in our case, expecting value to be a list of strings) directly.

@flyinggrizzly Try out the dev branch, and let me know if it behaves as you'd expect. You can install that version of neuron using this command:

nix-env -if https://github.com/srid/neuron/archive/dev.tar.gz

(You don't need to have the tags plugin enabled)

flyinggrizzly commented 3 years ago

That did it--works exactly like I needed. Thank you!

flyinggrizzly commented 3 years ago

Sidenote, that --downlinks-of query syntax appears not to work in the master or dev branch builds atm.

srid commented 3 years ago

Yes, downlinks query is not implemented yet. I just provided it as a potential thing to support. But I'd rather do #407 first (from a architectural point of view).