Re: [pollen] Navigation issue with Pollen templates

2019-02-28 Thread Matthew Butterick


> On Feb 28, 2019, at 4:28 PM, Matthew Butterick  wrote:
> 
> But I would put the code inside a function in "pollen.rkt". In that case you 
> can pass `metas` as an argument, or use the `current-metas` parameter.

(Of course in that case the `require` could go at the top of the file with the 
others. I'm just mixing it into this sample to show what it's being used for)

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Navigation issue with Pollen templates

2019-02-28 Thread Matthew Butterick

> On Feb 28, 2019, at 3:17 PM, Brendan Stromberger 
>  wrote:
> 
> In my template, I have `◊(define here (path->pagenode (->output-path 
> (hash-ref metas 'here-path`
> 
> This renders out to a pagenode that looks something like 
> "body/3_the_trigrams.html"
> 
> When I send this pagenode into `next` or `previous`, it returns nothing.

Probably you want to do something like this (pseudocodishly, I have not checked 
that this works):

;;;

(define here-path (hash-ref metas 'here-path))
;; `here-path` is an absolute path, so if your pagetree nodes are relative to 
project root,
;; you'll also want to make this one relative the same way.
(require racket/path) ; for `find-relative-path`. 
(define here-path-relative (find-relative-path here-path 
(current-project-root)))
;; every node in a pagetree is a symbol
(define here-path-pagenode (string->symbol (path->string here-path-relative)))
;; having made our special pagenode, now we can query the pagetree
(define next-path-pagenode (next here-path-pagenode)) 
;; then we convert the result back to an output path
(define next-url (->output-path (build-path (current-project-root) 
next-path-pagenode)))

;;;

BTW if the code above lives inside a template, use `local-require` rather than 
`require`. But I would put the code inside a function in "pollen.rkt". In that 
case you can pass `metas` as an argument, or use the `current-metas` parameter.

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Navigation issue with Pollen templates

2019-02-28 Thread Brendan Stromberger
Alright, I'm making progress, but not quite there yet.

In my template, I have `◊(define here (path->pagenode (->output-path 
(hash-ref metas 'here-path`

This renders out to a pagenode that looks something like 
"body/3_the_trigrams.html"

When I send this pagenode into `next` or `previous`, it returns nothing.

My ptree files still reference only `*.poly.pm` source files.

On Thursday, February 28, 2019 at 12:45:59 PM UTC-5, Matthew Butterick 
wrote:
>
>
> On Feb 28, 2019, at 6:42 AM, Brendan Stromberger  > wrote:
>
> I can't seem to get next/previous navigation working. When I use 
> `◊(previous here)` and `◊(next here)`
> for my nav links, they evaluate to blank strings. `◊|here|` correctly 
> evaluates (as far as I can tell) to the current doc path.
>
>
> `here-path` is a source path, but `here` is an output path. So if you're 
> going to rely on `here` as the input to navigation functions, the pagetree 
> must also contain output filenames. 
>
> (This point was a little ambiguous in the docs that introduce `here`, so 
> I've pushed a clarification.)
>
> In this case, your pagetree contains source names, so `here` (as an output 
> name) is not found, and `(next here)` and `(previous here)` evaluate to #f, 
> which are both rendered as empty strings.
>
> That said, you can use source names in the pagetree. In a `poly` project 
> that may be the better idea. But if so, you need to do a little more 
> housekeeping in your template files:
>
> 1) Instead of `here`, you'd want to pass `(hash-ref metas 'here-path)` to 
> your pagetree function.
>
> 2) The result will be a source path, so you'd want to use `->output-path` 
> to convert it to a usable output navigation link.
>
> Separately, if you're including subdirectories in your pagetree, you need 
> to be mindful of absolute vs relative pathnames. For instance, if the 
> browser is visiting "front/cover.html" and links to the relative URL 
> "front/author_note.html", then it will try to go to 
> "front/front/author_note.html" (which doesn't exist). The simple solution 
> is to make all your pagetree paths start from the project root, and in the 
> template, stick with absolute URLs (that is, always prefix links in URLs 
> with "/"). 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Using generated pagetree as an index pagetree

2019-02-28 Thread Brendan Stromberger
Thanks for the advice, Matthew. So far, I've been splitting the difference 
between the two approaches (vertical/horizontal), but as time goes on, 
leaning into the horizontal :) I very much appreciate all your help so far 
and hope to someday contribute.


On Thursday, February 28, 2019 at 1:40:01 PM UTC-5, Matthew Butterick wrote:
>
> Sometimes there's a misapprehension among new users that Pollen represents 
> a monolithic "take it or leave it" system. (Not a surprise, because many 
> page-making systems are like that.) Pollen tries to make simple projects 
> easy (by providing non-astonishing default behavior) while not inhibiting 
> complex or ambitious projects (by being hackable & mixing smoothly with 
> Racket at large). 
>
> Of course, these projects require more heavy lifting from the author. My 
> free advice to anyone in your position would be to work "horizontally" by 
> making an end-to-end prototype of the project (e.g., simple Pollen source 
> files that produce simple HTML). Then iteratively improve.
>
> This is in contrast to working "vertically" where one tries to design the 
> whole project from the top down, like a snake swallowing a goat. This tends 
> to be harder, less rewarding, and takes more time (because it's easier to 
> develop faulty intuitions when things are unfamiliar).
>
>
> On Feb 28, 2019, at 10:07 AM, Brendan Stromberger  > wrote:
>
> Thanks Matthew. My apologies for using the "M" word – at this moment, a 
> lot about Racket *feels* magical simply because I don't understand it yet ;)
>  
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Using generated pagetree as an index pagetree

2019-02-28 Thread Matthew Butterick
Sometimes there's a misapprehension among new users that Pollen represents a 
monolithic "take it or leave it" system. (Not a surprise, because many 
page-making systems are like that.) Pollen tries to make simple projects easy 
(by providing non-astonishing default behavior) while not inhibiting complex or 
ambitious projects (by being hackable & mixing smoothly with Racket at large). 

Of course, these projects require more heavy lifting from the author. My free 
advice to anyone in your position would be to work "horizontally" by making an 
end-to-end prototype of the project (e.g., simple Pollen source files that 
produce simple HTML). Then iteratively improve.

This is in contrast to working "vertically" where one tries to design the whole 
project from the top down, like a snake swallowing a goat. This tends to be 
harder, less rewarding, and takes more time (because it's easier to develop 
faulty intuitions when things are unfamiliar).


> On Feb 28, 2019, at 10:07 AM, Brendan Stromberger 
>  wrote:
> 
> Thanks Matthew. My apologies for using the "M" word – at this moment, a lot 
> about Racket *feels* magical simply because I don't understand it yet ;) 

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Using generated pagetree as an index pagetree

2019-02-28 Thread Brendan Stromberger
Thanks Matthew. My apologies for using the "M" word – at this moment, a lot 
about Racket *feels* magical simply because I don't understand it yet ;) 

On Thursday, February 28, 2019 at 12:57:52 PM UTC-5, Matthew Butterick 
wrote:
>
>
> On Feb 28, 2019, at 9:09 AM, Brendan Stromberger  > wrote:
>
> Side question but related: is `doc` a magical export from ptree files? How 
> do I know what is being exported from any given Pollen file (*.ptree, *.p, 
> *.pm)?
>
>
>
> `doc` and `metas` are exported from every Pollen source file. (Meaning, a 
> file that starts with `#lang pollen` or one of its dialects — not a *.p 
> file, which is just a source-control convenience.) You can examine the 
> values of these exports on the DrRacket REPL.
>
> There isn't anything magical about the pagetree subsystem. It's just a way 
> of streamlining the common housekeeping of a) maintaining a tree-shaped 
> list of things and then b) querying into that list of things, while c) 
> staying consistent with the authoring conventions of other Pollen files. 
> You could do it your own way.
>
> Likewise, zooming out further, there isn't anything magical about Pollen 
> at large. It's just a convenient way of writing Racket programs that 
> involve a lot of text.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Using generated pagetree as an index pagetree

