mirror of
https://github.com/Brandon-Rozek/website-theme.git
synced 2024-11-21 15:56:29 -05:00
Refactored toot code
This commit is contained in:
parent
80bae4b2a9
commit
adb903dc60
7 changed files with 94 additions and 236 deletions
|
@ -267,6 +267,10 @@ main {
|
||||||
min-height: calc(100vh - 250px);
|
min-height: calc(100vh - 250px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
article {
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
main .e-content {
|
main .e-content {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
51
layouts/partials/toot.html
Normal file
51
layouts/partials/toot.html
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{{ $tootData := .Scratch.Get "toot" }}
|
||||||
|
|
||||||
|
{{ with $tootData }}
|
||||||
|
{{ if ne .content "" }}
|
||||||
|
<article class="toot h-entry">
|
||||||
|
<div rel="author" class="h-card p-author toot-avatar">
|
||||||
|
<img class="u-photo" width=50 src="{{ .account.avatar }}"/>
|
||||||
|
<span style="display: none;">{{ .account.display_name }}</span>
|
||||||
|
</div>
|
||||||
|
<p class="date">Tooted on <time class="dt-published" datetime='{{ .created_at }}'>{{ dateFormat "January 2, 2006 15:04" (time .created_at) }}</time></p>
|
||||||
|
<div class="e-content p-name">
|
||||||
|
{{ .content | safeHTML }}
|
||||||
|
{{ if gt (len .media_attachments) 0 }}
|
||||||
|
<div class="toot-photos">
|
||||||
|
{{ range .media_attachments}}
|
||||||
|
{{ if eq .type "image" }}
|
||||||
|
<img src="{{ .preview_url }}" alt="{{ .description }}"/>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
<a class="u-url" style="display: none">{{ .Permalink }}</a>
|
||||||
|
{{ range .tags }}
|
||||||
|
<a class="p-category" href="{{ .url }}" style="display: none;">{{ .name }}</a>
|
||||||
|
{{ end }}
|
||||||
|
<div class="toot-social">
|
||||||
|
{{ $post_url := urls.Parse .url }}
|
||||||
|
{{ $status_id := index (last 1 (split $post_url.Path "/")) 0 }}
|
||||||
|
{{ $social_url := printf "%s://%s/interact/%s" $post_url.Scheme $post_url.Host $status_id }}
|
||||||
|
{{ $reply_url := printf "%s?type=reply" $social_url }}
|
||||||
|
{{ $favorite_url := printf "%s?type=favourite" $social_url }}
|
||||||
|
{{ $boost_url := printf "%s?type=reblog" $social_url }}
|
||||||
|
<span>
|
||||||
|
<a class='fas fa-share' href="{{ $reply_url }}"></a>
|
||||||
|
{{ .replies_count }}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<a class='fas fa-retweet' href="{{ $boost_url }}"></a>
|
||||||
|
{{ .reblogs_count }}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<a class='fas fa-star' href="{{ $favorite_url }}"></a>
|
||||||
|
{{ .favourites_count }}
|
||||||
|
</span>
|
||||||
|
<span>| Source: <a class="u-syndication" href="{{ .url }}">{{ .url }}</a></span>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
@ -3,51 +3,5 @@
|
||||||
{{ $api_url := printf "%s://%s/api/v1/statuses/%s" $url.Scheme $url.Host $status_id }}
|
{{ $api_url := printf "%s://%s/api/v1/statuses/%s" $url.Scheme $url.Host $status_id }}
|
||||||
{{ $dataJ := getJSON $api_url }}
|
{{ $dataJ := getJSON $api_url }}
|
||||||
|
|
||||||
{{ with $dataJ }}
|
{{ .Scratch.Set "toot" $dataJ }}
|
||||||
{{ if ne .content "" }}
|
{{ partial "toot.html" . }}
|
||||||
<article class="toot h-entry">
|
|
||||||
<div rel="author" class="h-card p-author toot-avatar">
|
|
||||||
<img class="u-photo" width=50 src="{{ .account.avatar }}"/>
|
|
||||||
<span style="display: none;">{{ .account.display_name }}</span>
|
|
||||||
</div>
|
|
||||||
<p class="date">Tooted on <time class="dt-published" datetime='{{ .created_at }}'>{{ dateFormat "January 2, 2006 15:04" (time .created_at) }}</time></p>
|
|
||||||
<div class="e-content p-name">
|
|
||||||
{{ .content | safeHTML }}
|
|
||||||
{{ if gt (len .media_attachments) 0 }}
|
|
||||||
<div class="toot-photos">
|
|
||||||
{{ range .media_attachments}}
|
|
||||||
{{ if eq .type "image" }}
|
|
||||||
<img src="{{ .preview_url }}" alt="{{ .description }}"/>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
<a class="u-url" style="display: none">{{ .Permalink }}</a>
|
|
||||||
{{ range .tags }}
|
|
||||||
<a class="p-category" href="{{ .url }}" style="display: none;">{{ .name }}</a>
|
|
||||||
{{ end }}
|
|
||||||
<div class="toot-social">
|
|
||||||
{{ $post_url := urls.Parse .url }}
|
|
||||||
{{ $status_id := index (last 1 (split $post_url.Path "/")) 0 }}
|
|
||||||
{{ $social_url := printf "%s://%s/interact/%s" $post_url.Scheme $post_url.Host $status_id }}
|
|
||||||
{{ $reply_url := printf "%s?type=reply" $social_url }}
|
|
||||||
{{ $favorite_url := printf "%s?type=favourite" $social_url }}
|
|
||||||
{{ $boost_url := printf "%s?type=reblog" $social_url }}
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-share' href="{{ $reply_url }}"></a>
|
|
||||||
{{ .replies_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-retweet' href="{{ $boost_url }}"></a>
|
|
||||||
{{ .reblogs_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-star' href="{{ $favorite_url }}"></a>
|
|
||||||
{{ .favourites_count }}
|
|
||||||
</span>
|
|
||||||
<span>| Source: <a class="u-syndication" href="{{ .url }}">{{ .url }}</a></span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
|
@ -2,51 +2,5 @@
|
||||||
{{ $url := printf "static/data/toots/%s.json" $toot_reference }}
|
{{ $url := printf "static/data/toots/%s.json" $toot_reference }}
|
||||||
{{ $dataJ := getJSON $url }}
|
{{ $dataJ := getJSON $url }}
|
||||||
|
|
||||||
{{ with $dataJ }}
|
{{ .Scratch.Set "toot" $dataJ }}
|
||||||
{{ if ne .content "" }}
|
{{ partial "toot.html" . }}
|
||||||
<article class="toot h-entry">
|
|
||||||
<div rel="author" class="h-card p-author toot-avatar">
|
|
||||||
<img class="u-photo" width=50 src="{{ .account.avatar }}"/>
|
|
||||||
<span style="display: none;">{{ .account.display_name }}</span>
|
|
||||||
</div>
|
|
||||||
<p class="date">Tooted on <time class="dt-published" datetime='{{ .created_at }}'>{{ dateFormat "January 2, 2006 15:04" (time .created_at) }}</time></p>
|
|
||||||
<div class="e-content p-name">
|
|
||||||
{{ .content | safeHTML }}
|
|
||||||
{{ if gt (len .media_attachments) 0 }}
|
|
||||||
<div class="toot-photos">
|
|
||||||
{{ range .media_attachments}}
|
|
||||||
{{ if eq .type "image" }}
|
|
||||||
<img src="{{ .preview_url }}" alt="{{ .description }}"/>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
<a class="u-url" style="display: none">{{ .Permalink }}</a>
|
|
||||||
{{ range .tags }}
|
|
||||||
<a class="p-category" href="{{ .url }}" style="display: none;">{{ .name }}</a>
|
|
||||||
{{ end }}
|
|
||||||
<div class="toot-social">
|
|
||||||
{{ $post_url := urls.Parse .url }}
|
|
||||||
{{ $status_id := index (last 1 (split $post_url.Path "/")) 0 }}
|
|
||||||
{{ $social_url := printf "%s://%s/interact/%s" $post_url.Scheme $post_url.Host $status_id }}
|
|
||||||
{{ $reply_url := printf "%s?type=reply" $social_url }}
|
|
||||||
{{ $favorite_url := printf "%s?type=favourite" $social_url }}
|
|
||||||
{{ $boost_url := printf "%s?type=reblog" $social_url }}
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-share' href="{{ $reply_url }}"></a>
|
|
||||||
{{ .Params.replies_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-retweet' href="{{ $boost_url }}"></a>
|
|
||||||
{{ .Params.reblogs_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-star' href="{{ $favorite_url }}"></a>
|
|
||||||
{{ .Params.favourites_count }}
|
|
||||||
</span>
|
|
||||||
<span>| Source: <a class="u-syndication" href="{{ .url }}">{{ .url }}</a></span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
|
@ -3,50 +3,6 @@
|
||||||
|
|
||||||
|
|
||||||
{{ range sort $dataJ "created_at" "desc" }}
|
{{ range sort $dataJ "created_at" "desc" }}
|
||||||
{{ if ne .content "" }}
|
{{ .Scratch.Set "toot" $dataJ }}
|
||||||
<article class="toot h-entry">
|
{{ partial "toot.html" . }}
|
||||||
<div rel="author" class="h-card p-author toot-avatar">
|
|
||||||
<img class="u-photo" width=50 src="{{ .account.avatar }}"/>
|
|
||||||
<span style="display: none;">{{ .account.display_name }}</span>
|
|
||||||
</div>
|
|
||||||
<p class="date">Tooted on <time class="dt-published" datetime='{{ .created_at }}'>{{ dateFormat "January 2, 2006 15:04" (time .created_at) }}</time></p>
|
|
||||||
<div class="e-content p-name">
|
|
||||||
{{ .content | safeHTML }}
|
|
||||||
{{ if gt (len .media_attachments) 0 }}
|
|
||||||
<div class="toot-photos">
|
|
||||||
{{ range .media_attachments}}
|
|
||||||
{{ if eq .type "image" }}
|
|
||||||
<img src="{{ .preview_url }}" alt="{{ .description }}"/>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
<a class="u-url" style="display: none">{{ .Permalink }}</a>
|
|
||||||
{{ range .tags }}
|
|
||||||
<a class="p-category" href="{{ .url }}" style="display: none;">{{ .name }}</a>
|
|
||||||
{{ end }}
|
|
||||||
<div class="toot-social">
|
|
||||||
{{ $post_url := urls.Parse .url }}
|
|
||||||
{{ $status_id := index (last 1 (split $post_url.Path "/")) 0 }}
|
|
||||||
{{ $social_url := printf "%s://%s/interact/%s" $post_url.Scheme $post_url.Host $status_id }}
|
|
||||||
{{ $reply_url := printf "%s?type=reply" $social_url }}
|
|
||||||
{{ $favorite_url := printf "%s?type=favourite" $social_url }}
|
|
||||||
{{ $boost_url := printf "%s?type=reblog" $social_url }}
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-share' href="{{ $reply_url }}"></a>
|
|
||||||
{{ .Params.replies_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-retweet' href="{{ $boost_url }}"></a>
|
|
||||||
{{ .Params.reblogs_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-star' href="{{ $favorite_url }}"></a>
|
|
||||||
{{ .Params.favourites_count }}
|
|
||||||
</span>
|
|
||||||
<span>| Source: <a class="u-syndication" href="{{ .url }}">{{ .url }}</a></span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -3,59 +3,25 @@
|
||||||
<main>
|
<main>
|
||||||
<style>main { text-align: left; }</style>
|
<style>main { text-align: left; }</style>
|
||||||
{{ partial "search.html" . }}
|
{{ partial "search.html" . }}
|
||||||
<p>
|
{{ .Content }}
|
||||||
This is an experimental page showing my toots from Mastodon.
|
|
||||||
Currently, this does not support boosts and it does not automatically refresh.
|
|
||||||
Feel free to check out
|
|
||||||
<a href="https://fosstodon.org/@brozek">my profile at Fosstodon</a>
|
|
||||||
</p>
|
|
||||||
{{ $listPageDateFormat := .Site.Params.listPageDateFormat | default "January, 2006"}}
|
{{ $listPageDateFormat := .Site.Params.listPageDateFormat | default "January, 2006"}}
|
||||||
{{ range $index, $value := .Pages.GroupByDate $listPageDateFormat }}
|
{{ range $index, $value := .Pages.GroupByDate $listPageDateFormat }}
|
||||||
{{ range .Pages }}
|
{{ range .Pages }}
|
||||||
<article class="toot h-entry">
|
{{ $dataJ := dict "account" .Params.account
|
||||||
<div rel="author" class="h-card p-author toot-avatar">
|
"account.display_name" .Params.account.display_name
|
||||||
<img class="u-photo" width=50 src="{{ .Params.account.avatar }}"/>
|
"created_at" .Date
|
||||||
<span style="display: none;">{{ .Params.account.display_name }}</span>
|
"content" .Content
|
||||||
</div>
|
"media_attachments" .Params.media_attachments
|
||||||
<p class="date">Tooted on <time class="dt-published" datetime='{{ .Date }}'>{{ dateFormat "January 2, 2006 15:04" (time .Date) }}</time></p>
|
"Permalink" .Permalink
|
||||||
<div class="e-content p-name">
|
"tags" .Params.tags
|
||||||
{{ .Content | safeHTML }}
|
"url" .Params.syndication
|
||||||
{{ if gt (len .Params.media_attachments) 0 }}
|
"replies_count" .Params.replies_count
|
||||||
<div class="toot-photos">
|
"reblogs_count" .Params.reblogs_count
|
||||||
{{ range .Params.media_attachments}}
|
"favourites_count" .Params.favourites_count
|
||||||
{{ if eq .type "image" }}
|
}}
|
||||||
<img src="{{ .preview_url }}" alt="{{ .description }}"/>
|
|
||||||
{{ end }}
|
{{ .Scratch.Set "toot" $dataJ }}
|
||||||
{{ end }}
|
{{ partial "toot.html" . }}
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
<a class="u-url" style="display: none">{{ .Permalink }}</a>
|
|
||||||
{{ range .Params.tags }}
|
|
||||||
<a class="p-category" href="{{ .url }}" style="display: none;">{{ .name }}</a>
|
|
||||||
{{ end }}
|
|
||||||
<div class="toot-social">
|
|
||||||
{{ $post_url := urls.Parse .Params.syndication }}
|
|
||||||
{{ $status_id := index (last 1 (split $post_url.Path "/")) 0 }}
|
|
||||||
{{ $social_url := printf "%s://%s/interact/%s" $post_url.Scheme $post_url.Host $status_id }}
|
|
||||||
{{ $reply_url := printf "%s?type=reply" $social_url }}
|
|
||||||
{{ $favorite_url := printf "%s?type=favourite" $social_url }}
|
|
||||||
{{ $boost_url := printf "%s?type=reblog" $social_url }}
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-share' href="{{ $reply_url }}"></a>
|
|
||||||
{{ .Params.replies_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-retweet' href="{{ $boost_url }}"></a>
|
|
||||||
{{ .Params.reblogs_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-star' href="{{ $favorite_url }}"></a>
|
|
||||||
{{ .Params.favourites_count }}
|
|
||||||
</span>
|
|
||||||
<span>| Source: <a class="u-syndication" href="{{ .Params.syndication }}">{{ .Params.syndication }}</a></span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -4,50 +4,23 @@
|
||||||
{{ .Scratch.Set "customTitleHeaderLink" "/toots" }}
|
{{ .Scratch.Set "customTitleHeaderLink" "/toots" }}
|
||||||
{{ partial "header.html" . }}
|
{{ partial "header.html" . }}
|
||||||
<main>
|
<main>
|
||||||
<article class="toot h-entry">
|
{{ $dataJ := dict "account" .Params.account
|
||||||
<div rel="author" class="h-card p-author toot-avatar">
|
"account.display_name" .Params.account.display_name
|
||||||
<img class="u-photo" width=50 src="{{ .Params.account.avatar }}"/>
|
"created_at" .Date
|
||||||
<span style="display: none;">{{ .Params.account.display_name }}</span>
|
"content" .Content
|
||||||
</div>
|
"media_attachments" .Params.media_attachments
|
||||||
<p class="date">Tooted on <time class="dt-published" datetime='{{ .Date }}'>{{ dateFormat "January 2, 2006 15:04" (time .Date) }}</time></p>
|
"Permalink" .Permalink
|
||||||
<div class="e-content p-name">
|
"tags" .Params.tags
|
||||||
{{ .Content | safeHTML }}
|
"url" .Params.syndication
|
||||||
{{ if gt (len .Params.media_attachments) 0 }}
|
"replies_count" .Params.replies_count
|
||||||
<div class="toot-photos">
|
"reblogs_count" .Params.reblogs_count
|
||||||
{{ range .Params.media_attachments}}
|
"favourites_count" .Params.favourites_count
|
||||||
{{ if eq .type "image" }}
|
}}
|
||||||
<img src="{{ .preview_url }}" alt="{{ .description }}"/>
|
|
||||||
{{ end }}
|
{{ .Scratch.Set "toot" $dataJ }}
|
||||||
{{ end }}
|
{{ partial "toot.html" . }}
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
<a class="u-url" style="display: none">{{ .Permalink }}</a>
|
|
||||||
{{ range .Params.tags }}
|
|
||||||
<a class="p-category" href="{{ .url }}" style="display: none;">{{ .name }}</a>
|
|
||||||
{{ end }}
|
|
||||||
<div class="toot-social">
|
|
||||||
{{ $post_url := urls.Parse .Params.syndication }}
|
|
||||||
{{ $status_id := index (last 1 (split $post_url.Path "/")) 0 }}
|
|
||||||
{{ $social_url := printf "%s://%s/interact/%s" $post_url.Scheme $post_url.Host $status_id }}
|
|
||||||
{{ $reply_url := printf "%s?type=reply" $social_url }}
|
|
||||||
{{ $favorite_url := printf "%s?type=favourite" $social_url }}
|
|
||||||
{{ $boost_url := printf "%s?type=reblog" $social_url }}
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-share' href="{{ $reply_url }}"></a>
|
|
||||||
{{ .Params.replies_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-retweet' href="{{ $boost_url }}"></a>
|
|
||||||
{{ .Params.reblogs_count }}
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<a class='fas fa-star' href="{{ $favorite_url }}"></a>
|
|
||||||
{{ .Params.favourites_count }}
|
|
||||||
</span>
|
|
||||||
<span>| Source: <a class="u-syndication" href="{{ .Params.syndication }}">{{ .Params.syndication }}</a></span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
||||||
{{ partial "footer.html" . }}
|
{{ partial "footer.html" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue