diff --git a/main.go b/main.go index 85a6d89..0e6c447 100644 --- a/main.go +++ b/main.go @@ -99,6 +99,7 @@ type indexPage struct { Content template.HTML Backrefs map[string][]Backref ShowGraph bool + TodayPage string } type Node struct { @@ -131,6 +132,7 @@ type editPage struct { Editor template.HTML Backrefs map[string][]Backref ShowGraph bool + TodayPage string } type historyPage struct { @@ -449,6 +451,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Editor: editor, Name: page, Backrefs: mpPage.Refs, + TodayPage: todayPage(), ShowGraph: page != "Daily_Notes", } @@ -459,6 +462,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } err = t.Execute(w, data) if err != nil { + log.Println(err) http.Error(w, err.Error(), 500) return } @@ -651,6 +655,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Name: page, Backrefs: mpPage.Refs, ShowGraph: page != "Daily_Notes", + TodayPage: todayPage(), } t, err := template.ParseFiles("templates/layout.html", "templates/view.html") diff --git a/templates/edit.html b/templates/edit.html index fd2703d..a242528 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -1,4 +1,5 @@ {{ define "navbar" }} + Today Back {{ end }} diff --git a/templates/view.html b/templates/view.html index cc3d36e..fd1387b 100644 --- a/templates/view.html +++ b/templates/view.html @@ -37,6 +37,7 @@ History Recent Changes Graph + Today Logout {{ $.Session.Me }} {{ else }} diff --git a/util.go b/util.go index dc0bed7..306aad5 100644 --- a/util.go +++ b/util.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "fmt" "log" "math/rand" "regexp" @@ -95,3 +96,23 @@ func (sw *stopwatch) Stop() { d := endTime.Sub(sw.start) log.Printf("%-20s: %s\n", sw.label, d.String()) } + +func todayPage() string { + now := time.Now() + months := []string{ + "", + "januari", + "februari", + "maart", + "april", + "mei", + "juni", + "juli", + "augustus", + "september", + "oktober", + "november", + "december", + } + return fmt.Sprintf("%d_%s_%d", now.Day(), months[now.Month()], now.Year()) +}