2019-02-28 Thread Matthew Butterick

> On Feb 28, 2019, at 9:09 AM, Brendan Stromberger 
>  wrote:
> 
> Side question but related: is `doc` a magical export from ptree files? How do 
> I know what is being exported from any given Pollen file (*.ptree, *.p, *.pm)?


`doc` and `metas` are exported from every Pollen source file. (Meaning, a file 
that starts with `#lang pollen` or one of its dialects — not a *.p file, which 
is just a source-control convenience.) You can examine the values of these 
exports on the DrRacket REPL.

There isn't anything magical about the pagetree subsystem. It's just a way of 
streamlining the common housekeeping of a) maintaining a tree-shaped list of 
things and then b) querying into that list of things, while c) staying 
consistent with the authoring conventions of other Pollen files. You could do 
it your own way.

Likewise, zooming out further, there isn't anything magical about Pollen at 
large. It's just a convenient way of writing Racket programs that involve a lot 
of text.

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Navigation issue with Pollen templates

2019-02-28 Thread Matthew Butterick

> On Feb 28, 2019, at 6:42 AM, Brendan Stromberger 
>  wrote:
> 
> I can't seem to get next/previous navigation working. When I use `◊(previous 
> here)` and `◊(next here)`
> for my nav links, they evaluate to blank strings. `◊|here|` correctly 
> evaluates (as far as I can tell) to the current doc path.

`here-path` is a source path, but `here` is an output path. So if you're going 
to rely on `here` as the input to navigation functions, the pagetree must also 
contain output filenames. 

(This point was a little ambiguous in the docs that introduce `here`, so I've 
pushed a clarification.)

In this case, your pagetree contains source names, so `here` (as an output 
name) is not found, and `(next here)` and `(previous here)` evaluate to #f, 
which are both rendered as empty strings.

That said, you can use source names in the pagetree. In a `poly` project that 
may be the better idea. But if so, you need to do a little more housekeeping in 
your template files:

1) Instead of `here`, you'd want to pass `(hash-ref metas 'here-path)` to your 
pagetree function.

2) The result will be a source path, so you'd want to use `->output-path` to 
convert it to a usable output navigation link.

