Fix language tag and improve templates

This commit is contained in:
Andrew71 2024-08-28 14:53:54 +03:00
parent 2b0f9c139a
commit 8ae76cc8e8
12 changed files with 35 additions and 27 deletions

View file

@ -1,6 +1,11 @@
# Changelog # Changelog
This file keeps track of changes in a human-readable fashion This file keeps track of changes in a human-readable fashion
## v1.1.4
* Fixed HTML `lang` tag
* Theme CSS link is now only present if non-default is set
* Improved template consistency (backend)
## v1.1.3 ## v1.1.3
This release mostly consists of backend improvements This release mostly consists of backend improvements
* List items no longer replace hyphens with spaces for consistency * List items no longer replace hyphens with spaces for consistency

View file

@ -51,7 +51,7 @@ port=7101 # What port to run on (probably leave on 7101 if using docker)
timezone=Local # IANA Time zone database identifier ("UTC", Local", "Europe/Moscow" etc.), Defaults to Local if can't parse. timezone=Local # IANA Time zone database identifier ("UTC", Local", "Europe/Moscow" etc.), Defaults to Local if can't parse.
grace_period=0s # Time after a new day begins, but before the switch to next day's file. e.g. 3h26m - files will change at 3:26am grace_period=0s # Time after a new day begins, but before the switch to next day's file. e.g. 3h26m - files will change at 3:26am
language=en # ISO-639 language code (available - en, ru) language=en # ISO-639 language code (available - en, ru)
theme=default # Picked theme (available - default, high-contrast, lavender, gruvbox, sans) theme="" # Picked theme (available - default (if left empty), high-contrast, lavender, gruvbox, sans)
title=🌺 Hibiscus.txt # The text in the header title=🌺 Hibiscus.txt # The text in the header
log_to_file=false # Whether to write logs to a file log_to_file=false # Whether to write logs to a file
log_file=config/log.txt # Where to store the log file if it is enabled log_file=config/log.txt # Where to store the log file if it is enabled

View file

