mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix: tagged nodes
This commit is contained in:
47
deps/publish/src/logseq/publish/meta_store.cljs
vendored
47
deps/publish/src/logseq/publish/meta_store.cljs
vendored
@@ -1,6 +1,5 @@
|
||||
(ns logseq.publish.meta-store
|
||||
(:require [cljs-bean.core :as bean]
|
||||
[clojure.string :as string]
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.publish.common :as publish-common])
|
||||
(:require-macros [logseq.publish.async :refer [js-await]]))
|
||||
|
||||
@@ -274,22 +273,38 @@
|
||||
(= (nth parts 1 nil) "tag")
|
||||
(let [tag-name (when-let [raw (nth parts 2 nil)]
|
||||
(js/decodeURIComponent raw))
|
||||
rows (publish-common/get-sql-rows
|
||||
(publish-common/sql-exec sql
|
||||
(str "SELECT page_tags.graph_uuid, page_tags.source_page_uuid, page_tags.source_page_title, "
|
||||
"pages.short_id, "
|
||||
"MAX(page_tags.updated_at) AS updated_at "
|
||||
"FROM page_tags "
|
||||
"LEFT JOIN pages "
|
||||
"ON pages.graph_uuid = page_tags.graph_uuid "
|
||||
"AND pages.page_uuid = page_tags.source_page_uuid "
|
||||
"WHERE page_tags.tag_title = ? "
|
||||
"GROUP BY page_tags.graph_uuid, page_tags.source_page_uuid, page_tags.source_page_title, pages.short_id "
|
||||
"ORDER BY updated_at DESC;")
|
||||
tag-name))]
|
||||
tagged-rows (publish-common/get-sql-rows
|
||||
(publish-common/sql-exec sql
|
||||
(str "SELECT page_tags.graph_uuid, page_tags.tag_page_uuid, page_tags.tag_title, "
|
||||
"page_tags.source_page_uuid, page_tags.source_page_title, page_tags.source_block_uuid, "
|
||||
"page_tags.source_block_content, page_tags.source_block_format, page_tags.updated_at, "
|
||||
"pages.short_id "
|
||||
"FROM page_tags "
|
||||
"LEFT JOIN pages "
|
||||
"ON pages.graph_uuid = page_tags.graph_uuid "
|
||||
"AND pages.page_uuid = page_tags.source_page_uuid "
|
||||
"WHERE page_tags.tag_title = ? "
|
||||
"ORDER BY page_tags.updated_at DESC;")
|
||||
tag-name))
|
||||
page-rows (publish-common/get-sql-rows
|
||||
(publish-common/sql-exec sql
|
||||
(str "SELECT page_tags.graph_uuid, page_tags.source_page_uuid, page_tags.source_page_title, "
|
||||
"pages.short_id, "
|
||||
"MAX(page_tags.updated_at) AS updated_at "
|
||||
"FROM page_tags "
|
||||
"LEFT JOIN pages "
|
||||
"ON pages.graph_uuid = page_tags.graph_uuid "
|
||||
"AND pages.page_uuid = page_tags.source_page_uuid "
|
||||
"WHERE page_tags.tag_title = ? "
|
||||
"GROUP BY page_tags.graph_uuid, page_tags.source_page_uuid, page_tags.source_page_title, pages.short_id "
|
||||
"ORDER BY updated_at DESC;")
|
||||
tag-name))]
|
||||
(publish-common/json-response {:pages (map (fn [row]
|
||||
(js->clj row :keywordize-keys false))
|
||||
rows)}))
|
||||
page-rows)
|
||||
:tagged_nodes (map (fn [row]
|
||||
(js->clj row :keywordize-keys false))
|
||||
tagged-rows)}))
|
||||
|
||||
(= (nth parts 1 nil) "ref")
|
||||
(let [ref-name (when-let [raw (nth parts 2 nil)]
|
||||
|
||||
41
deps/publish/src/logseq/publish/render.cljs
vendored
41
deps/publish/src/logseq/publish/render.cljs
vendored
@@ -665,7 +665,9 @@
|
||||
page-uuid (page-ref->uuid s name->uuid)]
|
||||
(if page-uuid
|
||||
[[:a.page-ref {:href (str "/page/" graph-uuid "/" page-uuid)} (str "#" s)]]
|
||||
[(str "#" s)]))
|
||||
(if (and graph-uuid (not (string/blank? s)))
|
||||
[[:a.page-ref {:href (str "/tag/" (js/encodeURIComponent s))} (str "#" s)]]
|
||||
[(str "#" s)])))
|
||||
|
||||
(= "Macro" type)
|
||||
(if-let [macro-data (normalize-macro-data data)]
|
||||
@@ -1061,11 +1063,7 @@
|
||||
[:a.page-ref {:href href} (or source-page-title source-page-uuid)]
|
||||
[:span (or source-page-title source-page-uuid)])
|
||||
(when (and source-block-content (not page?))
|
||||
[:div.tagged-block source-block-content])
|
||||
[:div.tagged-sub
|
||||
(if page?
|
||||
(str "Page: " source-page-uuid)
|
||||
(str "Block: " source-block-uuid))]]
|
||||
[:div.tagged-block source-block-content])]
|
||||
[:span.tagged-meta (or (format-timestamp updated-at) "—")]]))
|
||||
|
||||
(defn- author-usernames
|
||||
@@ -1329,7 +1327,7 @@
|
||||
(let [rows tag-items
|
||||
title (or tag-title tag-uuid)
|
||||
doc [:html
|
||||
(render-head (str "Tag - " title))
|
||||
(render-head (str "#" title))
|
||||
[:body
|
||||
[:main.wrap
|
||||
(toolbar-node
|
||||
@@ -1337,9 +1335,7 @@
|
||||
[:a.toolbar-btn {:href (str "/graph/" graph-uuid)} "Home"])
|
||||
(search-node graph-uuid)
|
||||
(theme-toggle-node))
|
||||
[:h1 title]
|
||||
[:p.tag-sub (str "Tag: " tag-uuid)]
|
||||
[:p.graph-meta (str "Graph: " graph-uuid)]
|
||||
[:h1 (str "#" title)]
|
||||
(if (seq rows)
|
||||
[:ul.page-list
|
||||
(for [item rows]
|
||||
@@ -1357,24 +1353,13 @@
|
||||
[:body
|
||||
[:main.wrap
|
||||
(toolbar-node
|
||||
(search-node nil)
|
||||
[:a.toolbar-btn {:href "/"} "Home"]
|
||||
(theme-toggle-node))
|
||||
[:h1 title]
|
||||
[:p.tag-sub (str "Tag: " tag-name)]
|
||||
[:h1 (str "#" title)]
|
||||
(if (seq rows)
|
||||
[:ul.page-list
|
||||
(for [row rows
|
||||
:let [graph-id (tag-item-val row :graph_uuid)
|
||||
page-uuid (tag-item-val row :source_page_uuid)
|
||||
page-title (tag-item-val row :source_page_title)
|
||||
href (when (and graph-id page-uuid)
|
||||
(str "/page/" graph-id "/" page-uuid))]]
|
||||
[:li.page-item
|
||||
[:div.page-links
|
||||
(if href
|
||||
[:a.page-ref {:href href} (or page-title page-uuid)]
|
||||
[:span (or page-title page-uuid)])]
|
||||
[:span.page-meta (or (format-timestamp (tag-item-val row :updated_at)) "—")]])]
|
||||
(for [row rows]
|
||||
(render-tagged-item (tag-item-val row :graph_uuid) row))]
|
||||
[:p "No published pages use this tag yet."])
|
||||
(publish-script)]]]]
|
||||
(str "<!doctype html>" (render-hiccup doc))))
|
||||
@@ -1388,9 +1373,7 @@
|
||||
[:body
|
||||
[:main.wrap
|
||||
(toolbar-node
|
||||
(when graph-uuid
|
||||
[:a.toolbar-btn {:href (str "/graph/" graph-uuid)} "Home"])
|
||||
(search-node graph-uuid)
|
||||
[:a.toolbar-btn {:href "/"} "Home"]
|
||||
(theme-toggle-node))
|
||||
[:h1 title]
|
||||
[:p.tag-sub (str "Reference: " ref-name)]
|
||||
@@ -1467,7 +1450,7 @@
|
||||
[:body
|
||||
[:main.wrap
|
||||
(toolbar-node
|
||||
(search-node nil)
|
||||
[:a.toolbar-btn {:href "/"} "Home"]
|
||||
(theme-toggle-node))
|
||||
[:div.not-found
|
||||
[:p.not-found-eyebrow "404"]
|
||||
|
||||
14
deps/publish/src/logseq/publish/routes.cljs
vendored
14
deps/publish/src/logseq/publish/routes.cljs
vendored
@@ -383,7 +383,7 @@
|
||||
#js {"content-type" "text/html; charset=utf-8"}
|
||||
(publish-common/cors-headers))})
|
||||
(js-await [data (.json resp)
|
||||
rows (or (aget data "pages") #js [])
|
||||
rows (or (aget data "tagged_nodes") #js [])
|
||||
title (or tag-name "Tag")]
|
||||
(js/Response.
|
||||
(publish-render/render-tag-name-html tag-name title rows)
|
||||
@@ -514,12 +514,12 @@
|
||||
(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))}))
|
||||
(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 [{:keys [allowed? provided?]} (check-page-password request graph-uuid page-uuid env)]
|
||||
(if-not allowed?
|
||||
(js/Response.
|
||||
|
||||
Reference in New Issue
Block a user