Checking for pagetree parent fails on Windows. #254

Closed
opened 3 years ago by leemeichin · 3 comments
leemeichin commented 3 years ago (Migrated from github.com)

Given a pagetree with nesting (i.e. index.ptree):

#lang pollen

index.html
◊posts{
  posts/some-post.html
}

And a template, template.html.p:

◊when/splice[(equal? 'posts (parent here))]{
  <h1>It works</h1>
}
(->html doc)

And the file posts/some-post.poly.pm:

#lang pollen

Any old text

When running raco pollen start on Windows and visiting posts/some-post.html, <h1>It works</h1> won't render.
When running raco pollen start on Linux and visiting posts/some-post.html, <h1>It works</h1> will render.

Upon further inspection, there is some confusion with path separators, as the rendered ptree looks like this:

...
posts/
  posts\some-post.html

I suspect there's something within pagetrees that misses out a normalised path when creating a nested pagetree.

Given a pagetree with nesting (i.e. `index.ptree`): ```racket #lang pollen index.html ◊posts{ posts/some-post.html } ``` And a template, `template.html.p`: ```racket ◊when/splice[(equal? 'posts (parent here))]{ <h1>It works</h1> } ◊(->html doc) ``` And the file `posts/some-post.poly.pm`: ```racket #lang pollen Any old text ``` When running `raco pollen start` on Windows and visiting `posts/some-post.html`, `<h1>It works</h1>` won't render. When running `raco pollen start` on Linux and visiting `posts/some-post.html`, `<h1>It works</h1>` will render. Upon further inspection, there is some confusion with path separators, as the rendered ptree looks like this: ```racket ... posts/ posts\some-post.html ``` I suspect there's something within pagetrees that misses out a normalised path when creating a nested pagetree.
mbutterick commented 3 years ago (Migrated from github.com)

here-path is the absolute path according to local platform conventions (on the idea that this is the least astonishing way to present a local path). here is the same path, converted to an output path that is relative to the current project root. You are running Windows, so both here-path and here adhere to Windows path conventions. Whereas your pagetree seems to assume Linux path conventions.

`here-path` is the absolute path according to local platform conventions (on the idea that this is the least astonishing way to present a local path). `here` is the same path, converted to an output path that is relative to the current project root. You are running Windows, so both `here-path` and `here` adhere to Windows path conventions. Whereas your pagetree seems to assume Linux path conventions.
otherjoel commented 3 years ago (Migrated from github.com)

See also previous discussion on this issue: https://github.com/mbutterick/pollen-users/issues/71

See also previous discussion on this issue: https://github.com/mbutterick/pollen-users/issues/71
leemeichin commented 3 years ago (Migrated from github.com)

That's an enlightening discussion! @otherjoel I'd actually borrowed something from one of your repos, when looking for inspiration. Namely, include-files, here: https://github.com/otherjoel/thenotepad/blob/master/index.ptree#L3-L6.

This wasn't an issue with Pollen after all, it was just the hard-coded "~a/~a" format string. I'm still pretty new to Racket so I hodge-podged a tweak into it so it calls simplify-path and ensures the string is normalised.

-   (map (λ (str) (string->symbol (format "~a/~a" folder (string-replace str extension "html"))))
+   (map (λ (str) (string->symbol (path->string (simplify-path (format "~a/~a" folder (string-replace str extension "html"))))))

Apologies for the mis-filed issue here :) I'll close it as there's nothing to fix.

Thank you also @mbutterick for the fantastic library and extensive documentation and tutorials. I came here from Beautiful Racket and thought I'd give it a shot; it's fascinating!

That's an enlightening discussion! @otherjoel I'd actually borrowed something from one of your repos, when looking for inspiration. Namely, `include-files`, here: https://github.com/otherjoel/thenotepad/blob/master/index.ptree#L3-L6. This wasn't an issue with Pollen after all, it was just the hard-coded `"~a/~a"` format string. I'm still pretty new to Racket so I hodge-podged a tweak into it so it calls `simplify-path` and ensures the string is normalised. ```diff - (map (λ (str) (string->symbol (format "~a/~a" folder (string-replace str extension "html")))) + (map (λ (str) (string->symbol (path->string (simplify-path (format "~a/~a" folder (string-replace str extension "html")))))) ``` Apologies for the mis-filed issue here :) I'll close it as there's nothing to fix. Thank you also @mbutterick for the fantastic library and extensive documentation and tutorials. I came here from Beautiful Racket and thought I'd give it a shot; it's fascinating!
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#254
Loading…
There is no content yet.