From 29f5bb728b1a08ad19cd3559d17f2235c37bf54a Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 24 Nov 2019 19:15:30 +0100 Subject: [PATCH] Initial commit. --- .gitmodules | 3 + archetypes/default.adoc | 9 +++ archetypes/default.md | 8 +++ config.toml | 62 ++++++++++++++++++ layouts/partials/extra_foot.html | 6 ++ layouts/partials/extra_head.html | 1 + static/comtodon.css | 97 +++++++++++++++++++++++++++ static/comtodon.js | 108 +++++++++++++++++++++++++++++++ static/favicon.png | Bin 0 -> 2196 bytes themes/nocolor | 1 + 10 files changed, 295 insertions(+) create mode 100644 .gitmodules create mode 100644 archetypes/default.adoc create mode 100644 archetypes/default.md create mode 100644 config.toml create mode 100644 layouts/partials/extra_foot.html create mode 100644 layouts/partials/extra_head.html create mode 100644 static/comtodon.css create mode 100644 static/comtodon.js create mode 100644 static/favicon.png create mode 160000 themes/nocolor diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1dbbd0d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "themes/nocolor"] + path = themes/nocolor + url = https://schlomp.space/tastytea/hugo-theme-nocolor.git diff --git a/archetypes/default.adoc b/archetypes/default.adoc new file mode 100644 index 0000000..9d3a61b --- /dev/null +++ b/archetypes/default.adoc @@ -0,0 +1,9 @@ +--- +title: "{{ replace .TranslationBaseName "-" " " | title }}" +description: null +date: {{ .Date }} +type: {{ .Type }} +draft: true +tags: +- +--- diff --git a/archetypes/default.md b/archetypes/default.md new file mode 100644 index 0000000..7f8f0ea --- /dev/null +++ b/archetypes/default.md @@ -0,0 +1,8 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +description: "" +date: {{ .Date }} +draft: true +tags: +--- + diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..3dadf7f --- /dev/null +++ b/config.toml @@ -0,0 +1,62 @@ +baseURL = "https://text-de.tastytea.de/" +languageCode = "de" +title = "tastyteas texthalde." +theme = [ "nocolor" ] +copyright = "CC BY-NC 4.0" + +pygmentsCodefences = true +pygmentsCodeFencesGuessSyntax = false +pygmentsUseClasses = true + +canonifyURLs = false +Paginate = 5 +PaginatePath = "page" + +# enableGitInfo = true + +[params] + subtitle = "Was ich immer schonmal irgendwo hinschreiben wollte." + favicon = "favicon.png" + datefmt = "2006-01-02" + showfullcontent = false + opengraph = true + schema = true + + [params.comtodon] + domain = "likeable.space" + +[taxonomies] + tags = "tags" + +[author] + name = "tastytea" + email = "tastytea@tastytea.de" + +[menu] + [[menu.main]] + identifier = "post" + name = "Posts" + url = "/posts/" + weight = 1 + + [[menu.main]] + identifier = "tags" + name = "Tags" + url = "/tags/" + weight = 2 + + [[menu.main]] + identifier = "rss" + name = "RSS" + url = "/index.xml" + weight = 3 + + [[menu.footer]] + name = "Contact" + url = "https://tastytea.de/" + weight = 1 + + [[menu.footer]] + name = "Sourcecode" + url = "https://schlomp.space/tastytea/text-de" + weight = 2 diff --git a/layouts/partials/extra_foot.html b/layouts/partials/extra_foot.html new file mode 100644 index 0000000..f7fac88 --- /dev/null +++ b/layouts/partials/extra_foot.html @@ -0,0 +1,6 @@ +{{ if .Params.comtodon }} +

Comments

