Refactor renderer and templates

This commit is contained in:
r 2020-01-14 16:57:16 +00:00
parent 3c6653a77b
commit 55987a4c1b
27 changed files with 262 additions and 242 deletions

View file

@ -1,5 +1,6 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> About </div>
<div>
@ -15,4 +16,5 @@
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,5 +1,6 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Emojis </div>
<div class="emoji-list-container">
@ -12,5 +13,4 @@
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,9 +1,12 @@
{{template "header.tmpl" .HeaderData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
<div class="page-title"> Error </div>
<div class="error-text"> {{.Error}} </div>
<div>
<a href="/timeline/home">Home</a>
<a href="/signin">Sign In</a>
<a href="/timeline/home">Home</a>
<a href="/signin">Sign In</a>
</div>
{{template "footer.tmpl"}}
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,8 +1,9 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Followers </div>
{{template "userlist.tmpl" .Users}}
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
<div class="pagination">
{{if .HasNext}}
<a href="{{.NextLink}}">next</a>
@ -10,3 +11,4 @@
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,8 +1,9 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Following </div>
{{template "userlist.tmpl" .Users}}
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
<div class="pagination">
{{if .HasNext}}
<a href="{{.NextLink}}">next</a>
@ -10,3 +11,4 @@
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,3 +1,4 @@
{{with .Data}}
<!DOCTYPE html>
<html lang="en">
<head>
@ -8,8 +9,9 @@
{{if .CustomCSS}}
<link rel="stylesheet" href="{{.CustomCSS}}">
{{end}}
{{if .FluorideMode}}
{{if $.Ctx.FluorideMode}}
<script src="/static/fluoride.js"></script>
{{end}}
</head>
<body {{if .DarkMode}}class="dark"{{end}}>
<body {{if $.Ctx.DarkMode}}class="dark"{{end}}>
{{end}}

View file

@ -1,4 +0,0 @@
{{template "header.tmpl" .HeaderData}}
<div class="page-title"> Home </div>
<a href="/signin"> Signin </a>
{{template "footer.tmpl"}}

View file

@ -1,7 +1,9 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Liked By </div>
{{template "userlist.tmpl" .Users}}
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,3 +1,4 @@
{{with .Data}}
<div class="user-info">
<div class="user-info-img-container">
<a class="img-link" href="/timeline/home" title="home">
@ -25,3 +26,4 @@
</div>
</div>
</div>
{{end}}

View file

@ -1,5 +1,6 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Notifications </div>
{{range .Notifications}}
@ -14,7 +15,7 @@
<div>
<div class="notification-info-text">
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
<img class="icon" src="{{GetIcon "user-plus" .DarkMode}}" alt="followed" />
<img class="icon" src="{{GetIcon "user-plus" $.Ctx.DarkMode}}" alt="followed" />
<span> followed you </span>
</div>
<div class="notification-follow-uname">
@ -24,7 +25,7 @@
</div>
{{else if eq .Type "mention"}}
{{template "status" .Status}}
{{template "status" (WithContext .Status $.Ctx)}}
{{else if eq .Type "reblog"}}
<div class="notification-retweet-container">
@ -36,10 +37,10 @@
<div>
<div class="notification-info-text">
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
<img class="icon" src="{{GetIcon "retweeted" .DarkMode}}" alt="retweeted" />
<img class="icon" src="{{GetIcon "retweeted" $.Ctx.DarkMode}}" alt="retweeted" />
<span> retweeted your post </span>
</div>
{{template "status" .Status}}
{{template "status" (WithContext .Status $.Ctx)}}
</div>
</div>
@ -53,10 +54,10 @@
<div>
<div class="notification-info-text">
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
<img class="icon" src="{{GetIcon "liked" .DarkMode}}" alt="liked" />
<img class="icon" src="{{GetIcon "liked" $.Ctx.DarkMode}}" alt="liked" />
<span> liked your post </span>
</div>
{{template "status" .Status}}
{{template "status" (WithContext .Status $.Ctx)}}
</div>
</div>
{{end}}
@ -68,4 +69,6 @@
<a href="{{.NextLink}}">next</a>
{{end}}
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,3 +1,4 @@
{{with .Data}}
<form class="post-form" action="/post" method="POST" enctype="multipart/form-data">
{{if .ReplyContext}}
<input type="hidden" name="reply_to_id" value="{{.ReplyContext.InReplyToID}}" />
@ -6,7 +7,7 @@
<label for="post-content" class="post-form-title"> New post </label>
{{end}}
<a class="post-form-emoji-link" href="/emojis" target="_blank" title="emoji reference">
<img class="icon post-emoji" src="{{GetIcon "smile-o" .DarkMode}}" alt="emojis" />
<img class="icon post-emoji" src="{{GetIcon "smile-o" $.Ctx.DarkMode}}" alt="emojis" />
</a>
<div class="post-form-content-container">
<textarea id="post-content" name="content" class="post-content" cols="50" rows="5">{{if .ReplyContext}}{{.ReplyContext.ReplyContent}}{{end}}</textarea>
@ -42,4 +43,5 @@
</div>
<button type="submit"> Post </button>
</form>
{{end}}

View file

@ -1,7 +1,9 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Retweeted By </div>
{{template "userlist.tmpl" .Users}}
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,5 +1,6 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Search </div>
<div>
@ -21,12 +22,12 @@
{{if eq .Type "statuses"}}
{{range .Statuses}}
{{template "status.tmpl" .}}
{{template "status.tmpl" (WithContext . $.Ctx)}}
{{end}}
{{end}}
{{if eq .Type "accounts"}}
{{template "userlist.tmpl" .Users}}
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
{{end}}
<div class="pagination">
@ -34,4 +35,6 @@
<a href="{{.NextLink}}">next</a>
{{end}}
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,5 +1,6 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Settings </div>
<form id="settings-form" action="/settings" method="POST">
@ -36,3 +37,4 @@
</form>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,4 +1,5 @@
{{template "header.tmpl" .HeaderData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
<div class="page-title"> Signin </div>
<form class="signin-form" action="/signin" method="post">
@ -8,3 +9,4 @@
</form>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,3 +1,4 @@
{{with .Data}}
<div id="status-{{.ID}}" class="status-container-container">
{{if .Reblog}}
<div class="retweet-info">
@ -5,12 +6,13 @@
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="avatar" />
</a>
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
<img class="icon" src="{{GetIcon "retweeted" .DarkMode}}" alt="retweeted" />
<img class="icon" src="{{GetIcon "retweeted" $.Ctx.DarkMode}}" alt="retweeted" />
retweeted
</div>
{{template "status" .Reblog}}
{{template "status" (WithContext .Reblog $.Ctx)}}
{{else}}
{{block "status" .}}
{{block "status" (WithContext . $.Ctx)}}
{{with $s := .Data}}
<div class="status-container status-{{.ID}}" data-id="{{.ID}}">
{{if not .HideAccountInfo}}
<div class="status-profile-img-container">
@ -28,17 +30,17 @@
</a>
<a class="status-visibility">
{{if eq .Visibility "public"}}
<img class="icon" src="{{GetIcon "globe" .DarkMode}}" alt="Public" title="Public" />
<img class="icon" src="{{GetIcon "globe" $.Ctx.DarkMode}}" alt="Public" title="Public" />
{{else if eq .Visibility "unlisted"}}
<img class="icon" src="{{GetIcon "unlock-alt" .DarkMode}}" alt="Unlisted" title="Unlisted" />
<img class="icon" src="{{GetIcon "unlock-alt" $.Ctx.DarkMode}}" alt="Unlisted" title="Unlisted" />
{{else if eq .Visibility "private"}}
<img class="icon" src="{{GetIcon "lock" .DarkMode}}" alt="Private" title="Private" />
<img class="icon" src="{{GetIcon "lock" $.Ctx.DarkMode}}" alt="Private" title="Private" />
{{else if eq .Visibility "direct"}}
<img class="icon" src="{{GetIcon "envelope" .DarkMode}}" alt="Direct" title="Direct" />
<img class="icon" src="{{GetIcon "envelope" $.Ctx.DarkMode}}" alt="Direct" title="Direct" />
{{end}}
</a>
<a class="remote-link" href="{{.URL}}" target="_blank" title="source">
<img class="icon" src="{{GetIcon "link" .DarkMode}}" alt="source" />
<img class="icon" src="{{GetIcon "link" $.Ctx.DarkMode}}" alt="source" />
</a>
</div>
{{end}}
@ -46,7 +48,7 @@
{{if .InReplyToID}}
<div class="status-reply-to">
<a class="status-reply-to-link" href="{{if not .ShowReplies}}/thread/{{.InReplyToID}}{{end}}#status-{{.InReplyToID}}">
<img class="icon" src="{{GetIcon "mail-forward" .DarkMode}}" alt="reply to" /> reply to {{.Pleroma.InReplyToAccountAcct}}
<img class="icon" src="{{GetIcon "mail-forward" $.Ctx.DarkMode}}" alt="reply to" /> reply to {{.Pleroma.InReplyToAccountAcct}}
</a>
</div>
{{if index .ReplyMap .ID}} <span class="status-reply-info-divider"> - </span> {{end}}
@ -66,7 +68,7 @@
{{if eq .Type "image"}}
<a class="img-link" href="{{.URL}}" target="_blank">
<img class="status-image" src="{{.URL}}" alt="status-image" />
{{if (and $.MaskNSFW $.Sensitive)}}
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</a>
@ -81,7 +83,7 @@
<source src="{{.URL}}">
<p> Your browser doesn't support HTML5 video </p>
</video>
{{if (and $.MaskNSFW $.Sensitive)}}
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</div>
@ -93,27 +95,27 @@
<div class="status-action-container">
<div class="status-action">
<a class="status-you" href="/thread/{{.ID}}?reply=true#status-{{.ID}}" title="reply">
<img class="icon" src="{{GetIcon "reply" .DarkMode}}" alt="reply" />
<img class="icon" src="{{GetIcon "reply" $.Ctx.DarkMode}}" alt="reply" />
</a>
<a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if .ThreadInNewTab}}target="_blank"{{end}}>
<a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
{{DisplayInteractionCount .RepliesCount}}
</a>
</div>
<div class="status-action">
{{if or (eq .Visibility "private") (eq .Visibility "direct")}}
<a class="status-retweet" title="this status cannot be retweeted">
<img class="icon" src="{{GetIcon "retweet" .DarkMode}}" alt="retweet" />
<img class="icon" src="{{GetIcon "retweet" $.Ctx.DarkMode}}" alt="retweet" />
</a>
{{else}}
{{if .Reblogged}}
<form class="status-retweet" data-action="unretweet" action="/unretweet/{{.ID}}" method="post">
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
<input type="image" src="{{GetIcon "retweeted" .DarkMode}}" alt="undo retweet" class="icon" title="undo retweet">
<input type="image" src="{{GetIcon "retweeted" $.Ctx.DarkMode}}" alt="undo retweet" class="icon" title="undo retweet">
</form>
{{else}}
<form class="status-retweet" data-action="retweet" action="/retweet/{{.ID}}" method="post">
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
<input type="image" src="{{GetIcon "retweet" .DarkMode}}" alt="retweet" class="icon" title="retweet">
<input type="image" src="{{GetIcon "retweet" $.Ctx.DarkMode}}" alt="retweet" class="icon" title="retweet">
</form>
{{end}}
{{end}}
@ -125,12 +127,12 @@
{{if .Favourited}}
<form class="status-like" data-action="unlike" action="/unlike/{{.ID}}" method="post">
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
<input type="image" src="{{GetIcon "liked" .DarkMode}}" alt="unlike" class="icon" title="unlike">
<input type="image" src="{{GetIcon "liked" $.Ctx.DarkMode}}" alt="unlike" class="icon" title="unlike">
</form>
{{else}}
<form class="status-like" data-action="like" action="/like/{{.ID}}" method="post">
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
<input type="image" src="{{GetIcon "star-o" .DarkMode}}" alt="like" class="icon" title="like">
<input type="image" src="{{GetIcon "star-o" $.Ctx.DarkMode}}" alt="like" class="icon" title="like">
</form>
{{end}}
<a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list">
@ -138,7 +140,7 @@
</a>
</div>
<div class="status-action">
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}" {{if .ThreadInNewTab}}target="_blank"{{end}}>
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}" {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}"> {{TimeSince .CreatedAt}} </time>
</a>
</div>
@ -147,4 +149,6 @@
</div>
{{end}}
{{end}}
{{end}}
</div>
{{end}}

