Resolve today to page for current date
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6d0551d08e
commit
077d76462c
26
main.go
26
main.go
|
@ -301,9 +301,7 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
page := r.URL.Path[9:]
|
page := r.URL.Path[9:]
|
||||||
if page == "" {
|
page = resolvePageName(page)
|
||||||
page = "Home"
|
|
||||||
}
|
|
||||||
|
|
||||||
history, err := mp.PageHistory(page)
|
history, err := mp.PageHistory(page)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -411,9 +409,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
page := r.URL.Path[6:]
|
page := r.URL.Path[6:]
|
||||||
if page == "" {
|
page = resolvePageName(page)
|
||||||
page = "Home"
|
|
||||||
}
|
|
||||||
|
|
||||||
mpPage := mp.Get(page)
|
mpPage := mp.Get(page)
|
||||||
pageText := mpPage.Content
|
pageText := mpPage.Content
|
||||||
|
@ -462,7 +458,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
Editor: editor,
|
Editor: editor,
|
||||||
Name: page,
|
Name: page,
|
||||||
Backrefs: mpPage.Refs,
|
Backrefs: mpPage.Refs,
|
||||||
TodayPage: todayPage(),
|
TodayPage: "Today",
|
||||||
ShowGraph: page != "Daily_Notes",
|
ShowGraph: page != "Daily_Notes",
|
||||||
}
|
}
|
||||||
templates := baseTemplate
|
templates := baseTemplate
|
||||||
|
@ -595,9 +591,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
page := r.URL.Path[1:]
|
page := r.URL.Path[1:]
|
||||||
if page == "" {
|
page = resolvePageName(page)
|
||||||
page = "Home"
|
|
||||||
}
|
|
||||||
|
|
||||||
mpPage := mp.Get(page)
|
mpPage := mp.Get(page)
|
||||||
pageText := mpPage.Content
|
pageText := mpPage.Content
|
||||||
|
@ -676,7 +670,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
Name: page,
|
Name: page,
|
||||||
Backrefs: mpPage.Refs,
|
Backrefs: mpPage.Refs,
|
||||||
ShowGraph: page != "Daily_Notes",
|
ShowGraph: page != "Daily_Notes",
|
||||||
TodayPage: todayPage(),
|
TodayPage: "Today",
|
||||||
}
|
}
|
||||||
templates := baseTemplate
|
templates := baseTemplate
|
||||||
templates = append(templates, "templates/view.html")
|
templates = append(templates, "templates/view.html")
|
||||||
|
@ -924,3 +918,13 @@ func createSearchIndex(dataDir, indexName string) (bleve.Index, error) {
|
||||||
return searchIndex, nil
|
return searchIndex, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resolvePageName(name string) string {
|
||||||
|
if name == "" {
|
||||||
|
return "Home"
|
||||||
|
}
|
||||||
|
if name == "Today" {
|
||||||
|
return todayPage()
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user