Re: [pollen] Navigation issue with Pollen templates

2019-03-01 Thread Brendan Stromberger
Alright, I'm up and running :)
Thanks!

On Friday, March 1, 2019 at 2:13:46 PM UTC-5, Matthew Butterick wrote:
>
>
> On Mar 1, 2019, at 11:08 AM, Brendan Stromberger  > wrote:
>
> build-path: contract violation
>   expected: (or/c path-for-some-system? path-string? 'up 'same)
>   given: 'body/2_understanding_the_lines.poly.pm
>   argument position: 2nd
>   other arguments...:
>#
>
> My error, the last line needs to look like this (converting the node, 
> which is a symbol, to a string, which `build-path` will accept):
>
> (define next-url (->output-path (build-path (current-project-root) 
> (symbol->string next-path-pagenode
>
>
>

-- 
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-03-01 Thread Matthew Butterick

> On Mar 1, 2019, at 11:08 AM, Brendan Stromberger 
>  wrote:
> 
> build-path: contract violation
>   expected: (or/c path-for-some-system? path-string? 'up 'same)
>   given: 'body/2_understanding_the_lines.poly.pm
>   argument position: 2nd
>   other arguments...:
>#
My error, the last line needs to look like this (converting the node, which is 
a symbol, to a string, which `build-path` will accept):

(define next-url (->output-path (build-path (current-project-root) 
(symbol->string next-path-pagenode


-- 
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-03-01 Thread Brendan Stromberger
Whoops, the inconsistency with the paths and the extensions was my bad, my 
ptree file was borked. :) 

On Friday, March 1, 2019 at 2:08:52 PM UTC-5, Brendan Stromberger wrote:
>
> Thanks for your help. Here are some output values for the functions 
> defined...
>
> root: /Users/vro/Desktop/dev/richmond/ 
> here-path: /Users/vro/Desktop/dev/richmond/body/3_the_trigrams.poly.pm 
> here-path-relative: body/3_the_trigrams.poly.pm 
> here-path-pagenode: body/3_the_trigrams.poly.pm 
> next-path-pagenode: body/3_the_trigrams.html.pm 
> prev-path-pagenode: body/2_understanding_the_lines.poly.pm
>
> If I drop the definitions for previous-url and next-url in there, I get 
> the following error:
>
> build-path: contract violation
>   expected: (or/c path-for-some-system? path-string? 'up 'same)
>   given: 'body/2_understanding_the_lines.poly.pm
>   argument position: 2nd
>   other arguments...:
>#
>
>
> That said, the values for next-path-pagenode and prev-path-pagenode seem 
> incorrect, and it seems odd to me that next-path-pagenode references a .
> html.pm file, where prev-path-pagenode references a .poly.pm file. I'm 
> gonna keep cracking on this. My will is being tested :)
>
> Thanks for your help so far.
> Brendan
>
> On Thursday, February 28, 2019 at 7:39:02 PM UTC-5, Matthew Butterick 
> wrote:
>>
>>
>>
>> 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-03-01 Thread Brendan Stromberger
Thanks for your help. Here are some output values for the functions 
defined...

root: /Users/vro/Desktop/dev/richmond/ 
here-path: /Users/vro/Desktop/dev/richmond/body/3_the_trigrams.poly.pm 
here-path-relative: body/3_the_trigrams.poly.pm 
here-path-pagenode: body/3_the_trigrams.poly.pm 
next-path-pagenode: body/3_the_trigrams.html.pm 
prev-path-pagenode: body/2_understanding_the_lines.poly.pm

If I drop the definitions for previous-url and next-url in there, I get the 
following error:

build-path: contract violation
  expected: (or/c path-for-some-system? path-string? 'up 'same)
  given: 'body/2_understanding_the_lines.poly.pm
  argument position: 2nd
  other arguments...:
   #


That said, the values for next-path-pagenode and prev-path-pagenode seem 
incorrect, and it seems odd to me that next-path-pagenode references a 
.html.pm file, where prev-path-pagenode references a .poly.pm file. I'm 
gonna keep cracking on this. My will is being tested :)

Thanks for your help so far.
Brendan

On Thursday, February 28, 2019 at 7:39:02 PM UTC-5, Matthew Butterick wrote:
>
>
>
> 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 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] 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.