friendly page for non published

This commit is contained in:
Tienson Qin
2025-12-28 22:59:41 +08:00
parent 326254c8f3
commit 0c668505cd
3 changed files with 43 additions and 14 deletions

View File

@@ -1,16 +1,19 @@
import katexPkg from "https://esm.sh/katex@0.16.10?bundle";
import { EditorState } from "https://esm.sh/@codemirror/state@6.4.1?bundle";
import { EditorView } from "https://esm.sh/@codemirror/view@6.28.2?bundle";
import { basicSetup } from "https://esm.sh/@codemirror/basic-setup@0.20.0?bundle";
import { defaultHighlightStyle, syntaxHighlighting } from "https://esm.sh/@codemirror/language@6.10.2?bundle";
import { javascript } from "https://esm.sh/@codemirror/lang-javascript@6.2.2?bundle";
import { python } from "https://esm.sh/@codemirror/lang-python@6.1.6?bundle";
import { html } from "https://esm.sh/@codemirror/lang-html@6.4.9?bundle";
import { css } from "https://esm.sh/@codemirror/lang-css@6.2.1?bundle";
import { json } from "https://esm.sh/@codemirror/lang-json@6.0.1?bundle";
import { markdown } from "https://esm.sh/@codemirror/lang-markdown@6.2.5?bundle";
import { sql } from "https://esm.sh/@codemirror/lang-sql@6.6.2?bundle";
import { clojure } from "https://esm.sh/@nextjournal/lang-clojure@1.0.0?bundle";
import {
EditorState,
EditorView,
basicSetup,
defaultHighlightStyle,
syntaxHighlighting,
javascript,
python,
html,
css,
json,
markdown,
sql,
clojure,
} from "https://esm.sh/@codemirror/basic-setup@0.20.0?bundle";
const katex = katexPkg.default || katexPkg;

View File

@@ -677,3 +677,21 @@
[:span.page-meta (or (format-timestamp (tag-item-val row :updated_at)) "—")]])]
[:p "No published pages reference this yet."])]]]]
(str "<!doctype html>" (render-hiccup doc))))
(defn render-not-published-html
[graph-uuid]
(let [title "Page not published"
doc [:html
[:head
[:meta {:charset "utf-8"}]
[:meta {:name "viewport" :content "width=device-width,initial-scale=1"}]
[:title title]
[:link {:rel "stylesheet" :href "/static/publish.css"}]]
[:body
[:main.wrap
[:div.page-toolbar
(when graph-uuid
[:a.toolbar-btn {:href (str "/graph/" graph-uuid)} "Home"])]
[:h1 title]
[:p.tag-sub "This page hasn't been published yet."]]]]]
(str "<!doctype html>" (render-hiccup doc))))

View File

@@ -401,8 +401,16 @@
#js {:headers (publish-common/merge-headers
#js {"content-type" "text/html; charset=utf-8"}
(publish-common/cors-headers))})
(publish-common/not-found)))
(publish-common/not-found)))
(js/Response.
(publish-render/render-not-published-html graph-uuid)
#js {:headers (publish-common/merge-headers
#js {"content-type" "text/html; charset=utf-8"}
(publish-common/cors-headers))}))))
(js/Response.
(publish-render/render-not-published-html graph-uuid)
#js {:headers (publish-common/merge-headers
#js {"content-type" "text/html; charset=utf-8"}
(publish-common/cors-headers))}))
(js-await [meta (.json meta-resp)
index-id (.idFromName do-ns "index")
index-stub (.get do-ns index-id)