Although you may use these definitions in your frog.rkt, they
are more likely to be used by third-party Body enhancers.
(This module is automatically required for you by the
frog/config language used in frog.rkt.)
These definitions represent locations of certain local directories and
files — as well as translating between local filesystem paths and
URI paths that will work on the deployed web site. One wrinkle is that
the local file paths might be Windows style, which differs from the
Unix style used by URI paths.
(top) → (or/c #f absolute-path?)
|
| (top path) → void? |
| path : (or/c #f absolute-path?) |
The project directory root. Frog sets the value
after it has initialized and found the location of
frog.rkt. Many other functions in this
module expect
top to be non-
#f,
so for example in unit tests you may need to
set this yourself.
(src-path) → absolute-path?
|
Resolved location of current-source-dir.
(src/posts-path) → absolute-path?
|
The "posts" subdirectory of src-path.
(post-template.html) → absolute-path?
|
The "post-template.html" file in src-path.
(page-template.html) → absolute-path?
|
The "page-template.html" file in src-path.
(index-template.html) → absolute-path?
|
The "index-template.html" in src-path.
(obj-path) → absolute-path?
|
The ".frog" build cache subdirectory.
(www-path) → absolute-path?
|
Root of the output files, as determined by current-output-dir.
(www/tags-path) → absolute-path?
|
The "tags/" subdirectory of www-path.
(www/feeds-path) → absolute-path?
|
The "feeds/" subdirectory of www-path.
(www/img-path) → absolute-path?
|
The "img/" subdirectory of www-path.
(www/index-pathname) → absolute-path?
|
Resolves current-posts-index-uri regardless of it being any
of "/path/index.html", "\path\index.html", or
"c:\path\index.html"
(abs->rel/www path) → string?
|
| path : absolute-path? |
Convert an absolute local path to a URI path string relative to
www-path — which in turn is relative to
current-output-dir. The result is always in Unix style
(even on Windows) so it is suitable for use as a URI path.
For example if top is "/project/blog" and
current-output-dir is "../build",
then given "/project/build/css" this should return
"/css". Same result if on Windows and top is
"c:\project\blog" and current-output-dir is
"..\build".
NOTE: If you’re creating a URI that a client will use to make an
HTTP request — e.g. you will write it in an HTML, feed, or sitemap
file — this result isn’t sufficient. You should run the result
through canonical-uri, and if you need current-scheme/host
prepended, in turn through full-uri.
Examples:
| > (require frog/paths frog/params) |
| > (parameterize ([top "/projects/blog"] | | [current-output-dir "."]) | | (abs->rel/www (string->path "/projects/blog/css"))) |
|
"/css" |
| > (parameterize ([top "/projects/blog"] | | [current-output-dir "../build"]) | | (abs->rel/www (string->path "/projects/build/css"))) |
|
"/css" |
(abs->rel/src path) → path-string?
|
| path : absolute-path? |
Convert an absolute local path to a local path-string relative to
src-path.
(abs->rel/top path) → path-string?
|
| path : absolute-path? |
Convert an absolute local path to a local path-string relative to
top.
(canonical-uri uri-path) → string?
|
| uri-path : string? |
Possibly rewrite a URI path to take account of non-#f
current-uri-prefix and uri-path-segment-encode
it.
Examples:
| > (require frog/paths frog/params) |
| > (canonical-uri "relative/λ/path") |
"relative/%3F/path" |
| > (parameterize ([current-uri-prefix #f]) | | (canonical-uri "/absolute/λ/path")) |
|
"/absolute/%3F/path" |
| > (parameterize ([current-uri-prefix "/prefix"]) | | (canonical-uri "/absolute/λ/path")) |
|
"/prefix/absolute/%3F/path" |
(full-uri uri-path) → string?
|
| uri-path : string? |
Given a URI path string, prepend the scheme & host to make a full URI.
Examples:
| > (require frog/paths frog/params) |
| > (parameterize ([current-scheme/host "https://www.example.com"]) | | (full-uri "/absolute/path/to/file.html")) |
|
"https://www.example.com/absolute/path/to/file.html" |
(slug s) → string?
|
| s : string? |
Convert a string into a "slug", in which:
The string is Unicode normalized to NFC form using
string-normalize-nfc
Consecutive characters that are neither
char-alphabetic? nor char-numeric?
are replaced by hyphens.
The string is Unicode normalized to NFD form using
string-normalize-nfd
Examples:
| > (require frog/paths) |
| > (slug "Foo? Bar. Baz.") |
"Foo-Bar-Baz" |
| > (slug "Here's a question--how many hyphens???") |
"Here-s-a-question-how-many-hyphens" |
| > (slug "La biblioteca está en el estómago de Godzilla") |
"La-biblioteca-está-en-el-estómago-de-Godzilla" |