From 1f7dadf19ecc3f7f8072eb7bb692584b8fbf529c Mon Sep 17 00:00:00 2001 From: tdro Date: Fri, 8 Mar 2024 14:01:03 -0500 Subject: themes/default/layouts/partials: Merge menu --- assets/css/default.css | 33 +++++++------- assets/js/index.js | 6 +-- static/js/contextmenu.ts | 6 +-- .../default/layouts/partials/card-meta-header.html | 10 ++--- themes/default/layouts/partials/menu-datetime.html | 22 ++++++++++ themes/default/layouts/partials/menu-embed.html | 8 ++++ themes/default/layouts/partials/menu-markdown.html | 13 ++++++ .../default/layouts/partials/menu-permalink.html | 11 +++++ themes/default/layouts/partials/menu-plain.html | 9 ++++ .../layouts/partials/meta-context-menu.html | 50 ---------------------- .../default/layouts/partials/meta-date-time.html | 14 ------ themes/default/layouts/partials/meta-datetime.html | 14 ++++++ .../default/layouts/partials/meta-expiry-date.html | 20 --------- .../default/layouts/partials/meta-expirydate.html | 20 +++++++++ themes/default/layouts/partials/meta-markdown.html | 13 ------ themes/default/layouts/partials/meta-menu.html | 23 ++++++++++ .../default/layouts/partials/meta-permalink.html | 11 ----- .../default/layouts/partials/meta-read-time.html | 12 ------ themes/default/layouts/partials/meta-readtime.html | 12 ++++++ .../default/layouts/partials/meta-word-count.html | 33 -------------- .../default/layouts/partials/meta-wordcount.html | 33 ++++++++++++++ 21 files changed, 194 insertions(+), 179 deletions(-) create mode 100644 themes/default/layouts/partials/menu-datetime.html create mode 100644 themes/default/layouts/partials/menu-embed.html create mode 100644 themes/default/layouts/partials/menu-markdown.html create mode 100644 themes/default/layouts/partials/menu-permalink.html create mode 100644 themes/default/layouts/partials/menu-plain.html delete mode 100644 themes/default/layouts/partials/meta-context-menu.html delete mode 100644 themes/default/layouts/partials/meta-date-time.html create mode 100644 themes/default/layouts/partials/meta-datetime.html delete mode 100644 themes/default/layouts/partials/meta-expiry-date.html create mode 100644 themes/default/layouts/partials/meta-expirydate.html delete mode 100644 themes/default/layouts/partials/meta-markdown.html create mode 100644 themes/default/layouts/partials/meta-menu.html delete mode 100644 themes/default/layouts/partials/meta-permalink.html delete mode 100644 themes/default/layouts/partials/meta-read-time.html create mode 100644 themes/default/layouts/partials/meta-readtime.html delete mode 100644 themes/default/layouts/partials/meta-word-count.html create mode 100644 themes/default/layouts/partials/meta-wordcount.html diff --git a/assets/css/default.css b/assets/css/default.css index af163a8..cf106eb 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -157,9 +157,9 @@ li:target [role="doc-backlink"][href^="#fnref\:"] { nav a:focus, button:focus, +menu a:focus, code-block a:focus, -gallery-images a:focus, -context-control a:focus { +gallery-images a:focus { outline-offset: -0.2rem !important; } @@ -608,7 +608,7 @@ pre code { summary, abbr[title] label, -micro-metadata-menu context-control label { +menu label { cursor: pointer; } @@ -625,7 +625,7 @@ a:hover { } a:hover, -micro-metadata-menu:hover span, +menu:hover span, micro-metadata-view a:hover span, micro-metadata-draft a:hover span, micro-metadata-handle a:hover span { @@ -1263,25 +1263,28 @@ micro-metadata-anchored a[data-anchored="marked"] svg { fill: #cd5c5c; } -micro-metadata-menu { +menu { display: inline-block; + list-style-type: none; + margin: 0; + padding: 0; position: relative; } -micro-metadata-menu context-menu { +menu context-menu { min-width: 10rem; } -micro-metadata-menu context-menu svg { +menu context-menu svg { margin-right: 0.25rem; } -micro-metadata-menu context-menu a { +menu context-menu a { display: block; padding: 0.5rem 1rem; } -micro-metadata-menu context-menu a:hover { +menu context-menu a:hover { background-color: #eee; background-color: var(--hover-background); border-radius: 0.25rem; @@ -1306,7 +1309,7 @@ micro-metadata context-menu a span { text-decoration: none; } -micro-metadata-menu span, +menu span, micro-metadata-view a span, micro-metadata-name a:hover, micro-metadata-draft a span, @@ -2146,21 +2149,21 @@ context-menu { opacity: 0; } -context-menu[right] { +context-menu[position="right"] { right: 0; } -context-menu[left] { +context-menu[position="left"] { left: 0; } -context-menu[anchor] { +context-menu[position="anchor"] { left: -125%; top: 0; } -context-menu[left], -context-menu[right] { +context-menu[position="left"], +context-menu[position="right"] { top: 1rem; } diff --git a/assets/js/index.js b/assets/js/index.js index cc23d2c..61fbe68 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -378,7 +378,7 @@ } }; self.addEventListener("scroll", function() { - const triggers = document.querySelectorAll("micro-metadata-menu input"); + const triggers = document.querySelectorAll("menu input"); hide(triggers); }); [ @@ -386,8 +386,8 @@ "touchstart" ].forEach(function(event) { self.addEventListener(event, function(event) { - const menus = document.querySelectorAll("micro-metadata-menu"); - const triggers = document.querySelectorAll("micro-metadata-menu input"); + const menus = document.querySelectorAll("menu"); + const triggers = document.querySelectorAll("menu input"); hideIfClickedOutside(menus, triggers, event); }); }); diff --git a/static/js/contextmenu.ts b/static/js/contextmenu.ts index b19cf9e..5add288 100644 --- a/static/js/contextmenu.ts +++ b/static/js/contextmenu.ts @@ -14,14 +14,14 @@ }; self.addEventListener("scroll", function () { - const triggers = document.querySelectorAll("micro-metadata-menu input"); + const triggers = document.querySelectorAll("menu input"); hide(triggers); }); ["click", "touchstart"].forEach(function (event) { self.addEventListener(event, function (event) { - const menus = document.querySelectorAll("micro-metadata-menu"); - const triggers = document.querySelectorAll("micro-metadata-menu input"); + const menus = document.querySelectorAll("menu"); + const triggers = document.querySelectorAll("menu input"); hideIfClickedOutside(menus, triggers, event); }); }); diff --git a/themes/default/layouts/partials/card-meta-header.html b/themes/default/layouts/partials/card-meta-header.html index 3fcd670..5672972 100644 --- a/themes/default/layouts/partials/card-meta-header.html +++ b/themes/default/layouts/partials/card-meta-header.html @@ -10,16 +10,16 @@ {{- partial "meta-handle.html" . -}} - {{- partial "meta-date-time.html" . -}} + {{- partial "meta-datetime.html" . -}} {{- partial "meta-view.html" . -}} - {{- partial "meta-context-menu.html" . -}} + {{- partial "meta-menu.html" . -}} - {{- partial "meta-word-count.html" . -}} + {{- partial "meta-wordcount.html" . -}} - {{- partial "meta-read-time.html" . -}} + {{- partial "meta-readtime.html" . -}} - {{- partial "meta-expiry-date.html" . -}} + {{- partial "meta-expirydate.html" . -}} diff --git a/themes/default/layouts/partials/menu-datetime.html b/themes/default/layouts/partials/menu-datetime.html new file mode 100644 index 0000000..5b2acf1 --- /dev/null +++ b/themes/default/layouts/partials/menu-datetime.html @@ -0,0 +1,22 @@ +{{- $href := print .Permalink -}} + + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/calendar.svg")) -}} + + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/clock.svg")) -}} + + + diff --git a/themes/default/layouts/partials/menu-embed.html b/themes/default/layouts/partials/menu-embed.html new file mode 100644 index 0000000..7890102 --- /dev/null +++ b/themes/default/layouts/partials/menu-embed.html @@ -0,0 +1,8 @@ +{{- $href := print .Permalink -}} + + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/code.svg")) -}} + Embed + + diff --git a/themes/default/layouts/partials/menu-markdown.html b/themes/default/layouts/partials/menu-markdown.html new file mode 100644 index 0000000..7098fa5 --- /dev/null +++ b/themes/default/layouts/partials/menu-markdown.html @@ -0,0 +1,13 @@ +{{- if not .ExpiryDate -}} + {{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} + {{- $source := print (path.Dir $relURL) ".md" -}} + {{- $href := print .Site.BaseURL "/" (partial "function-paths.html").markdown $source -}} + {{- $title := .File.LogicalName -}} + + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/square-letter-m.svg")) -}} + Markdown + + +{{- end -}} diff --git a/themes/default/layouts/partials/menu-permalink.html b/themes/default/layouts/partials/menu-permalink.html new file mode 100644 index 0000000..2af4e8a --- /dev/null +++ b/themes/default/layouts/partials/menu-permalink.html @@ -0,0 +1,11 @@ +{{- $href := print .Permalink "#" (partial "card-id.html" .) -}} + + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/link.svg")) -}} + Permalink +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/menu-plain.html b/themes/default/layouts/partials/menu-plain.html new file mode 100644 index 0000000..3886945 --- /dev/null +++ b/themes/default/layouts/partials/menu-plain.html @@ -0,0 +1,9 @@ +{{- $href := print .Permalink -}} +{{- $plain := print $href "index.txt" -}} + + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/notes.svg")) -}} + Plaintext + + diff --git a/themes/default/layouts/partials/meta-context-menu.html b/themes/default/layouts/partials/meta-context-menu.html deleted file mode 100644 index 89f88d2..0000000 --- a/themes/default/layouts/partials/meta-context-menu.html +++ /dev/null @@ -1,50 +0,0 @@ -{{- $id := partial "card-id.html" . -}} -{{- $href := print .Permalink -}} -{{- $plain := print $href "index.txt" -}} - - - - - - - {{- partial "meta-markdown.html" . -}} - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/notes.svg")) -}} - Plaintext - - - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/code.svg")) -}} - Embed - - - {{- partial "meta-permalink.html" . -}} - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/calendar.svg")) -}} - - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/clock.svg")) -}} - - - - - - -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-date-time.html b/themes/default/layouts/partials/meta-date-time.html deleted file mode 100644 index 1dc50f3..0000000 --- a/themes/default/layouts/partials/meta-date-time.html +++ /dev/null @@ -1,14 +0,0 @@ - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/calendar.svg")) -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} - {{ if .Lastmod.After .Date }} - (edited) - {{- end -}} -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-datetime.html b/themes/default/layouts/partials/meta-datetime.html new file mode 100644 index 0000000..1dc50f3 --- /dev/null +++ b/themes/default/layouts/partials/meta-datetime.html @@ -0,0 +1,14 @@ + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/calendar.svg")) -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} + {{ if .Lastmod.After .Date }} + (edited) + {{- end -}} +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-expiry-date.html b/themes/default/layouts/partials/meta-expiry-date.html deleted file mode 100644 index 6eef09e..0000000 --- a/themes/default/layouts/partials/meta-expiry-date.html +++ /dev/null @@ -1,20 +0,0 @@ -{{- if .ExpiryDate -}} - {{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} - {{- $diff := now.Sub .ExpiryDate -}} - {{- $duration := lang.FormatNumberCustom 0 (math.Round (mul (div $diff.Hours 24) -1)) -}} - {{- $date := .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" -}} - {{- $title := print "Self destructs within" " " $duration " " "days" " " "(" $date ")" -}} - {{- if $expired -}} - {{- $title = print "Self destructed" " " $date -}} - {{- end -}} - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/trash-2.svg")) -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- end -}} diff --git a/themes/default/layouts/partials/meta-expirydate.html b/themes/default/layouts/partials/meta-expirydate.html new file mode 100644 index 0000000..6eef09e --- /dev/null +++ b/themes/default/layouts/partials/meta-expirydate.html @@ -0,0 +1,20 @@ +{{- if .ExpiryDate -}} + {{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} + {{- $diff := now.Sub .ExpiryDate -}} + {{- $duration := lang.FormatNumberCustom 0 (math.Round (mul (div $diff.Hours 24) -1)) -}} + {{- $date := .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" -}} + {{- $title := print "Self destructs within" " " $duration " " "days" " " "(" $date ")" -}} + {{- if $expired -}} + {{- $title = print "Self destructed" " " $date -}} + {{- end -}} + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/trash-2.svg")) -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- end -}} diff --git a/themes/default/layouts/partials/meta-markdown.html b/themes/default/layouts/partials/meta-markdown.html deleted file mode 100644 index 7098fa5..0000000 --- a/themes/default/layouts/partials/meta-markdown.html +++ /dev/null @@ -1,13 +0,0 @@ -{{- if not .ExpiryDate -}} - {{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} - {{- $source := print (path.Dir $relURL) ".md" -}} - {{- $href := print .Site.BaseURL "/" (partial "function-paths.html").markdown $source -}} - {{- $title := .File.LogicalName -}} - - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/square-letter-m.svg")) -}} - Markdown - - -{{- end -}} diff --git a/themes/default/layouts/partials/meta-menu.html b/themes/default/layouts/partials/meta-menu.html new file mode 100644 index 0000000..f5e127d --- /dev/null +++ b/themes/default/layouts/partials/meta-menu.html @@ -0,0 +1,23 @@ +{{- $id := partial "card-id.html" . -}} + + +
  • + +
  • +
  • + + + + {{- partial "menu-markdown.html" . -}} + {{- partial "menu-plain.html" . -}} + {{- partial "menu-embed.html" . -}} + {{- partial "menu-permalink.html" . -}} + {{- partial "menu-datetime.html" . -}} + + +
  • +
    +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-permalink.html b/themes/default/layouts/partials/meta-permalink.html deleted file mode 100644 index 2af4e8a..0000000 --- a/themes/default/layouts/partials/meta-permalink.html +++ /dev/null @@ -1,11 +0,0 @@ -{{- $href := print .Permalink "#" (partial "card-id.html" .) -}} - - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/link.svg")) -}} - Permalink -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-read-time.html b/themes/default/layouts/partials/meta-read-time.html deleted file mode 100644 index 1af03e7..0000000 --- a/themes/default/layouts/partials/meta-read-time.html +++ /dev/null @@ -1,12 +0,0 @@ -{{- $seconds := mul (div .WordCount 180.0) 60.0 -}} -{{- $seconds = printf "%.0f" $seconds -}} -{{- if eq $seconds "0" -}} - {{- $seconds = "1" -}} -{{- end -}} - - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/eye.svg")) }} - {{ $seconds }}s read -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-readtime.html b/themes/default/layouts/partials/meta-readtime.html new file mode 100644 index 0000000..1af03e7 --- /dev/null +++ b/themes/default/layouts/partials/meta-readtime.html @@ -0,0 +1,12 @@ +{{- $seconds := mul (div .WordCount 180.0) 60.0 -}} +{{- $seconds = printf "%.0f" $seconds -}} +{{- if eq $seconds "0" -}} + {{- $seconds = "1" -}} +{{- end -}} + + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/eye.svg")) }} + {{ $seconds }}s read +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-word-count.html b/themes/default/layouts/partials/meta-word-count.html deleted file mode 100644 index 5fd5451..0000000 --- a/themes/default/layouts/partials/meta-word-count.html +++ /dev/null @@ -1,33 +0,0 @@ -{{- $author := partial "function-authors-data.html" . -}} -{{- $limit := $author.wordlimit -}} -{{- $wordLimit := gt .WordCount $limit -}} -{{- $overLimit := sub .WordCount $limit -}} -{{- $bitCount := lang.FormatNumberCustom 0 (len .Content) -}} - - -{{- /* This comment removes trailing newlines and white spaces. */ -}} - - {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/notes.svg")) -}} - - {{- if $wordLimit -}} - {{ .WordCount }} - {{- else -}} - {{ .WordCount }} - {{- end -}} - /{{ $limit }} words -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} - -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-wordcount.html b/themes/default/layouts/partials/meta-wordcount.html new file mode 100644 index 0000000..5fd5451 --- /dev/null +++ b/themes/default/layouts/partials/meta-wordcount.html @@ -0,0 +1,33 @@ +{{- $author := partial "function-authors-data.html" . -}} +{{- $limit := $author.wordlimit -}} +{{- $wordLimit := gt .WordCount $limit -}} +{{- $overLimit := sub .WordCount $limit -}} +{{- $bitCount := lang.FormatNumberCustom 0 (len .Content) -}} + + +{{- /* This comment removes trailing newlines and white spaces. */ -}} + + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/notes.svg")) -}} + + {{- if $wordLimit -}} + {{ .WordCount }} + {{- else -}} + {{ .WordCount }} + {{- end -}} + /{{ $limit }} words +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} + +{{- /* This comment removes trailing newlines and white spaces. */ -}} -- cgit v1.2.3