+ +
+ +{{- end }} diff --git a/layouts/partials/extra_head.html b/layouts/partials/extra_head.html new file mode 100644 index 0000000..49ffa7c --- /dev/null +++ b/layouts/partials/extra_head.html @@ -0,0 +1 @@ + diff --git a/static/comtodon.css b/static/comtodon.css new file mode 100644 index 0000000..889a9ec --- /dev/null +++ b/static/comtodon.css @@ -0,0 +1,97 @@ +@charset "UTF-8"; +.comtodon .status { + position: relative; + padding: 0.5em; + margin-bottom: 0.5em; + margin-left: 1em; + border: 0.1em solid; +} + +.comtodon .status-content, .comtodon .reply-main { + margin-bottom: .5em; +} + +.comtodon .status-content { + padding-left: 0.1em; +} + +.comtodon .status-content.sensitive { + content: 'Sensitive'; +} + +.comtodon .replies { + margin-left: 1em; +} + +.comtodon p { + margin: .1em; +} + +.comtodon .emoji { + height: 1em; +} + +.comtodon .author { + display: -ms-grid; + display: grid; + -ms-grid-columns: 3.3em auto; + grid-template-columns: 3.3em auto; + -ms-grid-rows: (1em)[3]; + grid-template-rows: repeat(3, 1em); + grid-gap: 0.1em; +} + +.comtodon .author .avatar { + -ms-grid-row: 1; + -ms-grid-row-span: 3; + -ms-grid-column: 1; + grid-area: 1 / 1 / 4 / 1; + height: 100%; +} + +.comtodon a.author { + text-decoration: none; +} + +.comtodon .author .name { + font-weight: bold; +} + +.comtodon .author .acct:before { + content: '@'; +} + +.comtodon .date { + float: right; +} + +.comtodon .spoiler { + font-weight: bold; +} + +.comtodon .reply-main { + display: inline-block; + padding: .1em .3em; +} + +.comtodon .reply-main:after { + content: ' in the Fediverse'; +} + +.comtodon .reply { + visibility: hidden; + position: absolute; + right: .1em; + top: 2em; +} + +.comtodon .reply:after { + content: 'reply'; + visibility: visible; + display: block; + position: absolute; + right: 0; + bottom: 0; + font-size: .8em; + padding: .1em .3em; +} diff --git a/static/comtodon.js b/static/comtodon.js new file mode 100644 index 0000000..23c98b2 --- /dev/null +++ b/static/comtodon.js @@ -0,0 +1,108 @@ +(function () { + function fail(el, text) { + el.innerHTML = 'Loading fail =(' + console.error(text, el) + } + + function required(el, field) { + const val = el.dataset[field] + if (val) { + return val + } + fail(el, `Missing data-${field} attribut`) + } + + function h(classes, content, tag = 'div') { + return `<${tag} class="${classes}">${content}` + } + + const TIMES = new Map([ + ['second', 1000], + ['minute', 60], + ['hour', 60], + ['day', 24], + ['month', 30.5], + ['year', 12], + ['century', 100] + ]) + + function ago(date) { + const now = Date.now() + const target = Number(new Date(date)) + + const prefix = target > now ? 'in ' : '' + const milliseconds = Math.floor(Math.abs(target - now)) + + let cur = 0 + let divider = 1 + let name = 'millisecond' + for (const time of TIMES) { + divider *= time[1] + const next = Math.floor(milliseconds / divider) + if (next <= 0) { + return `${prefix}${cur} ${name}${cur > 1 ? 's' : ''} ago` + } + name = time[0] + cur = next + } + return `${prefix}a long time ago` + } + + function moji(text, emojis) { + for (const emoji of emojis) { + text = text.split(`:${emoji.shortcode}:`).join( + `${emoji.shortcode}` + ) + } + return text + } + + function tree(statuses, parent, limit) { + const [replies, others] = statuses.reduce(([c, o], s) => (s.in_reply_to_id == parent.id ? [[...c, s], o] : [c, [...o, s]]), [[], []]) + parent.replies = limit ? replies.map(r => tree(others, r, limit - 1)) : [] + return parent + } + + function html(statuses, domain) { + return statuses.map(({ account, created_at, content, id, emojis, sensitive, spoiler_text, replies }) => + h('status', h('date', ago(created_at), 'p') + + h('author" target="_blank" target="_blank" href="' + account.url, `` + + h('name', moji(account.display_name, account.emojis), 'span') + + h('acct', account.acct, 'span'), 'a') + + (spoiler_text || sensitive ? h('spoiler', spoiler_text || h('spoiler-empty', 'Sensitive', 'span')) : '') + + h('status-content' + (spoiler_text || sensitive ? ' sensitive' : ''), moji(content, emojis)) + + (replies ? h('replies', html(replies, domain)) : '') + + h(`reply" target="_blank" href="https://${domain}/interact/${id}?type=reply`, 'Reply', 'a'))).join('') + } + + function moderate(statuses, id) { + if (!id) { + return statuses + } + const valids = statuses.filter(s => s.account.id == id).map(s => s.in_reply_to_id) + return statuses.filter(s => valids.includes(s.id)) + } + + for (const el of document.getElementsByClassName('comtodon')) { + el.innerHTML = '
Loading...
' + + const domain = required(el, 'domain') + const status = required(el, 'status') + if (!domain || !status) { + return + } + + fetch(`https://${domain}/api/v1/statuses/${status}/context`) + .then(res => res.json()) + .then(res => { + el.innerHTML = h(`reply-main" target=\"_blank\" href="https://${domain}/interact/${status}?type=reply`, 'Comment', 'a') + const statuses = moderate(res.descendants, el.dataset.moderator) + if (statuses) { + el.innerHTML += html('deep' in el.dataset ? tree(statuses, { id: status }, el.dataset.deep || -1).replies : statuses, domain) + } else { + el.innerHTML += h('empty', 'Any comment') + } + }) + .catch(() => fail(el, 'Request fail')) + } +})() \ No newline at end of file diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..260de8fd33b09d98037ad0d724f07fa9c7510cbb GIT binary patch literal 2196 zcm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