From d9a29082d810f2954c29aea215ba5cbbaa361ac6 Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 6 Aug 2022 02:09:42 -0400 Subject: themes/default/layouts/partials: Hack in card context menu --- Makefile | 67 ++++++------- assets/css/default.css | 105 ++++++++++++++++----- assets/js/index.js | 28 ++++++ content/canory/messages/markdown.md | 2 +- static/icons/feather/arrow-down-circle.svg | 15 +++ static/icons/feather/external-link.svg | 15 +++ static/js/contextmenu.ts | 28 ++++++ static/js/index.ts | 1 + themes/default/layouts/_default/baseof.html | 2 +- themes/default/layouts/_default/summary.html | 10 +- .../default/layouts/partials/card-meta-header.html | 29 ++++++ themes/default/layouts/partials/card-meta.html | 45 --------- themes/default/layouts/partials/context-menu.html | 4 - themes/default/layouts/partials/meta-anchored.html | 19 ++++ .../layouts/partials/meta-context-menu.html | 21 +++++ .../default/layouts/partials/meta-date-time.html | 27 ++---- themes/default/layouts/partials/meta-draft.html | 8 +- .../default/layouts/partials/meta-expiry-date.html | 7 +- themes/default/layouts/partials/meta-handle.html | 31 +++--- themes/default/layouts/partials/meta-link.html | 13 --- themes/default/layouts/partials/meta-markdown.html | 18 ++++ themes/default/layouts/partials/meta-name.html | 23 ++--- .../default/layouts/partials/meta-permalink.html | 9 ++ .../default/layouts/partials/meta-read-time.html | 4 +- themes/default/layouts/partials/meta-source.html | 22 ----- themes/default/layouts/partials/meta-view.html | 18 ++++ .../default/layouts/partials/meta-word-count.html | 18 ++-- 27 files changed, 388 insertions(+), 201 deletions(-) create mode 100644 static/icons/feather/arrow-down-circle.svg create mode 100644 static/icons/feather/external-link.svg create mode 100644 static/js/contextmenu.ts create mode 100644 themes/default/layouts/partials/card-meta-header.html delete mode 100644 themes/default/layouts/partials/card-meta.html delete mode 100644 themes/default/layouts/partials/context-menu.html create mode 100644 themes/default/layouts/partials/meta-anchored.html create mode 100644 themes/default/layouts/partials/meta-context-menu.html delete mode 100644 themes/default/layouts/partials/meta-link.html create mode 100644 themes/default/layouts/partials/meta-markdown.html create mode 100644 themes/default/layouts/partials/meta-permalink.html delete mode 100644 themes/default/layouts/partials/meta-source.html create mode 100644 themes/default/layouts/partials/meta-view.html diff --git a/Makefile b/Makefile index f398fbe..25c1496 100644 --- a/Makefile +++ b/Makefile @@ -29,35 +29,38 @@ test: icons: rm -rf static/icons mkdir -p static/icons/feather static/icons/tabler - svn export --force https://github.com/feathericons/feather/trunk/LICENSE static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/alert-circle.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/archive.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-left.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-right.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-up.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/at-sign.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/calendar.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/circle.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/clock.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/code.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/copy.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/edit.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/eye-off.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/file-text.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/git-commit.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/globe.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/heart.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/home.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/link.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/map-pin.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/rss.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/search.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/tag.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/trash-2.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/user.svg static/icons/feather - svn export --force https://github.com/feathericons/feather/trunk/icons/users.svg static/icons/feather - svn export --force https://github.com/tabler/tabler-icons/trunk/LICENSE static/icons/tabler - svn export --force https://github.com/tabler/tabler-icons/trunk/icons/book-2.svg static/icons/tabler - svn export --force https://github.com/tabler/tabler-icons/trunk/icons/clock.svg static/icons/tabler - svn export --force https://github.com/tabler/tabler-icons/trunk/icons/pinned.svg static/icons/tabler - svn export --force https://github.com/tabler/tabler-icons/trunk/icons/robot.svg static/icons/tabler + svn export --force https://github.com/feathericons/feather/trunk/LICENSE static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/alert-circle.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/archive.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-down-circle.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-left.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-right.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/arrow-up.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/at-sign.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/calendar.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/circle.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/clock.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/code.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/copy.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/edit.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/external-link.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/eye-off.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/file-text.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/git-commit.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/globe.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/heart.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/home.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/link.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/map-pin.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/rss.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/search.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/tag.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/trash-2.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/user.svg static/icons/feather + svn export --force https://github.com/feathericons/feather/trunk/icons/users.svg static/icons/feather + svn export --force https://github.com/tabler/tabler-icons/trunk/LICENSE static/icons/tabler + svn export --force https://github.com/tabler/tabler-icons/trunk/icons/book-2.svg static/icons/tabler + svn export --force https://github.com/tabler/tabler-icons/trunk/icons/clock.svg static/icons/tabler + svn export --force https://github.com/tabler/tabler-icons/trunk/icons/pinned.svg static/icons/tabler + svn export --force https://github.com/tabler/tabler-icons/trunk/icons/robot.svg static/icons/tabler + git add -f static/icons diff --git a/assets/css/default.css b/assets/css/default.css index 761c64d..af1c360 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -290,7 +290,8 @@ object { border-radius: 0.5rem; } -details { +details, +micro-metadata-menu context-control label { cursor: pointer; } @@ -308,6 +309,13 @@ a { a:hover { color: #111; color: var(--foreground); +} + +a:hover, +micro-metadata-menu:hover span, +micro-metadata-view a:hover span, +micro-metadata-draft a:hover span, +micro-metadata-handle a:hover span { text-decoration-thickness: 0.15rem !important; } @@ -365,7 +373,7 @@ abbr[title]:hover { border-bottom: 2px dashed; } -[type="checkbox"]:checked ~ abbr[title]::after { +input[type="checkbox"]:checked ~ abbr[title]::after { content: " (" attr(title) ")"; } @@ -706,7 +714,7 @@ micro-metadata { color: #444; color: var(--fade); display: flex; - line-height: 1.25; + line-height: 1.4; margin-bottom: 0.5rem; } @@ -714,19 +722,24 @@ micro-metadata h2 { display: inline; } -micro-metadata section { +micro-metadata header { word-break: break-all; word-break: break-word; } -micro-metadata section a { +micro-metadata header a { color: inherit; } -micro-metadata section > *:not(:last-child) { +micro-metadata header > *:not(:last-child) { margin-right: 0.5rem; } +micro-metadata header > *:hover { + color: #111; + color: var(--foreground); +} + micro-metadata-expiry, micro-metadata-draft em, micro-metadata word-limit em { @@ -740,7 +753,7 @@ micro-metadata-draft em { } micro-header footer svg, -micro-metadata section svg { +micro-metadata header svg { height: 1rem; width: 1rem; stroke-width: 0.1rem; @@ -753,9 +766,10 @@ micro-metadata unlisted-entry { s label, abbr[title], abbr[title] label, -micro-metadata read-time, +micro-metadata-expiry, +micro-metadata-readtime, +micro-metadata-datetime, micro-metadata word-limit, -micro-metadata expiry-date, micro-metadata unlisted-entry { cursor: help; } @@ -765,7 +779,6 @@ micro-metadata-anchored { color: var(--foreground); display: flex; margin-bottom: 0.25rem; - margin-top: -0.5rem; width: 100%; } @@ -780,6 +793,43 @@ micro-metadata-anchored svg { margin-right: 0.25rem; } +micro-metadata-menu { + display: inline-block; +} + +micro-metadata-menu context-menu svg { + margin-right: 0.25rem; +} + +micro-metadata-menu context-menu a { + display: block; + padding: 0.5rem 1rem; +} + +micro-metadata-menu context-menu a:hover { + background-color: #eee; + background-color: var(--hover-background); + border-radius: 0.25rem; +} + +micro-metadata a:focus > span, +micro-metadata-view a, +micro-metadata-name a, +micro-metadata-draft a, +micro-metadata-handle a, +micro-metadata context-menu a, +micro-metadata context-menu a span { + text-decoration: none; +} + +micro-metadata-name a:hover, +micro-metadata-menu span, +micro-metadata-view a span, +micro-metadata-draft a span, +micro-metadata-handle a span { + text-decoration: underline; +} + anchored-via { color: #444; color: var(--fade); @@ -1387,22 +1437,24 @@ context-menu { border-color: var(--border-lighter); border-radius: 0.5rem; box-shadow: 0 0 1rem -0.5rem var(--shadow); - padding-bottom: 0.5rem; - padding-top: 0.5rem; min-width: 6.25rem; position: absolute; z-index: 99; - max-width: 20rem; visibility: hidden; opacity: 0; } -context-profile context-menu { - color: #111; - color: var(--foreground); - display: block; - padding: 1rem; - text-align: left; +context-menu[right] { + right: 0; +} + +context-menu[left] { + left: 0; +} + +context-menu[left], +context-menu[right] { + top: 1rem; } context-profile a { @@ -1424,6 +1476,16 @@ context-profile aside:nth-child(2) { line-height: 1.25; } +context-profile context-menu { + color: #111; + color: var(--foreground); + display: block; + padding: 1rem; + text-align: left; + max-width: 20rem; +} + +input:checked + context-menu, micro-card figure:hover context-menu { margin-right: 1rem; opacity: 1; @@ -1537,7 +1599,7 @@ s { color: transparent; } -[type="checkbox"]:checked ~ s { +input[type="checkbox"]:checked ~ s { background-color: inherit; color: inherit; } @@ -1587,7 +1649,8 @@ kbd { outline: none; } -[hidden] { +[hidden], +[data-page] micro-metadata-view { display: none; } diff --git a/assets/js/index.js b/assets/js/index.js index 71ff972..9d92d09 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -283,6 +283,34 @@ } }); })(); +(function() { + const hide = (triggers)=>{ + for(let i = 0; i < triggers.length; i++){ + triggers[i].checked = false; + } + }; + const hideIfClickedOutside = (menus, triggers, event)=>{ + for(let i = 0; i < menus.length; i++){ + const active = triggers[i].checked === true; + const outside = !menus[i].contains(event.target); + if (outside && active) hide(triggers); + } + }; + self.addEventListener("scroll", function() { + const triggers = document.querySelectorAll("micro-metadata-menu input"); + hide(triggers); + }); + [ + "click", + "touchstart" + ].forEach(function(event1) { + self.addEventListener(event1, function(event) { + const menus = document.querySelectorAll("micro-metadata-menu"); + const triggers = document.querySelectorAll("micro-metadata-menu input"); + hideIfClickedOutside(menus, triggers, event); + }); + }); +})(); (function() { self.addEventListener("DOMContentLoaded", function() { const form = document.getElementById("search-form"); diff --git a/content/canory/messages/markdown.md b/content/canory/messages/markdown.md index 032f5e5..0a66a90 100644 --- a/content/canory/messages/markdown.md +++ b/content/canory/messages/markdown.md @@ -7,7 +7,7 @@ author = "canory" [//]: # "That's a comment alright, hiding in plain sight." -The `metadata` :arrow_up: has a link to the raw +The `metadata` :arrow_up: has a menu link to the raw [Markdown](https://www.markdownguide.org/cheat-sheet/) file {{< markdown >}} that generates this message --- might as well show my internals. Casual users will frown, power users will delight. diff --git a/static/icons/feather/arrow-down-circle.svg b/static/icons/feather/arrow-down-circle.svg new file mode 100644 index 0000000..eb9f1a0 --- /dev/null +++ b/static/icons/feather/arrow-down-circle.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/static/icons/feather/external-link.svg b/static/icons/feather/external-link.svg new file mode 100644 index 0000000..537b731 --- /dev/null +++ b/static/icons/feather/external-link.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/static/js/contextmenu.ts b/static/js/contextmenu.ts new file mode 100644 index 0000000..dea9bec --- /dev/null +++ b/static/js/contextmenu.ts @@ -0,0 +1,28 @@ +(function () { + const hide = (triggers) => { + for (let i = 0; i < triggers.length; i++) { + triggers[i].checked = false; + } + }; + + const hideIfClickedOutside = (menus, triggers, event) => { + for (let i = 0; i < menus.length; i++) { + const active = triggers[i].checked === true; + const outside = !menus[i].contains(event.target); + if (outside && active) hide(triggers); + } + }; + + self.addEventListener("scroll", function () { + const triggers = document.querySelectorAll("micro-metadata-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"); + hideIfClickedOutside(menus, triggers, event); + }); + }); +})(); diff --git a/static/js/index.ts b/static/js/index.ts index 52cc678..e00907b 100644 --- a/static/js/index.ts +++ b/static/js/index.ts @@ -1,6 +1,7 @@ import "./pager.ts"; import "./plumber.ts"; import "./instantpage.ts"; +import "./contextmenu.ts"; import "./fixedsearch.ts"; import "./timeago.ts"; diff --git a/themes/default/layouts/_default/baseof.html b/themes/default/layouts/_default/baseof.html index b85497e..bd5fd21 100644 --- a/themes/default/layouts/_default/baseof.html +++ b/themes/default/layouts/_default/baseof.html @@ -1,5 +1,5 @@ - + {{- block "title" . -}}{{- end -}} diff --git a/themes/default/layouts/_default/summary.html b/themes/default/layouts/_default/summary.html index 86fb8d5..4e9d93d 100644 --- a/themes/default/layouts/_default/summary.html +++ b/themes/default/layouts/_default/summary.html @@ -6,12 +6,12 @@ </micro-thumbnail> <micro-content> <micro-metadata> - {{ partial "card-meta.html" . }} + {{ partial "card-meta-header.html" . }} </micro-metadata> - {{ if .Params.unsafe }}{{ partial "card-unsafe.html" "begin" }}{{ end }} - {{- partial "function-content.html" .Content | safeHTML -}} - {{ if .Params.unsafe }}{{ partial "card-unsafe.html" "end" }}{{ end }} - <micro-tags>{{ partial "meta-tags.html" . }}</micro-tags> + {{ if .Params.unsafe }}{{ partial "card-unsafe.html" "begin" }}{{ end }} + {{- partial "function-content.html" .Content | safeHTML -}} + {{ if .Params.unsafe }}{{ partial "card-unsafe.html" "end" }}{{ end }} + <micro-tags>{{ partial "meta-tags.html" . }}</micro-tags> </micro-content> </micro-summary> {{ if .ExpiryDate }}</micro-expires>{{ end }} diff --git a/themes/default/layouts/partials/card-meta-header.html b/themes/default/layouts/partials/card-meta-header.html new file mode 100644 index 0000000..66dbb94 --- /dev/null +++ b/themes/default/layouts/partials/card-meta-header.html @@ -0,0 +1,29 @@ +<micro-thumbnail hidden> + {{ partial "profile-picture.html" . }} +</micro-thumbnail> + +<header> + + {{- partial "meta-anchored.html" . -}} + + {{- partial "meta-name.html" . -}} + + {{- partial "meta-draft.html" . -}} + + {{- partial "meta-unlisted.html" . -}} + + {{- partial "meta-handle.html" . -}} + + {{- partial "meta-date-time.html" . -}} + + {{- partial "meta-view.html" . -}} + + {{- partial "meta-context-menu.html" . -}} + + {{- partial "meta-read-time.html" . -}} + + {{- partial "meta-word-count.html" . -}} + + {{- partial "meta-expiry-date.html" . -}} + +</header> diff --git a/themes/default/layouts/partials/card-meta.html b/themes/default/layouts/partials/card-meta.html deleted file mode 100644 index f7da69a..0000000 --- a/themes/default/layouts/partials/card-meta.html +++ /dev/null @@ -1,45 +0,0 @@ -<micro-thumbnail hidden> - {{ partial "profile-picture.html" . }} -</micro-thumbnail> - -<section> - {{ if or .Weight .Params.Liked .Params.feed }} - <micro-metadata-anchored> - {{- partial "meta-via.html" . -}} - - {{ if .Weight }} - <anchored-pinned> - {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/tabler/pinned.svg")) }} - <span>Pinned</span> - </anchored-pinned> - {{ end }} - - {{ if .Params.Liked }} - <anchored-liked> - {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/heart.svg")) }} - <span>Liked</span> - </anchored-liked> - {{ end }} - </micro-metadata-anchored> - {{ end }} - - {{- partial "meta-name.html" . -}} - - {{- partial "meta-handle.html" . -}} - - {{- partial "meta-date-time.html" . -}} - - {{- partial "meta-read-time.html" . -}} - - {{- partial "meta-word-count.html" . -}} - - {{- partial "meta-unlisted.html" . -}} - - {{- partial "meta-expiry-date.html" . -}} - - {{- partial "meta-link.html" . -}} - - {{- partial "meta-source.html" . -}} - - {{- partial "meta-draft.html" . -}} -</section> diff --git a/themes/default/layouts/partials/context-menu.html b/themes/default/layouts/partials/context-menu.html deleted file mode 100644 index 40e0001..0000000 --- a/themes/default/layouts/partials/context-menu.html +++ /dev/null @@ -1,4 +0,0 @@ -<input type="checkbox" id="context-menu-{{ .Name }}" /> -<label for="context-menu-{{ .Name }}">{{ .Label }}</label> - -<context-menu>{{ .Content }}</context-menu> diff --git a/themes/default/layouts/partials/meta-anchored.html b/themes/default/layouts/partials/meta-anchored.html new file mode 100644 index 0000000..61175b0 --- /dev/null +++ b/themes/default/layouts/partials/meta-anchored.html @@ -0,0 +1,19 @@ +{{ if or .Weight .Params.Liked .Params.feed }} + <micro-metadata-anchored> + {{- partial "meta-via.html" . -}} + + {{ if .Weight }} + <anchored-pinned> + {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/tabler/pinned.svg")) }} + <span>Pinned</span> + </anchored-pinned> + {{ end }} + + {{ if .Params.Liked }} + <anchored-liked> + {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/heart.svg")) }} + <span>Liked</span> + </anchored-liked> + {{ end }} + </micro-metadata-anchored> +{{ end }} diff --git a/themes/default/layouts/partials/meta-context-menu.html b/themes/default/layouts/partials/meta-context-menu.html new file mode 100644 index 0000000..7269262 --- /dev/null +++ b/themes/default/layouts/partials/meta-context-menu.html @@ -0,0 +1,21 @@ +{{- $id := delimit (shuffle (seq 1 7)) "" -}} +<micro-metadata-menu> + <context-control> + <label for="context-metadata-{{ $id }}"> + {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/arrow-down-circle.svg")) }} + <span>menu</span> + </label> + <input hidden type="checkbox" id="context-metadata-{{ $id }}" /> + <context-menu right> + {{- partial "meta-markdown.html" . -}} + {{- partial "meta-permalink.html" . -}} + <micro-metadata-datetime> + <a title="{{ .Date.Local | time.Format "3:04 PM Jan 2 2006" -}}"> + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/calendar.svg")) -}} + {{ .Date.Local | time.Format "Jan 2 2006" | lower -}} + </a> + </micro-metadata-datetime> + </context-menu> + </context-control> +</micro-metadata-menu> +{{- /* 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 index f1e49d0..bf855d8 100644 --- a/themes/default/layouts/partials/meta-date-time.html +++ b/themes/default/layouts/partials/meta-date-time.html @@ -1,23 +1,16 @@ -<micro-metadata-datetime> - {{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} - {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/calendar.svg")) -}} +{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} - {{- with .Params.feed.self -}} - <a href="{{ $.Site.BaseURL }}/{{ . }}"> - {{ else }} - <a href="{{ .Site.BaseURL }}/{{ $author.user }}/messages/{{ path.Base .Permalink }}/#{{ partial "card-id.html" . }}"> - {{ end }} - <time - datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" - title="{{ .Date | time.Format "Posted: Monday, January 2, 2006 at 15:04:05 MST" }} +<micro-metadata-datetime +title="{{ .Date | time.Format "Posted: Monday, January 2, 2006 at 15:04:05 MST" }} {{ if .Lastmod.After .Date }}{{ .Lastmod | time.Format "Edited: Monday, January 2, 2006 at 15:04:05 MST" }}{{ end }}"> - {{ (.Date.Local | time.Format "3:04 PM Jan 2 2006") -}} - </time> - {{ if .Lastmod.After .Date }} - <span>(edited)</span> - {{- end -}} + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/calendar.svg")) -}} + <time datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}"> + {{ (.Date.Local | time.Format "3:04 PM Jan 2 2006") -}} + </time> {{- /* This comment removes trailing newlines and white spaces. */ -}} - </a> + {{ if .Lastmod.After .Date }} + <span>(edited)</span> + {{- end -}} {{- /* This comment removes trailing newlines and white spaces. */ -}} </micro-metadata-datetime> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-draft.html b/themes/default/layouts/partials/meta-draft.html index 7513b3c..3ba6aee 100644 --- a/themes/default/layouts/partials/meta-draft.html +++ b/themes/default/layouts/partials/meta-draft.html @@ -2,8 +2,12 @@ <micro-metadata-draft> {{- /* This comment removes trailing newlines and white spaces. */ -}} <em> - {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/edit.svg")) -}} - <a href="{{ .Site.BaseURL }}/{{ .Type }}/drafts/">Draft</a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <a href="{{ .Site.BaseURL }}/{{ .Type }}/drafts/"> + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/edit.svg")) -}} + <span>Draft</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> {{- /* This comment removes trailing newlines and white spaces. */ -}} </em> {{- /* 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 index 0521e60..e2c4838 100644 --- a/themes/default/layouts/partials/meta-expiry-date.html +++ b/themes/default/layouts/partials/meta-expiry-date.html @@ -2,11 +2,10 @@ {{- $diff := now.Sub .ExpiryDate -}} {{- $duration := lang.FormatNumberCustom 0 (math.Round (mul (div $diff.Hours 24) -1)) -}} - <micro-metadata-expiry> + <micro-metadata-expiry + title="Self destructs within {{ $duration }} days ({{ .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" }})"> {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/trash-2.svg")) -}} - <time - datetime= "{{- .ExpiryDate | time.Format "2006-01-02T15:04:05Z" -}}" - title="Self destructs within {{ $duration }} days ({{ .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" }})"> + <time datetime= "{{- .ExpiryDate | time.Format "2006-01-02T15:04:05Z" -}}"> {{- .ExpiryDate | time.Format "Jan 2 2006" -}} {{- /* This comment removes trailing newlines and white spaces. */ -}} </time> diff --git a/themes/default/layouts/partials/meta-handle.html b/themes/default/layouts/partials/meta-handle.html index 2bb034d..0fbba06 100644 --- a/themes/default/layouts/partials/meta-handle.html +++ b/themes/default/layouts/partials/meta-handle.html @@ -1,24 +1,29 @@ -{{ $host := (urls.Parse .Site.BaseURL).Host -}} +{{- $host := (urls.Parse .Site.BaseURL).Host -}} +{{- $href := print .Site.BaseURL "/" (partial "author-user.html" .) "/#" -}} + {{- if (urls.Parse .Site.BaseURL).Host -}} {{- $host = (urls.Parse .Site.BaseURL).Host -}} {{- else -}} {{- $host = "localhost" -}} {{- end -}} +{{- $title := print (partial "author-user.html" .) "@" $host -}} + +{{- with .Params.feed -}} + {{- $host = $.Params.feed.domain -}} + {{- $href = print "http://" $.Params.feed.domain -}} + {{- $title = $.Params.feed.domain -}} +{{- end -}} + <micro-metadata-handle> - {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/at-sign.svg")) -}} - {{- with .Params.feed.domain -}} - <a - title="{{ . }}" - href="http://{{ . }}"> - {{ . -}} - </a> - {{- else -}} +{{- /* This comment removes trailing newlines and white spaces. */ -}} <a - title="{{ partial "author-user.html" . }}@{{ $host }}" - href="{{ .Site.BaseURL }}/{{ partial "author-user.html" . }}/#"> - {{- $host -}} + title="{{ $title }}" + href="{{ $href }}"> + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/at-sign.svg")) -}} + <span>{{- $host -}}</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} </a> - {{- end -}} +{{- /* This comment removes trailing newlines and white spaces. */ -}} </micro-metadata-handle> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-link.html b/themes/default/layouts/partials/meta-link.html deleted file mode 100644 index 442e99f..0000000 --- a/themes/default/layouts/partials/meta-link.html +++ /dev/null @@ -1,13 +0,0 @@ -<micro-metadata-link> - {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/link.svg")) -}} - - <cite> - <a title="#{{ partial "card-id.html" . }}" href="#{{ partial "card-id.html" . }}"> - id -{{- /* This comment removes trailing newlines and white spaces. */ -}} - </a> -{{- /* This comment removes trailing newlines and white spaces. */ -}} - </cite> -{{- /* This comment removes trailing newlines and white spaces. */ -}} -</micro-metadata-link> -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-markdown.html b/themes/default/layouts/partials/meta-markdown.html new file mode 100644 index 0000000..77a59c9 --- /dev/null +++ b/themes/default/layouts/partials/meta-markdown.html @@ -0,0 +1,18 @@ +{{- if not .ExpiryDate -}} + {{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} + {{- $source := print $author.user "/messages/" .File.LogicalName -}} + {{- $href := print .Site.BaseURL "/" (partial "function-paths.html" "markdown") "/" $source -}} + {{- $title := $href -}} + + {{- with .Params.feed -}} + {{- $href = print $.Site.BaseURL "/" $.Params.feed.raw -}} + {{- $title = $href -}} + {{- end -}} + + <micro-metadata-source> + <a href="{{ $href }}" title="{{ $title }}"> + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/code.svg")) -}} + <span>markdown</span> + </a> + </micro-metadata-source> +{{- end -}} diff --git a/themes/default/layouts/partials/meta-name.html b/themes/default/layouts/partials/meta-name.html index 2de47eb..7c4a16a 100644 --- a/themes/default/layouts/partials/meta-name.html +++ b/themes/default/layouts/partials/meta-name.html @@ -1,14 +1,15 @@ -<micro-metadata-name> - <h2> - <b> - {{- with .Params.feed.name -}} - {{- . -}} - {{- else -}} - {{- partial "author-name.html" . -}} - {{- end -}} - </b> -{{- /* This comment removes trailing newlines and white spaces. */ -}} - </h2> +{{- $href := print .Site.BaseURL "/" (partial "author-user.html" .) "/#" -}} +{{- $name := partial "author-name.html" . -}} +{{- $title := $name -}} + +{{- with .Params.feed -}} + {{- $href = print "http://" $.Params.feed.domain -}} + {{- $name = $.Params.feed.name -}} + {{- $title = $name -}} +{{- end -}} + +<micro-metadata-name title="{{ $title }}"> + <b><a href="{{ $href }}">{{ $name }}</a></b> {{- /* This comment removes trailing newlines and white spaces. */ -}} </micro-metadata-name> {{- /* 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 new file mode 100644 index 0000000..e9950cf --- /dev/null +++ b/themes/default/layouts/partials/meta-permalink.html @@ -0,0 +1,9 @@ +<micro-metadata-permalink> + <a title="#{{ partial "card-id.html" . }}" href="#{{ partial "card-id.html" . }}"> + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/link.svg")) -}} + <span>permalink</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</micro-metadata-permalink> +{{- /* 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 index bc32f41..dbc91f2 100644 --- a/themes/default/layouts/partials/meta-read-time.html +++ b/themes/default/layouts/partials/meta-read-time.html @@ -4,9 +4,9 @@ {{- $seconds = "1" -}} {{- end -}} -<micro-metadata-readtime> +<micro-metadata-readtime title="Takes {{ $seconds }} second{{- if not (eq $seconds "1") -}}s{{- end }} to read"> {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/clock.svg")) -}} - <read-time title="Takes {{ $seconds }} second{{- if not (eq $seconds "1") -}}s{{- end }} to read">{{ $seconds }} sec</read-time> + <span>{{ $seconds }} sec</span> {{- /* This comment removes trailing newlines and white spaces. */ -}} </micro-metadata-readtime> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-source.html b/themes/default/layouts/partials/meta-source.html deleted file mode 100644 index 4a1dbc6..0000000 --- a/themes/default/layouts/partials/meta-source.html +++ /dev/null @@ -1,22 +0,0 @@ -{{- if not .ExpiryDate -}} -{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} -{{- $source := print $author.user "/messages/" .File.LogicalName -}} - - <micro-metadata-source> - {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/code.svg")) -}} - <cite> - {{- with .Params.feed.raw -}} - <a title="{{ $.Site.BaseURL }}/{{ . }}" href="{{ $.Site.BaseURL }}/{{ . }}"> - {{- else -}} - <a - href="{{ .Site.BaseURL }}/{{ partial "function-paths.html" "markdown" }}/{{ $source }}" - title="{{ .Site.BaseURL }}/{{ partial "function-paths.html" "markdown" }}/{{ $source }}"> - {{- end -}} - raw -{{- /* This comment removes trailing newlines and white spaces. */ -}} - </a> -{{- /* This comment removes trailing newlines and white spaces. */ -}} - </cite> -{{- /* This comment removes trailing newlines and white spaces. */ -}} - </micro-metadata-source> -{{- end -}} diff --git a/themes/default/layouts/partials/meta-view.html b/themes/default/layouts/partials/meta-view.html new file mode 100644 index 0000000..d76798d --- /dev/null +++ b/themes/default/layouts/partials/meta-view.html @@ -0,0 +1,18 @@ +{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} + +<micro-metadata-view> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <a + {{ with .Params.feed.self -}} + href="{{ $.Site.BaseURL }}/{{ . }}" + {{ else }} + href="{{ .Site.BaseURL }}/{{ $author.user }}/messages/{{ path.Base .Permalink }}/#{{ partial "card-id.html" . }}" + {{ end }} + > + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/external-link.svg")) -}} + <span>view</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</micro-metadata-view> +{{- /* 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 index e88fec6..081c444 100644 --- a/themes/default/layouts/partials/meta-word-count.html +++ b/themes/default/layouts/partials/meta-word-count.html @@ -1,12 +1,10 @@ -<micro-metadata-wordcount> - {{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} - {{- $limit := $author.wordlimit -}} - {{- $wordLimit := gt .WordCount $limit -}} - {{- $overLimit := sub .WordCount $limit -}} - {{- $bitCount := lang.FormatNumberCustom 0 (len .Content) -}} - {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/file-text.svg")) -}} +{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} +{{- $limit := $author.wordlimit -}} +{{- $wordLimit := gt .WordCount $limit -}} +{{- $overLimit := sub .WordCount $limit -}} +{{- $bitCount := lang.FormatNumberCustom 0 (len .Content) -}} - <word-limit +<micro-metadata-wordcount title=" {{- if $wordLimit -}} {{ $overLimit }} words over the limit @@ -14,7 +12,11 @@ title=" {{ .WordCount }} words {{- end }} {{ $bitCount }} bits +{{- /* This comment removes trailing newlines and white spaces. */ -}} "> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <word-limit> + {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/file-text.svg")) -}} <word-count> {{- if $wordLimit -}} <em>{{ .WordCount }}</em> -- cgit v1.2.3