shrub/pub/doc/tree.md

55 lines
2.0 KiB
Markdown
Raw Normal View History

2015-08-04 04:37:19 +03:00
# Tree
2015-08-04 02:49:34 +03:00
`:tree` is the web filesystem interface.
2015-08-05 05:09:58 +03:00
# Data retrieval interface
Async provides loading by schema
`{path name sein sibs next prev}` are all immediately accesible from the store
a `getPath` method, if present (defaulting to current url), is used to determine the query root node.
2015-08-04 02:49:34 +03:00
# Internals
2015-08-04 04:37:19 +03:00
something something coffeescript
2015-08-04 02:49:34 +03:00
## `/[desk]/tree/{path}.json`
2015-08-04 04:37:19 +03:00
tree/json.hook accepts a query string schema `q` in light noun encoding¹
2015-08-04 02:49:34 +03:00
++ schema (dict ,[term $|(mark schema)])
++ dict |*(a=_,* $&([a (dict a)] a))
which is normalized and type-checked(request types are `%t` text, `%r` html-derived tree, and `%j` arbitrary json) to a `query` list of
- `[%kids query]`, the only recursive value, which executes for all subpaths
XX descent is only currently supported to a single level as a performance optimization
- `[%name %t]`, the node name
2015-08-06 02:48:34 +03:00
- `[%path %t]`, the current path
2015-08-04 02:49:34 +03:00
- `[%snip %r]`, a snippet, extracted via `react-snip-json`
2015-08-06 05:13:41 +03:00
- `[%head %r]`, the first `<h1/>`, extracted via `react-head-json`
2015-08-04 02:49:34 +03:00
- `[%body %r]`, the `react-json` body
- `[%meta %j]`, json frontmatter per the `mdy` mark definition
Per this specification, the current access points will be migrated:
- (json.hook)`""` to `body:'r' kids:{name:'t'}` `"?body.r__kids_name.t"`
- `"?kids"` to `kids:{name:'t' body:'r'}` `"?kids_name.t_body.r"`
2015-08-04 04:37:19 +03:00
- `"?snip"` to `kids:{name:'t' snip:'r' head:'r' meta:'j'}` `"?kids_name.t_snip.r_head.r_meta.j"`
2015-08-04 02:49:34 +03:00
¹In the examples,
=< (cook to-noun (cook to-tree apex))
|%
++ data $|(term [n=@ l=data r=data])
++ apex ;~(plug sym (star ;~(plug delim sym)))
++ delim ;~(pose (cold 0 dot) (cook lent (plus cab)))
++ to-noun |=(a=data ?@(a a [$(a l.a) $(a r.a)]))
++ to-tree
|= [acc=data a=(list ,[p=@u q=term])]
%+ roll a =< .(acc ^acc)
|= [[n=@u v=term] acc=data]
?@ acc [n acc v]
?: (gth n n.acc) [n acc v]
acc(r $(acc r.acc))
--
2015-08-04 04:37:19 +03:00
XX Curtis, this can be full coin `%many` if you wish.