View file

@ -1,14 +1,16 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with $s := .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> Thread </div>
{{range .Statuses}}
{{template "status.tmpl" .}}
{{if $.PostContext.ReplyContext}}{{if eq .ID $.PostContext.ReplyContext.InReplyToID}}
{{template "postform.tmpl" $.PostContext}}
{{template "status.tmpl" (WithContext . $.Ctx)}}
{{if $s.PostContext.ReplyContext}}{{if eq .ID $s.PostContext.ReplyContext.InReplyToID}}
{{template "postform.tmpl" (WithContext $s.PostContext $.Ctx)}}
{{end}}{{end}}
{{end}}
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,12 +1,12 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> {{.Title}} </div>
{{template "postform.tmpl" .PostContext}}
{{template "postform.tmpl" (WithContext .PostContext $.Ctx)}}
{{range .Statuses}}
{{template "status.tmpl" .}}
{{template "status.tmpl" (WithContext . $.Ctx)}}
{{end}}
<div class="pagination">
@ -17,4 +17,6 @@
<a href="{{.NextLink}}">next</a>
{{end}}
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,5 +1,6 @@
{{template "header.tmpl" .HeaderData}}
{{template "navigation.tmpl" .NavbarData}}
{{with .Data}}
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
<div class="page-title"> User </div>
<div class="user-info-container">
@ -14,7 +15,7 @@
<span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>
<span class="status-uname"> {{.User.Acct}} </span>
<a class="remote-link" href="{{.User.URL}}" target="_blank" title="remote profile">
<img class="icon" src="{{GetIcon "link" .DarkMode}}" alt="link" />
<img class="icon" src="{{GetIcon "link" $.Ctx.DarkMode}}" alt="link" />
</a>
</div>
<div>
@ -48,7 +49,7 @@
</div>
{{range .Statuses}}
{{template "status.tmpl" .}}
{{template "status.tmpl" (WithContext . $.Ctx)}}
{{end}}
<div class="pagination">
@ -58,4 +59,4 @@
</div>
{{template "footer.tmpl"}}
{{end}}

View file

@ -1,3 +1,4 @@
{{with .Data}}
<div class="user-list-container">
{{range .}}
<div class="user-list-item">
@ -15,3 +16,4 @@
</div>
{{end}}
</div>
{{end}}