Added a footer, added the main title to the home page, minor improvements

This commit is contained in:
ChaoticByte 2024-08-29 13:10:23 +02:00
parent 1aa58ac243
commit b86b1688ea
No known key found for this signature in database
6 changed files with 40 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Before After
Before After

View file

@ -20,6 +20,7 @@ type TemplateData struct {
Entry string Entry string
Title string Title string
EntryTitle string EntryTitle string
Footer []template.HTML
} }
func loadTemplate() { func loadTemplate() {
@ -41,7 +42,7 @@ func handleApplication(w http.ResponseWriter, req *http.Request) {
} }
err = appTemplate.ExecuteTemplate( err = appTemplate.ExecuteTemplate(
w, "app", w, "app",
TemplateData{TOC: db.Keys, Entry: entry, Title: MainTitle, EntryTitle: entryName}) TemplateData{TOC: db.Keys, Entry: entry, Title: MainTitle, EntryTitle: entryName, Footer: FooterContent})
if err != nil { logger.Println(err) } if err != nil { logger.Println(err) }
} }

View file

@ -19,6 +19,7 @@
</div> </div>
{{- else -}} {{- else -}}
<div class="home-main"> <div class="home-main">
<h1>{{ .Title }}</h1>
<input type="text" id="search-box" placeholder="search"> <input type="text" id="search-box" placeholder="search">
<div id="search-results" class="hidden"></div> <div id="search-results" class="hidden"></div>
<div class="toc" id="toc"> <div class="toc" id="toc">
@ -29,5 +30,6 @@
</div> </div>
<script src="/static/search.js"></script> <script src="/static/search.js"></script>
{{- end}} {{- end}}
<footer>{{ range .Footer }}<div>{{ . }}</div>{{ end }}</footer>
</body> </body>
</html> </html>

View file

@ -6,6 +6,7 @@ body {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
width: 100vw; width: 100vw;
min-height: 100vh;
font-family: sans-serif; font-family: sans-serif;
} }
a:hover, a:focus { text-decoration: underline; } a:hover, a:focus { text-decoration: underline; }
@ -14,6 +15,22 @@ a {
text-decoration: none; text-decoration: none;
outline: none; outline: none;
} }
footer {
margin-top: auto;
padding: 1rem;
box-sizing: border-box;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
footer > div {
margin: 0 .5rem;
}
footer, footer * {
color: #00000080 !important;
font-size: .9rem;
text-align: center;
}
.homebtn { .homebtn {
position: absolute; position: absolute;
@ -33,7 +50,8 @@ a {
} }
.main > h1 { .main > h1 {
font-size: 1.4rem; font-size: 1.4rem;
margin-bottom: 0; margin-top: 1.5rem;
margin-bottom: .5rem;
text-align: center; text-align: center;
} }
.content { white-space: pre-line; } .content { white-space: pre-line; }
@ -44,6 +62,9 @@ a {
box-sizing: border-box; box-sizing: border-box;
gap: 1rem; gap: 1rem;
} }
.home-main > h1 {
font-size: 1.6rem;
}
.home-main, .toc, #search-results { .home-main, .toc, #search-results {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -66,6 +87,9 @@ a {
@media only screen and (max-width: 750px) { @media only screen and (max-width: 750px) {
.main { margin-top: 4rem; } .main { margin-top: 4rem; }
.main > h1 {
margin-top: unset;
}
.main > h1, .content { .main > h1, .content {
width: 90vw; width: 90vw;
max-width: unset; max-width: unset;

View file

@ -1,10 +1,19 @@
package main package main
import "golang.org/x/text/language" import (
"html/template"
"golang.org/x/text/language"
)
const ServerListen = ":7000" const ServerListen = ":7000"
const EntriesDirectory = "./entries" const EntriesDirectory = "./entries"
const TemplateFile = "./public/index.html" const TemplateFile = "./public/index.html"
const StaticDirectory = "./public/static" const StaticDirectory = "./public/static"
const MainTitle = "Encyclopedia"
var ContentLanguage = language.English var ContentLanguage = language.English
const MainTitle = "Encyclopedia"
var FooterContent = []template.HTML{
template.HTML("powered by <a href='https://github.com/ChaoticByte/plaintext-encyclopedia' target='_blank' rel='noopener noreferrer'>plaintext-encyclopedia</a>"),
}