M content/docs.html => content/docs.html +0 -2
@@ 11,6 11,4 @@ hide-prev-next: #t
<nav>
{{ [join [sort [map [navigation 1] [fn [v] [render-link v]]]] "<br/>"] }}
</nav>
-<br/>
-<br/>
M content/index.html => content/index.html +6 -6
@@ 69,6 69,12 @@ hide-in-nav: #t
<td><a href="https://builds.sr.ht/~melchizedek6809/Nujel/">SourceHut CI</a></td>
</tr>
<tr>
+ <td>armv7 | aarch64</td>
+ <td>RaspberryPI OS</td>
+ <td>gcc</td>
+ <td>Semi-regular manual testing</td>
+ </tr>
+ <tr>
<td>amd64</td>
<td>DragonflyBSD | HaikuOS</td>
<td>system default</td>
@@ 87,12 93,6 @@ hide-in-nav: #t
<td>Irregular manual testing</td>
</tr>
<tr>
- <td>armv7 | aarch64</td>
- <td>RaspberryPI OS</td>
- <td>gcc</td>
- <td>Irregular manual testing</td>
- </tr>
- <tr>
<td>amd64</td>
<td>Windows 10</td>
<td>Visual Studio</td>
M content/language/index.html => content/language/index.html +1 -1
@@ 17,5 17,5 @@ Most functions/macros borrow their name directly from <i>Clojure</i> or <i>Commo
<h2>Chapters</h2>
<nav>
- {{ [join [sort [map [navigation 2] [fn [v] [render-link v]]]] "<br/>"] }}
+ {{ [join [sort [map [navigation #nil "language/chapters"] [fn [v] [render-link v]]]] "<br/>"] }}
</nav>=
\ No newline at end of file
A content/reference/index.html => content/reference/index.html +12 -0
@@ 0,0 1,12 @@
++++
+title: "Nujel reference"
+nav-title: "Nujel reference"
+date: "2022-09-13"
++++
+
+<h1>The Nujel reference</h1>
+<p>This is an experiment in generating a usable reference using the builtin reflection abilities, they will be pretty terrible at first, but hopefully will improve over time in quality.</p>
+
+<nav>
+ {{ [join [sort [map [navigation 2 "reference/"] [fn [v] [render-link v]]]] "<br/>"] }}
+</nav><
\ No newline at end of file
M main.nuj => main.nuj +0 -3
@@ 6,16 6,13 @@
[import [rainbow] :ansi]
[import [get :as context/get] "ssg/context"]
[import [build :as content/build add-resources] "ssg/content"]
-[import [add-default :as loader/add-default] "ssg/loader"]
[import [load-builtin-themes load-components] "ssg/theme"]
[defn main [args]
:export
[pfmtln "Welcome to the {} SSG" [rainbow "Nujel"]]
[when [and [car args] [string? [car args]]] [cd [car args]]]
-
[-> [context/get "./"]
- loader/add-default
load-builtin-themes
load-components
content/build
M ssg/content.nuj => ssg/content.nuj +1 -6
@@ 2,11 2,6 @@
[import [parse-frontmatter frontmatter get-frontmatter] "theme"]
[import [build-prev-next-list] "navigation"]
-[defn get-out-path [ctx path]
- :export
- [cat [tree/ref ctx :deploy-dir]
- [string/cut path [length [tree/ref ctx :content-root-dir]]]]]
-
[defn add-resources [ctx]
:export
"Copy all resources used over"
@@ 48,4 43,4 @@
[tree/ref ctx :content-root-dir]
content-frontmatter
loader/build]
- ctx]
+ [return ctx]]
M ssg/loader.nuj => ssg/loader.nuj +29 -20
@@ 1,28 1,37 @@
-[def loaders @[]]
+[import [render] "theme"]
-[defn add-loader [extension handler]
- "Add a loader for a specific file extension"
- :export
- [tree/set! loaders extension handler]]
+[defn get-out-path [ctx path]
+ [cat [tree/ref ctx :deploy-dir]
+ [string/cut path [length [tree/ref ctx :content-root-dir]]]]]
-[defn init [ctx]
- [require "loader/copy"]
- [require "loader/config"]
- [require "loader/html-content"]
- [return ctx]]
+[defn mkdir-safe [full-path]
+ [def parts [split full-path "/"]]
+ [def path #nil]
+ [while parts
+ [set! path [if path
+ [cat path "/" [car parts]]
+ [car parts]]]
+ [cdr! parts]
+ [mkdir path]]]
-[defn add-default [ctx]
- "Add the default loaders to the CTX"
- :export
- [init ctx]
- [def ctx-loaders [tree/ref ctx :loaders]]
- [doseq [ext [tree/keys loaders] ctx]
- [tree/set! ctx-loaders ext [tree/ref loaders ext]]]]
+[defn build-html [ctx path]
+ "Loader that just copies the file over"
+ [def dest-path [get-out-path ctx path]]
+ [mkdir-safe [path/dirname dest-path]]
+ [spit dest-path [render ctx path]]
+ [return dest-path]]
+
+[defn build-copy [ctx path]
+ "Loader that just copies the file over"
+ [def dest-path [get-out-path ctx path]]
+ [mkdir-safe [path/dirname dest-path]]
+ [file/copy path dest-path]
+ dest-path]
[defn build [ctx path]
"Build a certain path using the loader"
:export
- [def ctx-loaders [tree/ref ctx :loaders]]
[def ext [string->keyword [lowercase [path/extension path]]]]
- [[or [tree/ref ctx-loaders ext]
- [tree/ref ctx-loaders :otherwise]] ctx path]]
+ [if [== ext :html]
+ [build-html ctx path]
+ [build-copy ctx path]]]
D ssg/loader/config.nuj => ssg/loader/config.nuj +0 -9
@@ 1,9 0,0 @@
-[import [add-loader] "../loader"]
-[import [get-out-path] "../content"]
-[import [render] "../theme"]
-
-[defn build [ctx path]
- "Loader that just copies the file over"
- [return #nil]]
-
-[add-loader :nuj build]
D ssg/loader/copy.nuj => ssg/loader/copy.nuj +0 -11
@@ 1,11 0,0 @@
-[import [add-loader] "../loader"]
-[import [get-out-path] "../content"]\
-
-[defn build [ctx path]
- "Loader that just copies the file over"
- [def dest-path [get-out-path ctx path]]
- [mkdir [path/dirname dest-path]]
- [file/copy path dest-path]
- dest-path]
-
-[add-loader :otherwise build]
D ssg/loader/html-content.nuj => ssg/loader/html-content.nuj +0 -22
@@ 1,22 0,0 @@
-[import [add-loader] "../loader"]
-[import [get-out-path] "../content"]
-[import [render] "../theme"]
-
-[defn mkdir-safe [full-path]
- [def parts [split full-path "/"]]
- [def path #nil]
- [while parts
- [set! path [if path
- [cat path "/" [car parts]]
- [car parts]]]
- [cdr! parts]
- [mkdir path]]]
-
-[defn build [ctx path]
- "Loader that just copies the file over"
- [def dest-path [get-out-path ctx path]]
- [mkdir-safe [path/dirname dest-path]]
- [spit dest-path [render ctx path]]
- [return dest-path]]
-
-[add-loader :html build]
M ssg/navigation.nuj => ssg/navigation.nuj +11 -8
@@ 22,11 22,14 @@
[cdr! c]]
[tree/set! ctx :prev-next-nav nav]]
-[defn build [ctx depth]
- "Build up a navigation and return a list of trees, describing the entries"
- :export
- [-> [tree/values [tree/ref ctx :frontmatter]]
- [filter [fn [a] [== depth [tree/ref a :depth]]]]
- [filter [fn [a] [not [tree/ref a :hide-in-nav]]]]
- [list/sort [fn [a b] [< [tree/ref a :href]
- [tree/ref b :href]]]]]]
+[defn build [ctx depth prefix]
+ "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]]]]]]
+ [when depth
+ [set! l [filter l [fn [a] [== depth [tree/ref a :depth]]]]]]
+ [when prefix
+ [set! l [filter l [fn [a] [== prefix [cut [tree/ref a :href] 0 [buffer/length prefix]]]]]]]
+ [list/sort l [fn [a b] [< [tree/ref a :href]
+ [tree/ref b :href]]]]]
D ssg/pretty.nuj => ssg/pretty.nuj +0 -14
@@ 1,14 0,0 @@
-[defn pp-nujel-top [source i pp]
- [def len [buffer/length i]]
- [while [< i len]
- [def c [buffer/ref source i]]
- [case c
- [\; [set! i [pp-nujel-comment-eol source [inc i] pp]]]
- [otherwise [pp 'char-write c]
- [inc/int i]]]]]
-
-[defn pretty-print-nujel [source]
- :export
- [def pp [make-string-output-port]]
- [pp-nujel-top source 0 pp]
- [pp 'return-string]]
M ssg/theme.nuj => ssg/theme.nuj +4 -3
@@ 1,10 1,11 @@
[import [build :as navigation/build] "navigation"]
+[def themes @[]]
+
[defn Nujel [source]
[import [pp-nujel] :pretty/nujel]
[pp-nujel source :html]]
-[def themes @[]]
[defn add-theme [name mod]
[tree/set! themes name [module/load mod [current-closure]]]]
@@ 139,8 140,8 @@
[defn get-href [target]
[get-href* [get-ctx] [get-path] target]]
-[defn navigation [depth]
- [navigation/build [get-ctx] depth]]
+[defn navigation [depth prefix]
+ [navigation/build [get-ctx] depth prefix]]
[defn get-posts []
[def ret #nil]
M ssg/theme/default.nuj => ssg/theme/default.nuj +12 -25
@@ 2,31 2,18 @@
[def +theme-path+ [fmt "{}/default" *module-path*]]
-[defn load-templates [ctx]
- "Load all the partials"
- :export
- [doseq [comp-file [directory/read-recursive [fmt "{+theme-path+}/templates"]] ctx]
- [add-template ctx
- [-> comp-file
- path/basename
- path/without-extension
- string->keyword]
- [slurp comp-file]
- [cat [path/dirname comp-file] "/.."]]]]
-
-[defn load-components [ctx]
- "Load all the partials"
- :export
- [doseq [comp-file [directory/read-recursive [fmt "{+theme-path+}/components"]] ctx]
- [add-component ctx
- [-> comp-file
- path/basename
- path/without-extension
- string->keyword]
- [slurp comp-file]
- [cat [path/dirname comp-file] "/.."]]]]
+[defn load-part [ctx suffix fun]
+ [doseq [comp-file [directory/read-recursive [fmt "{+theme-path+}/{suffix}"]] ctx]
+ [fun
+ ctx
+ [-> comp-file
+ path/basename
+ path/without-extension
+ string->keyword]
+ [slurp comp-file]
+ [cat [path/dirname comp-file] "/.."]]]]
[defn init [ctx]
:export
- [load-components ctx]
- [load-templates ctx]]
+ [load-part ctx "templates" add-template]
+ [load-part ctx "components" add-component]]