Separately, if you're including subdirectories in your pagetree, you need to be 
mindful of absolute vs relative pathnames. For instance, if the browser is 
visiting "front/cover.html" and links to the relative URL 
"front/author_note.html", then it will try to go to 
"front/front/author_note.html" (which doesn't exist). The simple solution is to 
make all your pagetree paths start from the project root, and in the template, 
stick with absolute URLs (that is, always prefix links in URLs with "/"). 

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Using generated pagetree as an index pagetree

2019-02-28 Thread Brendan Stromberger
Side question but related: is `doc` a magical export from ptree files? How 
do I know what is being exported from any given Pollen file (*.ptree, *.p, 
*.pm)?

On Tuesday, February 19, 2019 at 6:13:58 PM UTC-5, Matthew Butterick wrote:
>
>
> On Feb 19, 2019, at 2:35 PM, Evžen Wybitul  > wrote:
>
> And I'd like to somehow include it in the index.ptree file (i.e. use it 
> both to render the files and on the webserver as the default ptree). How do 
> I go about this?
>
>
> You can `require` (or `dynamic-require`) a ptree source into another ptree 
> source. The `doc` export will contain the nodes.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Re: Library for rendering Pollen to JSON?

2019-02-28 Thread Brendan Stromberger
Here's another thought: for the section of the book that needs to power 
both the book portions (html,pdf,epub) as well as the webapp, can be 
written primariy as JSON, shared between both Pollen and Elm (or whatever I 
use), rather than trying to have Pollen export that specific section as 
JSON. 

On Thursday, February 28, 2019 at 9:37:27 AM UTC-5, Brendan Stromberger 
wrote:
>
> Thanks all! I want to publish this as a website as well as a PDF and ePub 
> (expect another post regarding epub at some point ;)) There's a large 
> section of the book that I want to eventually use as a data source for a 
> webapp I'm writing in Elm. I might also consider attempting to see if I can 
> bypass the JSON-output step and output JSX from Racket and use Pollen for 
> the entire pipeline: generating my books, and generating a full client-side 
> webapp using the book content as a data source. I'm not sure how I would 
> get Pollen to output to JSX but perhaps it isn't as hard as I'm imagining. 
> Perhaps it is. 
>
> I'd love some feedback on this idea.
>
> On Tuesday, February 26, 2019 at 9:53:08 AM UTC-5, Brendan Stromberger 
> wrote:
>>
>> Has anyone written a library to generalize (at least to some extent) the 
>> process of rendering a Pollen document to JSON?
>>
>> Thanks!
>> Brendan
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Navigation issue with Pollen templates

2019-02-28 Thread Brendan Stromberger
Hi there, I'm attempting to write an HTML template for my book and I've run 
into an issue:

I can't seem to get next/previous navigation working. When I use 
`◊(previous here)` and `◊(next here)`
for my nav links, they evaluate to blank strings. `◊|here|` correctly 
evaluates (as far as I can tell) to the current doc path.

Code sample at 
https://gist.github.com/bstro/ef0a46ccbd3ae770893124904db57226 

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Re: Library for rendering Pollen to JSON?

2019-02-28 Thread Brendan Stromberger
Thanks all! I want to publish this as a website as well as a PDF and ePub 
(expect another post regarding epub at some point ;)) There's a large 
section of the book that I want to eventually use as a data source for a 
webapp I'm writing in Elm. I might also consider attempting to see if I can 
bypass the JSON-output step and output JSX from Racket and use Pollen for 
the entire pipeline: generating my books, and generating a full client-side 
webapp using the book content as a data source. I'm not sure how I would 
get Pollen to output to JSX but perhaps it isn't as hard as I'm imagining. 
Perhaps it is. 

I'd love some feedback on this idea.

On Tuesday, February 26, 2019 at 9:53:08 AM UTC-5, Brendan Stromberger 
wrote:
>
> Has anyone written a library to generalize (at least to some extent) the 
> process of rendering a Pollen document to JSON?
>
> Thanks!
> Brendan
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.