feat: navbar
This commit is contained in:
17
dev/user.clj
Normal file
17
dev/user.clj
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
(ns user
|
||||||
|
(:require [net.deertopia.doerg.server :as server]
|
||||||
|
[net.deertopia.doerg.config :as cfg]
|
||||||
|
[net.deertopia.doerg.cached-file :as cached-file]
|
||||||
|
[babashka.fs :as fs]))
|
||||||
|
|
||||||
|
(cfg/load-config! :profile :dev)
|
||||||
|
|
||||||
|
(when (not= :running (server/status))
|
||||||
|
(server/start!))
|
||||||
|
|
||||||
|
(defn invalidate-html-cache! []
|
||||||
|
(fs/delete-tree (server/html-dir))
|
||||||
|
nil)
|
||||||
|
|
||||||
|
(defn toggle-html-cache! []
|
||||||
|
(alter-var-root #'cached-file/*use-cache?* not))
|
||||||
@@ -66,9 +66,6 @@
|
|||||||
(throw (ex-info "Failed to conform config"
|
(throw (ex-info "Failed to conform config"
|
||||||
(s/explain-data ::config r))))))
|
(s/explain-data ::config r))))))
|
||||||
|
|
||||||
(defn load-config! [var spec files & {:as opts}]
|
|
||||||
(alter-var-root var (constantly (read-config files opts))))
|
|
||||||
|
|
||||||
(def sources
|
(def sources
|
||||||
[;; Default config.
|
[;; Default config.
|
||||||
(io/resource "net/deertopia/doerg/default-config.edn")
|
(io/resource "net/deertopia/doerg/default-config.edn")
|
||||||
@@ -80,3 +77,10 @@
|
|||||||
(def default (read-config sources))
|
(def default (read-config sources))
|
||||||
|
|
||||||
(def ^:dynamic *cfg* default)
|
(def ^:dynamic *cfg* default)
|
||||||
|
|
||||||
|
(defn load-config!
|
||||||
|
([& {:as opts :keys [files]
|
||||||
|
:or {files sources}}]
|
||||||
|
(let [passthru-opts (-> opts (dissoc :files))]
|
||||||
|
(alter-var-root
|
||||||
|
#'*cfg* (constantly (read-config files passthru-opts))))))
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
(defn org-document
|
(defn org-document
|
||||||
"Recursively render an Org-mode document to Hiccup."
|
"Recursively render an Org-mode document to Hiccup."
|
||||||
[doc & {:as opts :keys [postamble]}]
|
[doc & {:as opts :keys [postamble header]}]
|
||||||
(binding [*opts* opts]
|
(binding [*opts* opts]
|
||||||
(tex-temml/binding-worker
|
(tex-temml/binding-worker
|
||||||
(let [rendered (-> doc gather-footnotes render-tex-snippets
|
(let [rendered (-> doc gather-footnotes render-tex-snippets
|
||||||
@@ -73,6 +73,8 @@
|
|||||||
[:title "org document"]
|
[:title "org document"]
|
||||||
doerg-html/head]
|
doerg-html/head]
|
||||||
[:body {:lang default-language}
|
[:body {:lang default-language}
|
||||||
|
(when header
|
||||||
|
[:header header])
|
||||||
[:article
|
[:article
|
||||||
rendered
|
rendered
|
||||||
(when postamble
|
(when postamble
|
||||||
@@ -273,6 +275,9 @@
|
|||||||
(defmethod org-element "bold" [{:keys [children]}]
|
(defmethod org-element "bold" [{:keys [children]}]
|
||||||
[:b children])
|
[:b children])
|
||||||
|
|
||||||
|
(defmethod org-element "strike-through" [{:keys [children]}]
|
||||||
|
[:s children])
|
||||||
|
|
||||||
(defmethod org-element "subscript" [{:keys [children]}]
|
(defmethod org-element "subscript" [{:keys [children]}]
|
||||||
[:sub children])
|
[:sub children])
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,21 @@
|
|||||||
#_[:a {:href (str "/n/" (slug/from-uuid path))}
|
#_[:a {:href (str "/n/" (slug/from-uuid path))}
|
||||||
(or (seq children) raw-link)]])
|
(or (seq children) raw-link)]])
|
||||||
|
|
||||||
|
(def navbar
|
||||||
|
"Hiccup element for Deertopia.net's navbar."
|
||||||
|
[:nav.navbar
|
||||||
|
[:ol.navbar-list
|
||||||
|
[:li
|
||||||
|
[:a.home-link {:href "/"}
|
||||||
|
"🦌 deertopia.net"]]
|
||||||
|
#_[:li
|
||||||
|
[:a.home-link {:href "/graph"}
|
||||||
|
"graph"]]
|
||||||
|
#_
|
||||||
|
[:li
|
||||||
|
[:a.home-link {:onclick "alert('unimplemented }:(')"}
|
||||||
|
"search"]]]])
|
||||||
|
|
||||||
(defn backlinks-postamble [node]
|
(defn backlinks-postamble [node]
|
||||||
(let [backlinks (roam/backlinks node)]
|
(let [backlinks (roam/backlinks node)]
|
||||||
(when-not (empty? backlinks)
|
(when-not (empty? backlinks)
|
||||||
@@ -93,7 +108,8 @@
|
|||||||
:stale? (cached-file/newer-than? org-file html-file)
|
:stale? (cached-file/newer-than? org-file html-file)
|
||||||
:compute #(doerg-render/to-html
|
:compute #(doerg-render/to-html
|
||||||
org-file
|
org-file
|
||||||
:postamble (backlinks-postamble node)))
|
:postamble (backlinks-postamble node)
|
||||||
|
:header navbar))
|
||||||
(-> (str html-file)
|
(-> (str html-file)
|
||||||
response/file-response
|
response/file-response
|
||||||
(response/content-type "text/html")))
|
(response/content-type "text/html")))
|
||||||
|
|||||||
Reference in New Issue
Block a user