aboutsummaryrefslogtreecommitdiff
path: root/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'renderer')
-rw-r--r--renderer/model.go3
-rw-r--r--renderer/renderer.go42
2 files changed, 45 insertions, 0 deletions
diff --git a/renderer/model.go b/renderer/model.go
index 102ce55..64b9946 100644
--- a/renderer/model.go
+++ b/renderer/model.go
@@ -10,6 +10,7 @@ type HeaderData struct {
NotificationCount int
CustomCSS string
FluorideMode bool
+ DarkMode bool
}
type NavbarData struct {
@@ -58,6 +59,7 @@ type NotificationData struct {
Notifications []*mastodon.Notification
HasNext bool
NextLink string
+ DarkMode bool
}
type UserData struct {
@@ -66,6 +68,7 @@ type UserData struct {
Statuses []*mastodon.Status
HasNext bool
NextLink string
+ DarkMode bool
}
type AboutData struct {
diff --git a/renderer/renderer.go b/renderer/renderer.go
index 4065312..42bffad 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -11,6 +11,39 @@ import (
"mastodon"
)
+var (
+ icons = map[string]string{
+ "envelope": "/static/icons/envelope.png",
+ "dark-envelope": "/static/icons/dark-envelope.png",
+ "globe": "/static/icons/globe.png",
+ "dark-globe": "/static/icons/dark-globe.png",
+ "liked": "/static/icons/liked.png",
+ "dark-liked": "/static/icons/liked.png",
+ "link": "/static/icons/link.png",
+ "dark-link": "/static/icons/dark-link.png",
+ "lock": "/static/icons/lock.png",
+ "dark-lock": "/static/icons/dark-lock.png",
+ "mail-forward": "/static/icons/mail-forward.png",
+ "dark-mail-forward": "/static/icons/dark-mail-forward.png",
+ "reply": "/static/icons/reply.png",
+ "dark-reply": "/static/icons/dark-reply.png",
+ "retweet": "/static/icons/retweet.png",
+ "dark-retweet": "/static/icons/dark-retweet.png",
+ "retweeted": "/static/icons/retweeted.png",
+ "dark-retweeted": "/static/icons/retweeted.png",
+ "smile-o": "/static/icons/smile-o.png",
+ "dark-smile-o": "/static/icons/dark-smile-o.png",
+ "star-o": "/static/icons/star-o.png",
+ "dark-star-o": "/static/icons/dark-star-o.png",
+ "star": "/static/icons/star.png",
+ "dark-star": "/static/icons/dark-star.png",
+ "unlock-alt": "/static/icons/unlock-alt.png",
+ "dark-unlock-alt": "/static/icons/dark-unlock-alt.png",
+ "user-plus": "/static/icons/user-plus.png",
+ "dark-user-plus": "/static/icons/dark-user-plus.png",
+ }
+)
+
type Renderer interface {
RenderErrorPage(ctx context.Context, writer io.Writer, data *ErrorData)
RenderHomePage(ctx context.Context, writer io.Writer, data *HomePageData) (err error)
@@ -42,6 +75,7 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
"TimeSince": TimeSince,
"FormatTimeRFC3339": FormatTimeRFC3339,
"FormatTimeRFC822": FormatTimeRFC822,
+ "GetIcon": GetIcon,
}).ParseGlob(templateGlobPattern)
if err != nil {
return
@@ -180,3 +214,11 @@ func FormatTimeRFC3339(t time.Time) string {
func FormatTimeRFC822(t time.Time) string {
return t.Format(time.RFC822)
}
+
+func GetIcon(name string, darkMode bool) (icon string) {
+ if darkMode {
+ name = "dark-" + name
+ }
+ icon, _ = icons[name]
+ return
+}