Properties definition list completion check

I wanted to make a definition list for all properties that I use. And I wanted a way to check for any properties not on the list.

Learning some clojure along the way :smiley: here’s the result.

On my workflow page, I have a section for property usage. It looks like this (collapsed blocks also have property lists as children)

The idea is to give a definition as the value. Alternatively you can put the definition beneath the property if you don’t want it to show up in the auto completion list.

There’s a query here “Andere Properties” which will list any properties not currently on this page. (system properties contain such properties as icon and file)

#+BEGIN_QUERY
{:title [:b "Andere Properties"]
 :inputs [:query-page] ; input the page the query is on for use in the query
 :query [:find ?prop ?def ; find the properties list and the definitions list
  :keys prop def ; put the find items in specified keys.
  :in $ ?page ; definition of the query-page input
  :where
   [?w :block/name ?page] ; get the database item of the query-page
   [?b :block/page ?w] ; get all blocks on the query-page
   [?b :block/properties ?def] ; fill variable ?def with the available block properties
   [?p :block/journal? false] ; get all non-journal pages
   [?p :block/file _] ; only those pages that also have a file = have content
   [?p :block/properties ?prop] ; fill variable ?prop with the available page properties
   (not [(empty? ?prop)]) ; filter out block property lists that are empty
 ]
 :result-transform (fn [rows] 
   (def proplist (set (distinct (flatten (map keys (for [r rows] (get r :prop) ) ) ) ) ) ) ; from the result for properties get a list of unique keys
   (def deflist (set (distinct (flatten (map keys (for [r rows] (get r :def) ) ) ) ) ) ) ; do the same for the result for definitions
   (sort (remove deflist proplist) ) ; subtract the deflist from the proplist and sort the result
 )
 :view (fn [rows] (for [r rows] (str/replace (str r ". ") ":" "") ) ) ; add a . to the end of each item and remove the : from the name. This results in a single line as icon. file. etc.
}
#+END_QUERY

Example result


Alteration options. (feel free to let me know some alternative scenarios to consider)

Properties list based on block properties instead of page properties

Change:

[?p :block/properties ?prop] ; fill variable ?prop with the available page properties

To:

[?h :block/page ?p] ; get blocks of the pages
[?h :block/properties ?prop] ; fill variable ?prop with the available properties of those blocks

Result as list instead of single line

Change:

:view (fn [rows] (for [r rows] (str/replace (str r ". ") ":" "") ) ) ; add a . to the end of each item and remove the : from the name. This results in a single line as icon. file. etc.

To:

:view (fn [rows] (for [r rows] [:div (str/replace (str r ". ") ":" "") ] ) ) ; add a . to the end of each item and remove the : from the name. The [:div ] turns this result in a list of items.


List of system properties

To help you filter them out :slight_smile: these are the ones present in my graph, feel free to point out some I’ve missed.

collapsed::
exclude-from-graph-view::
file::
file-path::
hl-color::
hl-page::
hl-stamp::
hl-type::
ls-type::
icon::
id::
public::
query-properties::
query-sort-by::
query-sort-desc::
query-table::
template::
template-including-parent::
2 Likes