Skip to content
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

Tag tree #121

Merged
merged 10 commits into from
Apr 21, 2020
Merged

Tag tree #121

merged 10 commits into from
Apr 21, 2020

Conversation

felko
Copy link
Contributor

@felko felko commented Apr 20, 2020

Implements #110.

The query command was implemented like this:

neuron query zettel ID
neuron query zettels [TAG]
neuron query tags [TAG] [--tree | --list (default) ]
neuron query --uri URI

The --tree argument provides a JSON tree where each node contains some information that would be useful for a tag browsing feature in editors, as discussed in the PR.

@felko
Copy link
Contributor Author

felko commented Apr 20, 2020

Update: The CLI regressed to its previous spec.
Tag queries can only be executed by using neuron query --uri zquery://tags?... for now, and the result is a JSON tree in any way.

The JSON tree follows this format:

tree ::= {
  "tag": reltag,
  "subTags": [reltag...]
}
reltag ::= {
  "name": string
  "exists": boolean,
  "root": string
}

If a zettelkasten contains zettels tagged science/biology and science/math (but not science alone), then the tree for zquery://tags?filter=science/** would look like this:

[
  {
    "tag": {
      "exists": false,
      "name": "science"
    },
    "subTags": [
      {
        "exists": true,
        "root": "science",
        "name": "biology"
      },
      {
        "exists": true,
        "root": "science",
        "name": "math"
      }
    ]
  }
]

This makes it very easy for editors to implement tag browsing, but the format is a little bit complicated, and contains some duplicate information since the leaves will always have exists = true anyway.
The root attribute allows the reconstruction of the "absolute" tag, by doing root/name.

@srid srid changed the title Tag queries Tag tree Apr 20, 2020
@srid srid self-requested a review April 21, 2020 02:56
@felko
Copy link
Contributor Author

felko commented Apr 21, 2020

Update: The tree is now under this format:

tree ::= {
  "tag": string,
  "count": int,
  "children": [tree...]
}

where count is the number of zettels associated with each tag.

The view has also been updated to display the count.

Squashed commit of the following:

commit ad81111
Merge: 87fdaf4 8a6a768
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 20:05:26 2020 +0200

    Merge branch 'srid/query-tags'

commit 87fdaf4
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 19:45:06 2020 +0200

    Add zettel count to each tag in the tree

commit 85bbe5f
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 18:50:49 2020 +0200

    Refactoring, removed Neuron.Zettelkasten.Tag.Tree module

commit aa30f4b
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 15:48:32 2020 +0200

    Move tree rendering to Neuron.Zettelkasten.Link.View

commit a71f23c
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 15:31:56 2020 +0200

    Move tree spec module

commit 67e5a1c
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 15:09:53 2020 +0200

    Remove TagTree and RelTag

commit e153f0c
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 14:36:58 2020 +0200

    Seperate tree building in its own module

commit 8a6a768
Merge: a7da37b c0ecc08
Author: Sridhar Ratnakumar <srid@srid.ca>
Date:   Mon Apr 20 22:56:11 2020 -0400

    Merge branch 'master' into query-tags

commit fd0237f
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Tue Apr 21 00:58:46 2020 +0200

    Change back Tag internal representation to Text

commit a7da37b
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 18:24:53 2020 +0200

    Move tag tree spec in its own module

commit 7067da8
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 17:38:26 2020 +0200

    Move JSON and HTML representation of the tree

commit 363818a
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 17:16:21 2020 +0200

    Create separate module for the tag tree

commit 1cc7d8c
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 17:02:51 2020 +0200

    Revert to previous CLI format

commit 790cbc6
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 16:39:50 2020 +0200

    Remove query tags --list option

commit e3acc3a
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 15:14:08 2020 +0200

    Make mkTag a smart constructor, to avoid empty tags

commit 263f680
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 15:04:22 2020 +0200

    Remove useless toString

commit 1c050e7
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 12:32:16 2020 +0200

    Cleanup

commit 143629b
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 12:09:46 2020 +0200

    Change query CLI

commit 47c9264
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 01:31:17 2020 +0200

    Comments

commit b94976a
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 01:24:19 2020 +0200

    Refactor

commit 54c74ac
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 00:52:19 2020 +0200

    Remove duplicate code

commit 5e1c10d
Merge: c071a46 03c5fe8
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 00:47:47 2020 +0200

    Merge srid/master to include srid#119

commit c071a46
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Mon Apr 20 00:30:13 2020 +0200

    Finish tag tree view

commit ee39bd7
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 18:47:17 2020 +0200

    Remove TreeTheme type, default to (folded) tree view

commit a94753c
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 16:27:12 2020 +0200

    Add basic tag query view

commit 2215744
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 16:26:55 2020 +0200

    Fixed query interface

commit e253196
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 16:26:26 2020 +0200

    Fixed tag roots not being propagated

commit 2c7b98e
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 16:03:38 2020 +0200

    Use new RelTag type for the nodes of the tag tree

commit 43b1da3
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 15:15:53 2020 +0200

    Fix CLI

commit d732ee0
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 15:08:18 2020 +0200

    Add tag test

commit 03f2e9d
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 15:07:11 2020 +0200

    Don't fold tag/subtag when tag also exists by itself

commit 9192c39
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 14:36:55 2020 +0200

    Add tag tree specification (failing)

commit a8a0cfd
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 13:17:04 2020 +0200

    Add CLI interface to the tag tree

commit a28dbb7
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 13:12:37 2020 +0200

    Fix tag spec

commit ac6372b
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 12:37:33 2020 +0200

    Remove unused extensions

commit 9d1f0c9
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 12:37:13 2020 +0200

    Implement tag tree and tag folding

commit 8cc0f64
Author: felko <baxbaxwalanuksiwe@gmail.com>
Date:   Sun Apr 19 12:35:30 2020 +0200

    Change Tag internal representation to FilePath
Which is misleading. "foo/bar/baz" is a tag; "bar" is not a tag (and if
the user uses a top-level "bar" tag, it would just be confusing to call
this inner node "bar" a tag)
@srid srid merged commit c159177 into srid:master Apr 21, 2020
@felko felko deleted the query-tags branch April 22, 2020 00:04
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