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:
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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user