Metadata on pagenodes (?) / how to render link traversal
#124
Open
opened 3 years ago by femtomc
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I have two related questions (related in the sense that they motivated a common solution, but the solution is outside of
pollen
, and I was hoping I could somehow not resort to it).I have an
index.html.pm
file -- I want to render an itemized list of the nodes in my pagetree (and I have an associatedindex.ptree
file I curate). However, I want to render them with their titles (distinct from their node name). As far as I can tell, there's no way to attach metadata to page nodes -- except by keeping some state (a finite map, say) around (and then, when the preprocessor ingests a file, tell it to add a key with the current page node name, with value the metadata I want). The one thing I'm concerned about is the order of the traversal -- if the state is not updated beforeindex.html.pm
is preprocessed, that's going to be a problem.The second question is about rendering the forward / backward links in a graphical form. I know that
pollen
must do this already (right?) -- I want to render a "knowledge graph" like representation of the link traversal. Is it possible to gain access to this structure through normal Racket? The alternative solution I had was another "stateful" thing where I keep a database around, and register forward/backward links in the database. I don't really want to do this, so I was hoping that there is an easier solution.Re -- I realized the first one was easy enough to work on:
e.g. this just uses the curated
.ptree
and a search over X-expressions to get the right thing.The second one (forward and back links) I'm still stumped on.
Why not
define-meta
?The forward & backward links can be computed from a pagetree. (They could be computed other ways too.) But no, Pollen does not automatically render them “in a graphical form” — you would do that yourself.
What does this mean — a graph of all the hyperlinks between pages? If so, I don’t see any alternative to reading the
link
tags out of the source files (assuming the links of interest are already tagged there; if not you would have to read & parse the output files) and imperatively building a graph. Racket’sgraph
library will output tographviz
format, so once you have a graph object, it’s easy to get a rendered diagram. (Not necessarily a pretty diagram, though.)This is covered in the second tutorial in the Pollen docs.
@mbutterick -- I'm looking into
pollen/core
more, I realized I misunderstood that you could access metadata about the document directly (e.g. by using the pagenode reference).Right, so basically: iterate over nodes in the page tree, and grab all "special" links (e.g. cross links to other nodes), then offload to
graphviz
.I'm pretty close now, thanks for the help!
Here, I did a poor job -- I meant the traversal across the nodes (not the rendering).