M ssg/content.nuj => ssg/content.nuj +16 -16
@@ 4,8 4,8 @@
(defn add-resources (ctx)
:export
"Copy all resources used over"
- (def deploy-dir (tree/ref ctx :deploy-dir))
- (doseq (res (tree/values (tree/ref ctx :resources-needed)) ctx)
+ (def deploy-dir (ref ctx :deploy-dir))
+ (doseq (res (tree/values (ref ctx :resources-needed)) ctx)
(mkdir (fmt "{deploy-dir}/{}" (path/dirname (cdr res))))
(file/copy (car res) (fmt "{deploy-dir}/{}" (cdr res)))))
@@ 27,19 27,19 @@
(defn queue-content* (ctx base-path out-path fm content-fun)
(def path (cat base-path out-path))
- (def href (string/cut path (inc (length (tree/ref ctx :content-root-dir)))))
+ (def href (string/cut path (inc (length (ref ctx :content-root-dir)))))
(tree/set! fm :href href)
- (tree/set! fm :depth (- (length (split (tree/ref fm :href) "/")) 1))
- (tree/set! (tree/ref ctx :frontmatter) (string->keyword href) fm)
- (tree/set! (tree/ref ctx :generator-queue) (string->keyword href) {:path path :meta fm :fun content-fun}))
+ (tree/set! fm :depth (- (length (split (ref fm :href) "/")) 1))
+ (tree/set! (ref ctx :frontmatter) (string->keyword href) fm)
+ (tree/set! (ref ctx :generator-queue) (string->keyword href) {:path path :meta fm :fun content-fun}))
(defn generate-content (ctx)
"Generate all autogenerated content"
:export
(build-content ctx
- (tree/ref ctx :content-root-dir)
- (tree/ref ctx :frontmatter)
+ (ref ctx :content-root-dir)
+ (ref ctx :frontmatter)
(fn (ctx path content-frontmatter)
(when-not (== (path/basename path) "generator.nuj")
(return #nil))
@@ 55,11 55,11 @@
:export
(def content-frontmatter {})
(build-content ctx
- (tree/ref ctx :content-root-dir)
+ (ref ctx :content-root-dir)
content-frontmatter
(fn (ctx path content-frontmatter)
(load-frontmatter path
- (string/cut path (inc (length (tree/ref ctx :content-root-dir))))
+ (string/cut path (inc (length (ref ctx :content-root-dir))))
content-frontmatter)))
(tree/set! ctx :frontmatter content-frontmatter))
@@ 67,15 67,15 @@
"Build everything"
:export
(build-content ctx
- (tree/ref ctx :content-root-dir)
- (tree/ref ctx :frontmatter)
+ (ref ctx :content-root-dir)
+ (ref ctx :frontmatter)
loader/build))
(defn build-queued (ctx)
"Build queued generator content"
:export
- (doseq (d (tree/values (tree/ref ctx :generator-queue)) ctx)
- (def raw-content ((tree/ref d :fun)))
- (def path (get-out-path ctx (tree/ref d :path)))
+ (doseq (d (tree/values (ref ctx :generator-queue)) ctx)
+ (def raw-content ((ref d :fun)))
+ (def path (get-out-path ctx (ref d :path)))
(mkdir-safe (path/dirname path))
- (spit path (render ctx path (tree/ref d :meta) raw-content))))
+ (spit path (render ctx path (ref d :meta) raw-content))))
M ssg/loader.nuj => ssg/loader.nuj +3 -3
@@ 2,8 2,8 @@
(defn get-out-path (ctx path)
:export
- (cat (tree/ref ctx :deploy-dir)
- (string/cut path (length (tree/ref ctx :content-root-dir)))))
+ (cat (ref ctx :deploy-dir)
+ (string/cut path (length (ref ctx :content-root-dir)))))
(defn mkdir-safe (full-path)
:export
@@ 23,7 23,7 @@
(mkdir-safe (path/dirname dest-path))
(def page-parts (split-frontmatter (slurp path)))
(def meta (get-frontmatter path
- (string/cut path (inc (length (tree/ref ctx :content-root-dir))))
+ (string/cut path (inc (length (ref ctx :content-root-dir))))
(car page-parts)))
(spit dest-path (render ctx path meta (cdr page-parts)))
(return dest-path))
M ssg/navigation.nuj => ssg/navigation.nuj +20 -20
@@ 3,35 3,35 @@
"not be displayed on every page but will be calculated nonetheless"
:export
(def nav {})
- (def l (-> (tree/values (tree/ref ctx :frontmatter))
- (list/sort (fn (a b) (< (tree/ref a :href)
- (tree/ref b :href))))))
+ (def l (-> (tree/values (ref ctx :frontmatter))
+ (list/sort (fn (a b) (< (ref a :href)
+ (ref b :href))))))
(def c l)
(while (cdr c)
- (when (== (path/dirname (tree/ref (car c) :href))
- (path/dirname (tree/ref (cadr c) :href)))
- (def cur-href (string->keyword (tree/ref (cadr c) :href)))
- (def prev-href (tree/ref (car c) :href))
- (when-not (tree/ref nav cur-href) (tree/set! nav cur-href {:prev #nil :next #nil}))
- (tree/set! (tree/ref nav cur-href) :prev prev-href)
+ (when (== (path/dirname (ref (car c) :href))
+ (path/dirname (ref (cadr c) :href)))
+ (def cur-href (string->keyword (ref (cadr c) :href)))
+ (def prev-href (ref (car c) :href))
+ (when-not (ref nav cur-href) (tree/set! nav cur-href {:prev #nil :next #nil}))
+ (tree/set! (ref nav cur-href) :prev prev-href)
- (def cur-href (string->keyword (tree/ref (car c) :href)))
- (def next-href (tree/ref (cadr c) :href))
- (when-not (tree/ref nav cur-href) (tree/set! nav cur-href {:prev #nil :next #nil}))
- (tree/set! (tree/ref nav cur-href) :next next-href))
+ (def cur-href (string->keyword (ref (car c) :href)))
+ (def next-href (ref (cadr c) :href))
+ (when-not (ref nav cur-href) (tree/set! nav cur-href {:prev #nil :next #nil}))
+ (tree/set! (ref nav cur-href) :next next-href))
(cdr! c))
(tree/set! ctx :prev-next-nav nav))
(defn build (ctx depth prefix category)
"Build up a navigation and return a list of trees, describing the entries"
:export
- (def l (-> (tree/values (tree/ref ctx :frontmatter))
- (filter (fn (a) (not (tree/ref a :hide-in-nav))))))
+ (def l (-> (tree/values (ref ctx :frontmatter))
+ (filter (fn (a) (not (ref a :hide-in-nav))))))
(when depth
- (set! l (filter l (fn (a) (== depth (tree/ref a :depth))))))
+ (set! l (filter l (fn (a) (== depth (ref a :depth))))))
(when prefix
- (set! l (filter l (fn (a) (== prefix (cut (tree/ref a :href) 0 (buffer/length prefix)))))))
+ (set! l (filter l (fn (a) (== prefix (cut (ref a :href) 0 (buffer/length prefix)))))))
(when category
- (set! l (filter l (fn (a) (== category (tree/ref a :category))))))
- (list/sort l (fn (a b) (< (tree/ref a :href)
- (tree/ref b :href)))))
+ (set! l (filter l (fn (a) (== category (ref a :category))))))
+ (list/sort l (fn (a b) (< (ref a :href)
+ (ref b :href)))))
M ssg/theme.nuj => ssg/theme.nuj +21 -21
@@ 15,20 15,20 @@
(return ctx))
(defn include-resource* (ctx path dest-path)
- (tree/set! (tree/ref ctx :resources-needed) (string->keyword path) (cons path dest-path))
+ (tree/set! (ref ctx :resources-needed) (string->keyword path) (cons path dest-path))
(return dest-path))
(defn load-components (ctx)
:export
(import (init :as theme/init)
- (tree/ref themes (tree/ref ctx :theme)))
+ (ref themes (ref ctx :theme)))
(theme/init ctx)
ctx)
(defn render (ctx path)
:export
"Apply a theme to a particular file in PATH"
- (def theme (tree/ref themes (tree/ref ctx :theme)))
+ (def theme (ref themes (ref ctx :theme)))
(import (render :as cur/render load-components) theme)
(load-components ctx)
(cur/render ctx path))
@@ 120,7 120,7 @@
(defn urlescape (in)
(with-string-port out
(dotimes (i (buffer/length in))
- (def c (buffer/ref in i))
+ (def c (ref in i))
(case c
(#\# (out 'block-write "%23"))
(#\& (out 'block-write "%26"))
@@ 128,26 128,26 @@
(otherwise (out 'char-write c))))))
(defn get-href* (ctx path target)
- (def name (string/cut path (inc (length (tree/ref ctx :content-root-dir)))))
+ (def name (string/cut path (inc (length (ref ctx :content-root-dir)))))
(def depth (- (length (split name "/")) 1))
(def href (if (tree? target)
- (tree/ref target :href)
+ (ref target :href)
target))
(dotimes (i depth (urlescape href))
(set! href (cat "../" href))))
(defn render-link* (ctx path target)
(if (string? target)
- (render-link* ctx path (tree/ref (tree/ref ctx :frontmatter) (string->keyword target)))
+ (render-link* ctx path (ref (ref ctx :frontmatter) (string->keyword target)))
(fmt "<a href=\"{}\" class=\"{}\">{}</a>"
(get-href* ctx path target)
(do (def classes #nil)
- (def tags (and (tree? target) (tree/ref target :tags)))
+ (def tags (and (tree? target) (ref target :tags)))
(doseq (tag tags) (cons! (cat "tag-" (keyword->string tag)) classes))
(join classes " "))
(if (tree? target)
- (or (tree/ref target :nav-title)
- (tree/ref target :title))
+ (or (ref target :nav-title)
+ (ref target :title))
target))))
(defn render-link (target)
@@ 161,8 161,8 @@
(defn get-posts ()
(def ret #nil)
- (doseq (p (tree/values (tree/ref (get-ctx) :frontmatter)) ret)
- (when (== :post (tree/ref p :type))
+ (doseq (p (tree/values (ref (get-ctx) :frontmatter)) ret)
+ (when (== :post (ref p :type))
(cons! p ret))))
(defn include-resource (res-path)
@@ 178,29 178,29 @@
(ref (get-ctx) :title)))
(defn this-href ()
- (string/cut (get-path) (inc (length (tree/ref (get-ctx) :content-root-dir)))))
+ (string/cut (get-path) (inc (length (ref (get-ctx) :content-root-dir)))))
(defn this-prev-next ()
- (tree/ref (tree/ref (get-ctx) :prev-next-nav)
+ (ref (ref (get-ctx) :prev-next-nav)
(string->keyword (this-href))))
(defn this-prev ()
(and (this-prev-next)
- (tree/ref (this-prev-next) :prev)))
+ (ref (this-prev-next) :prev)))
(defn this-next ()
(and (this-prev-next)
- (tree/ref (this-prev-next) :next)))
+ (ref (this-prev-next) :next)))
(defn component (name props children)
- (def component-fun (tree/ref (tree/ref (get-ctx) :components) name))
+ (def component-fun (ref (ref (get-ctx) :components) name))
(when-not component-fun (exception "Can't find a component called: " name))
(try (fn (err)
(efmtln "Error while rendering component {name}"))
(component-fun props children)))
(defn template (name props children)
- (def template-fun (tree/ref (tree/ref (get-ctx) :templates) (or name :page)))
+ (def template-fun (ref (ref (get-ctx) :templates) (or name :page)))
(when-not template-fun (exception "Can't find a template named: " name))
(try (fn (err)
(efmtln "Error while rendering theme {name}"))
@@ 208,13 208,13 @@
(defn add-component (ctx name raw-text component-path)
:export
- (tree/set! (tree/ref ctx :components)
+ (tree/set! (ref ctx :components)
name
(parse-component raw-text component-path)))
(defn add-template (ctx name raw-text component-path)
:export
- (tree/set! (tree/ref ctx :templates)
+ (tree/set! (ref ctx :templates)
name
(parse-component raw-text component-path)))
@@ 236,6 236,6 @@
(efmtln "Error while rendering {path}")
(efmtln "{err:?}"))
(def content (parse-content ctx path raw-content meta))
- (set! ret (template (tree/ref (get-meta) :type) meta content)))
+ (set! ret (template (ref (get-meta) :type) meta content)))
(reset-page-ctx!)
(return ret))
M ssg/theme/default/components/CategoryNavigation.html => ssg/theme/default/components/CategoryNavigation.html +1 -1
@@ 1,6 1,6 @@
<div class="category-navigation">
<h2>{{
- (def cur-cat (tree/ref props :category))
+ (def cur-cat (ref props :category))
(def items (navigation #nil #nil cur-cat))
(fmt "{} ({})" (capitalize (keyword->string cur-cat)) (length items))
}}</h2>
M ssg/theme/default/components/Error.html => ssg/theme/default/components/Error.html +1 -1
@@ 1,4 1,4 @@
<box-wrap box-color="red">
<h3>Error</h3>
- {{ (tree/ref props :message) }}
+ {{ (ref props :message) }}
</box-wrap>
M ssg/theme/default/components/Favicon.html => ssg/theme/default/components/Favicon.html +2 -2
@@ 1,4 1,4 @@
{{
-(when (tree/ref (get-ctx) :favicon)
- (fmt "<link rel=\"icon\" rel=\"icon\" type=\"image/png\" href=\"{}\"/>" (get-href (tree/ref (get-ctx) :favicon))))
+(when (ref (get-ctx) :favicon)
+ (fmt "<link rel=\"icon\" rel=\"icon\" type=\"image/png\" href=\"{}\"/>" (get-href (ref (get-ctx) :favicon))))
}}
M => +1 -1
@@ 1,5 1,5 @@
{{
(case (tree/ref (get-meta) :type)
(case (ref (get-meta) :type)
(:page (component :PageFooter))
(otherwise ""))
}}
M ssg/theme/default/components/Logo.html => ssg/theme/default/components/Logo.html +3 -3
@@ 1,7 1,7 @@
{{
-(when (tree/ref (get-ctx) :logo)
+(when (ref (get-ctx) :logo)
(fmt "<a class=\"logo-link\" href=\"{}\"><img src=\"{}\"/><span>{}</span></a>"
(get-href "index.html")
- (get-href (tree/ref (get-ctx) :logo))
- (tree/ref (get-ctx) :logo-text)))
+ (get-href (ref (get-ctx) :logo))
+ (ref (get-ctx) :logo-text)))
}}
M => +8 -8
@@ 1,18 1,18 @@
<div>
{{ (when (tree/ref (get-ctx) :author)
(cat "by " (tree/ref (get-ctx) :author))) }}
{{ (when (ref (get-ctx) :author)
(cat "by " (ref (get-ctx) :author))) }}
</div>
<div>
{{ (and (tree/ref (get-meta) :date)
(cat "Published " (tree/ref (get-meta) :date)))
{{ (and (ref (get-meta) :date)
(cat "Published " (ref (get-meta) :date)))
}}
{{ (and (tree/ref (get-meta) :modified-date)
(cat "Last modified " (tree/ref (get-meta) :modified-date)))
{{ (and (ref (get-meta) :modified-date)
(cat "Last modified " (ref (get-meta) :modified-date)))
}}
</div>
<div>
{{ (or (tree/ref (get-ctx) :imprint) "") }}
{{ (or (ref (get-ctx) :imprint) "") }}
</div>
<div>
{{ (or (tree/ref (get-ctx) :contact) "") }}
{{ (or (ref (get-ctx) :contact) "") }}
</div>
M ssg/theme/default/components/PostSnippet.html => ssg/theme/default/components/PostSnippet.html +5 -5
@@ 1,10 1,10 @@
<div class="post-snippet">
- <h4 class="post-date">{{ (tree/ref props :date) }}</h4>
+ <h4 class="post-date">{{ (ref props :date) }}</h4>
<h3>
- <a href="{{ (get-href (tree/ref props :href)) }}">
- {{ (tree/ref props :title) }}
+ <a href="{{ (get-href (ref props :href)) }}">
+ {{ (ref props :title) }}
</a>
</h3>
- <p>{{ (tree/ref props :summary) }}</p>
- <a href="{{ (get-href (tree/ref props :href)) }}">Read more</a>
+ <p>{{ (ref props :summary) }}</p>
+ <a href="{{ (get-href (ref props :href)) }}">Read more</a>
</div>
M ssg/theme/default/components/PrevNextNav.html => ssg/theme/default/components/PrevNextNav.html +1 -1
@@ 1,5 1,5 @@
{{
-(when (and (not (tree/ref (get-meta) :hide-prev-next)) (or (this-prev) (this-next)))
+(when (and (not (ref (get-meta) :hide-prev-next)) (or (this-prev) (this-next)))
(cat (fmt "<div class=\"prev-chapter\">{}</div>" (render-link (this-prev)))
(fmt "<div class=\"next-chapter\">{}</div>" (render-link (this-next)))))
}}
M ssg/theme/default/templates/page.html => ssg/theme/default/templates/page.html +1 -1
@@ 7,7 7,7 @@
<link rel="stylesheet" href="{{ (include-resource "resources/main.css") }}"/>
{{ (component :Favicon) }}
</head>
- <body page-type="{{ (keyword->string (or (tree/ref props :type) :page)) }}">
+ <body page-type="{{ (keyword->string (or (ref props :type) :page)) }}">
<header>
{{ (component :Header) }}
</header>
M ssg/theme/default/templates/post.html => ssg/theme/default/templates/post.html +5 -5
@@ 7,15 7,15 @@
<link rel="stylesheet" href="{{ (include-resource "resources/main.css") }}"/>
{{ (component :Favicon) }}
</head>
- <body page-type="{{ (keyword->string (or (tree/ref props :type) :post)) }}">
+ <body page-type="{{ (keyword->string (or (ref props :type) :post)) }}">
<header>
{{ (component :Header) }}
</header>
<main>
- <h4 class="post-date">{{ (tree/ref props :date) }}</h4>
- {{ (when (tree/ref props :author)
- (cat "<h4 class=\"byline\">by " (tree/ref props :author) "</h4>")) }}
- <h1>{{ (tree/ref props :title) }}</h1>
+ <h4 class="post-date">{{ (ref props :date) }}</h4>
+ {{ (when (ref props :author)
+ (cat "<h4 class=\"byline\">by " (ref props :author) "</h4>")) }}
+ <h1>{{ (ref props :title) }}</h1>
{{ children }}
</main>
<footer>