mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-28 16:45:32 +00:00
Added static pages
This commit is contained in:
@@ -6,8 +6,8 @@ tmp_dir = "tmp"
|
||||
args_bin = []
|
||||
bin = "./tmp/main"
|
||||
cmd = "go build -tags=\"dev\" -o ./tmp/main ."
|
||||
delay = 1000
|
||||
exclude_dir = ["assets", "views", "tmp", "vendor", "testdata", "data_git", "cache_gnd"]
|
||||
delay = 400
|
||||
exclude_dir = ["views/assets", "views/routes", "views/node_modules", "tmp", "vendor", "testdata", "data_git", "cache_gnd", "cache_geonames"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_unchanged = false
|
||||
|
||||
9
controllers/static.go
Normal file
9
controllers/static.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func Get(path string) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
return c.Render(path, nil)
|
||||
}
|
||||
}
|
||||
33
kgpz_web.go
33
kgpz_web.go
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
@@ -80,21 +79,21 @@ func Start(k *app.KGPZ, s *server.Server) {
|
||||
}()
|
||||
|
||||
// Interactive listening for input
|
||||
if k.IsDebug() {
|
||||
go func() {
|
||||
for {
|
||||
var input string
|
||||
fmt.Scanln(&input)
|
||||
if input == "r" {
|
||||
s.Restart()
|
||||
} else if input == "p" {
|
||||
k.Pull()
|
||||
} else if input == "q" {
|
||||
sigs <- os.Signal(syscall.SIGTERM)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// if k.IsDebug() {
|
||||
// go func() {
|
||||
// for {
|
||||
// var input string
|
||||
// fmt.Scanln(&input)
|
||||
// if input == "r" {
|
||||
// s.Restart()
|
||||
// } else if input == "p" {
|
||||
// k.Pull()
|
||||
// } else if input == "q" {
|
||||
// sigs <- os.Signal(syscall.SIGTERM)
|
||||
// }
|
||||
// }
|
||||
// }()
|
||||
// }
|
||||
//
|
||||
<-done
|
||||
}
|
||||
|
||||
@@ -101,14 +101,12 @@ func (s *Server) Watcher() error {
|
||||
func (s *Server) Start() {
|
||||
s.engine.Reload()
|
||||
|
||||
if s.cache != nil {
|
||||
s.cache.Close()
|
||||
if s.cache == nil {
|
||||
s.cache = memory.New(memory.Config{
|
||||
GCInterval: 30 * time.Second,
|
||||
})
|
||||
}
|
||||
|
||||
s.cache = memory.New(memory.Config{
|
||||
GCInterval: 30 * time.Second,
|
||||
})
|
||||
|
||||
srv := fiber.New(fiber.Config{
|
||||
AppName: s.Config.Address,
|
||||
CaseSensitive: false,
|
||||
@@ -165,6 +163,11 @@ func (s *Server) Start() {
|
||||
srv.Get("/:year/:issue/:page?", controllers.GetIssue(s.kgpz))
|
||||
srv.Get("/:year/:issue/beilage/:page?", controllers.GetIssue(s.kgpz))
|
||||
|
||||
srv.Get("/edition/", controllers.Get("/edition/"))
|
||||
srv.Get("/datenschutz/", controllers.Get("/datenschutz/"))
|
||||
srv.Get("/kontakt/", controllers.Get("/kontakt/"))
|
||||
srv.Get("/zitation/", controllers.Get("/zitation/"))
|
||||
|
||||
s.runner(srv)
|
||||
|
||||
if s.Config.Debug {
|
||||
@@ -228,7 +231,7 @@ func (s *Server) runner(srv *fiber.App) {
|
||||
logging.Error(err, "Error closing server cleanly. Shutting server down by force.")
|
||||
clean = false
|
||||
}
|
||||
s.cache.Close()
|
||||
s.cache.Reset()
|
||||
}
|
||||
|
||||
if !clean {
|
||||
|
||||
7
viewmodels/page.go
Normal file
7
viewmodels/page.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package viewmodels
|
||||
|
||||
type PageViewModel struct {
|
||||
Title string
|
||||
Description string
|
||||
Keywords string
|
||||
}
|
||||
@@ -45,11 +45,16 @@ func YearView(year string, lib *xmlprovider.Library) (*YearViewModel, error) {
|
||||
return nil, errors.New("No issues found for year " + year)
|
||||
}
|
||||
|
||||
res.SortAvailableYears()
|
||||
res.Sort()
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (y *YearViewModel) Sort() {
|
||||
y.SortAvailableYears()
|
||||
y.Issues.Sort()
|
||||
}
|
||||
|
||||
func (y *YearViewModel) PushIssue(i xmlprovider.Issue) {
|
||||
iv, err := FromIssue(i)
|
||||
if err != nil {
|
||||
@@ -59,6 +64,12 @@ func (y *YearViewModel) PushIssue(i xmlprovider.Issue) {
|
||||
list, ok := y.Issues[iv.Month]
|
||||
if !ok {
|
||||
list = []IssueViewModel{}
|
||||
} else {
|
||||
for _, issue := range list {
|
||||
if issue.Number.No == iv.Number.No {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
y.Issues[iv.Month] = append(list, *iv)
|
||||
@@ -84,3 +95,11 @@ func (y *YearViewModel) SortAvailableYears() {
|
||||
return iint < jint
|
||||
})
|
||||
}
|
||||
|
||||
func (ibm *IssuesByMonth) Sort() {
|
||||
for _, issues := range *ibm {
|
||||
sort.Slice(issues, func(i, j int) bool {
|
||||
return issues[i].Number.No < issues[j].Number.No
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
1
views/head.gohtml
Normal file
1
views/head.gohtml
Normal file
@@ -0,0 +1 @@
|
||||
<title>KGPZ - Ausgaben {{ .model.year }}</title>
|
||||
0
views/routes/datenschutz/body.gohtml
Normal file
0
views/routes/datenschutz/body.gohtml
Normal file
1
views/routes/datenschutz/head.gohtml
Normal file
1
views/routes/datenschutz/head.gohtml
Normal file
@@ -0,0 +1 @@
|
||||
<title>KGPZ - Impressum & Datenschutz</title>
|
||||
0
views/routes/edition/body.gohtml
Normal file
0
views/routes/edition/body.gohtml
Normal file
1
views/routes/edition/head.gohtml
Normal file
1
views/routes/edition/head.gohtml
Normal file
@@ -0,0 +1 @@
|
||||
<title>KGPZ - Geschichte & Edition</title>
|
||||
@@ -1,11 +1,10 @@
|
||||
{{ $model := .model }}
|
||||
<div>
|
||||
<a href="/{{- $model.Year -}}" aria-current="page">
|
||||
<a href="/{{- $model.Year -}}">
|
||||
Zurück zum Jahr
|
||||
{{ $model.Year }}
|
||||
</a>
|
||||
</div>
|
||||
Issue found!
|
||||
{{ $page := 0 }}
|
||||
{{ range $piece := .model.Pieces.IssuePieces }}
|
||||
<div>
|
||||
@@ -14,7 +13,7 @@ Issue found!
|
||||
<div>S. {{ $page }}</div>
|
||||
{{ end }}
|
||||
|
||||
Piece!
|
||||
Eintrag!
|
||||
{{ if gt (len $piece.IssueRefs) 1 }}
|
||||
{{ len $piece.IssueRefs }} Teile
|
||||
<ol>
|
||||
|
||||
1
views/routes/issue/head.gohtml
Normal file
1
views/routes/issue/head.gohtml
Normal file
@@ -0,0 +1 @@
|
||||
<title>KGPZ - Ausgabe {{ .model.Year }}&verythinsp;/&verythinsp;{{ .model.No }}</title>
|
||||
0
views/routes/kontakt/body.gotmpl
Normal file
0
views/routes/kontakt/body.gotmpl
Normal file
1
views/routes/kontakt/head.gohtml
Normal file
1
views/routes/kontakt/head.gohtml
Normal file
@@ -0,0 +1 @@
|
||||
<title>KGPZ - Kontakt</title>
|
||||
0
views/routes/zitation/body.gohtml
Normal file
0
views/routes/zitation/body.gohtml
Normal file
1
views/routes/zitation/head.gohtml
Normal file
1
views/routes/zitation/head.gohtml
Normal file
@@ -0,0 +1 @@
|
||||
<title>KGPZ - Zitation</title>
|
||||
Reference in New Issue
Block a user