pollen performance and folders
#34
Open
opened 5 years ago by jestarray
·
12 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?
Coming from little experience with web dev, pollen is great!
I have a few questions:
1: What is causing pollen take some time to generate pages since js based tools do it instantaneously?
2: I'd like to separate my pages into folders but I'm not sure how to write a directory down in the .ptree which is located at the root. Does every folder need it's own .ptree file?
A comparatively more gluttonous (but also more powerful) evaluation model.
Subfolders can have their own pagetree files, but they’re not required. I suggest you work backward from how you want to build your project, and let that dictate where the pagetree files are. For instance, for Beautiful Racket, I have one pagetree at the top, but it dynamically collects pages from subdirectories too. (And it can do this because a pagetree source is a self-contained program, etc.)
ahh. wait, so how would I grab the file of a subdirectory?
edit: ohh wait.. so I have to use (string->path) ?
EDIT2: i dont know why i didnt seek to look in the module reference documentation lol. reading it now
See Nesting pagetrees for one approach.
@mbutterick so how would i generate a table of contents? i'm unsure how to import index.ptree
If you want to import ALL the data, you can just
(require "index.ptree")
into the table of contents page. Every.ptree
file, includingindex.ptree
, exports adoc
variable with the pagenodes in it.You can also selectively call pagetree helper functions like
children
and passindex.ptree
as the pagetree source.Got it! One more question(sorry, a little new to racket), how do I flatten out a nested list?
I've been doing
(car l)
and(car (cdr l))
and this isn't going to scale well..match
fromracket/match
is a good tool for this:See the docs on match
https://docs.racket-lang.org/reference/match.html?q=match#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29
for more information
There's also
flatten
fromracket/list
https://docs.racket-lang.org/reference/pairs.html?q=flatten#%28def._%28%28lib._racket%2Flist..rkt%29._flatten%29%29,
but
match
would probably work better for you here.On Wed, Apr 15, 2020 at 7:22 PM jestarray notifications@github.com wrote:
Also look at the functions in
txexpr
(included with Pollen) for when you’re dealing with X-expressions. For instance, if you wanted a flat list of theli
elements from the above, you could do:So every page I have has a
<time>4/19/20</time>
tag and I want to grab all of them and create a TOC with the dates next to the title of pages.Doing
(select 'time path)
gives me:Is this the correct way to grab dates from every page?
That should work, though the error doesn’t make sense — it seems to be a file-permissions error triggered by something DrRacket is doing, not by Pollen per se. (Try running the same file from
racket
on the command line to see if the error is different.)You can also store a time value in the
metas
table and extract it that way (could be faster in certain circumstances).Same error... I'm calling it correctly right?
(select 'time 'chapter1/test.html)
, I also tried:(select 'time (build-path (current-directory) "chapter1" "test.html"))
?I do actually have write permissions on the drive.. (make-directory) works fine.
I feel it's going to be a back and forth conversation with little information gain to help you debugging if we just keep doing this. Do you have a link to your project? Or can you provide us a minimal template file /
pollen.rkt
and the problematic source file?