@ -41,7 +41,7 @@ var DefaultConfig = Config{
Timezone: time.Local, Timezone: time.Local,
GraceTime: 0, GraceTime: 0,
Language: "en", Language: "en",
Theme: "default", Theme: "",
Title: "🌺 Hibiscus.txt", Title: "🌺 Hibiscus.txt",
LogToFile: false, LogToFile: false,
LogFile: "config/log.txt", LogFile: "config/log.txt",

View file

@ -1,4 +1,6 @@
{ {
"lang": "en-UK",
"title.today": "Your day so far", "title.today": "Your day so far",
"title.days": "Previous days", "title.days": "Previous days",
"title.notes": "Notes", "title.notes": "Notes",

View file

@ -1,4 +1,6 @@
{ {
"lang": "ru",
"title.today": "Сегодняшний день", "title.today": "Сегодняшний день",
"title.days": "Предыдущие дни", "title.days": "Предыдущие дни",
"title.notes": "Заметки", "title.notes": "Заметки",
@ -11,7 +13,7 @@
"link.info": "системная информация", "link.info": "системная информация",
"time.date": "Сегодня", "time.date": "Сегодня",
"time.grace": "льготный период", "time.grace": "редактируется вчерашний день",
"button.save": "Сохранить", "button.save": "Сохранить",
"button.notes": "Новая заметка", "button.notes": "Новая заметка",
"prompt.notes": "Название заметки", "prompt.notes": "Название заметки",

View file

@ -15,7 +15,7 @@ type AppInfo struct {
// Info contains app information. // Info contains app information.
var Info = AppInfo{ var Info = AppInfo{
Version: "1.1.3", Version: "1.1.4",
SourceLink: "https://git.a71.su/Andrew71/hibiscus", SourceLink: "https://git.a71.su/Andrew71/hibiscus",
} }

View file

@ -1,11 +1,11 @@
{{define "header"}} {{ define "header" }}
<header> <header>
<h1>{{ config.Title }}</h1> <h1>{{ config.Title }}</h1>
<p>{{translatableText "time.date"}} <span id="today-date">a place</span> <span id="grace" hidden>({{ translatableText "time.grace" }})</span></p> <p>{{ translatableText "time.date" }} <span id="today-date">a place</span> <span id="grace" hidden>({{ translatableText "time.grace" }})</span></p>
</header> </header>
{{end}} {{ end }}
{{define "base"}} {{- define "base" -}}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ translatableText "lang" }}"> <html lang="{{ translatableText "lang" }}">
<head> <head>
@ -14,16 +14,16 @@
<link rel="manifest" href="/public/manifest.json" /> <link rel="manifest" href="/public/manifest.json" />
<link rel="icon" type="image/x-icon" href="/public/favicon.ico"> <link rel="icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" href="/public/main.css"> <link rel="stylesheet" href="/public/main.css">
<link rel="stylesheet" href="/public/themes/{{ config.Theme }}.css"> {{- if config.Theme -}}<link rel="stylesheet" href="/public/themes/{{ config.Theme }}.css">{{ end }}
<script src="/public/main.js"></script> <script src="/public/main.js"></script>
<title>Hibiscus.txt</title> <title>Hibiscus.txt</title>
</head> </head>
<body> <body>
{{template "header" .}} {{- template "header" . -}}
<main> <main>
{{template "main" .}} {{- template "main" . -}}
</main> </main>
{{template "footer" .}} {{- template "footer" . -}}
<script defer> <script defer>
const langName="{{ config.Language }}"; const langName="{{ config.Language }}";
const timeZone="{{ config.Timezone }}"; const timeZone="{{ config.Timezone }}";
@ -31,11 +31,11 @@
</script> </script>
</body> </body>
</html> </html>
{{end}} {{ end }}
{{define "footer"}} {{ define "footer" }}
<footer id="footer"> <footer id="footer">
<p><a href="/">{{ translatableText "link.today" }}</a> | <a href="/day">{{ translatableText "link.days" }}</a> | <a href="/notes">{{ translatableText "link.notes" }}</a> <p><a href="/">{{ translatableText "link.today" }}</a> | <a href="/day">{{ translatableText "link.days" }}</a> | <a href="/notes">{{ translatableText "link.notes" }}</a>
<span style="float:right;"><a class="no-accent" href="/info" title="{{ translatableText "link.info" }}">v{{ info.Version }}</a></span></p> <span style="float:right;"><a class="no-accent" href="/info" title="{{ translatableText "link.info" }}">v{{ info.Version }}</a></span></p>
</footer> </footer>
{{end}} {{ end }}

View file

@ -1,7 +1,7 @@
{{define "main"}} {{ define "main" }}
<form method="POST"> <form method="POST">
<h2><label for="text">{{ .Title }}:</label></h2> <h2><label for="text">{{ .Title }}:</label></h2>
<textarea id="text" cols="40" rows="15" name="text">{{ .Content }}</textarea> <textarea id="text" cols="40" rows="15" name="text">{{ .Content }}</textarea>
<button type="submit">{{ translatableText "button.save" }}</button> <button type="submit">{{ translatableText "button.save" }}</button>
</form> </form>
{{end}} {{ end }}

View file

@ -1,4 +1,4 @@
{{define "main"}} {{ define "main" }}
<h2><label for="text">{{ .Title }}</label></h2> <h2><label for="text">{{ .Title }}</label></h2>
<textarea id="text" cols="40" rows="15" readonly>{{ .Content }}</textarea> <textarea id="text" cols="40" rows="15" readonly>{{ .Content }}</textarea>
{{end}} {{ end }}

View file

@ -1,4 +1,4 @@
{{define "main"}} {{ define "main" }}
<h2>{{ translatableText "title.info" }}</h2> <h2>{{ translatableText "title.info" }}</h2>
<ul> <ul>
<li>{{ translatableText "info.version" }} - {{ info.Version }} (<a href="{{ .SourceLink }}">{{ translatableText "info.version.link" }}</a>)</li> <li>{{ translatableText "info.version" }} - {{ info.Version }} (<a href="{{ .SourceLink }}">{{ translatableText "info.version.link" }}</a>)</li>
@ -6,4 +6,4 @@
<li><a href="/readme">{{ translatableText "info.readme" }}</a></li> <li><a href="/readme">{{ translatableText "info.readme" }}</a></li>
<li><a href="/api/export" download="hibiscus">{{ translatableText "info.export" }}</a></li> <li><a href="/api/export" download="hibiscus">{{ translatableText "info.export" }}</a></li>
</ul> </ul>
{{end}} {{ end }}

View file

@ -1,9 +1,9 @@
{{define "main"}} {{ define "main" }}
<h2 class="list-title">{{.Title}}</h2> <h2 class="list-title">{{ .Title }}</h2>
<p class="list-desc">{{.Description}}</p> <p class="list-desc">{{ .Description }}</p>
<ul> <ul>
{{range .Entries}} {{ range .Entries }}
<li><a href="/{{.Link}}">{{.Title}}</a></li> <li><a href="/{{.Link}}">{{.Title}}</a></li>
{{end}} {{ end }}
</ul> </ul>
{{end}} {{end}}

View file

@ -1 +0,0 @@
/* Default theme is defined in main.css */