|
|
|
@ -363,7 +363,7 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageBase := getPageBase(time.Now())
|
|
|
|
|
pageBase := getPageBase(mp, time.Now())
|
|
|
|
|
pageData := historyPage{
|
|
|
|
|
pageBaseInfo: pageBase,
|
|
|
|
|
Session: sess,
|
|
|
|
@ -383,7 +383,7 @@ func daysInMonth(year int, month time.Month) int {
|
|
|
|
|
return time.Date(year, month, 1, 0, 0, 0, 0, time.UTC).AddDate(0, 1, -1).Day()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func prepareDays(t time.Time) []Day {
|
|
|
|
|
func prepareDays(repo PagesRepository, t time.Time) []Day {
|
|
|
|
|
today := time.Now()
|
|
|
|
|
|
|
|
|
|
var days []Day
|
|
|
|
@ -425,10 +425,14 @@ func prepareDays(t time.Time) []Day {
|
|
|
|
|
if timeEqual(curDate, t) {
|
|
|
|
|
class += " current"
|
|
|
|
|
}
|
|
|
|
|
pageName := formatDatePageName(curDate)
|
|
|
|
|
if fday != "" && pageHasContent(mp, pageName) {
|
|
|
|
|
class += " has-content"
|
|
|
|
|
}
|
|
|
|
|
days = append(days, Day{
|
|
|
|
|
Class: class,
|
|
|
|
|
Text: fday,
|
|
|
|
|
URL: fmt.Sprintf("/edit/%s", formatDatePageName(curDate)),
|
|
|
|
|
URL: fmt.Sprintf("/edit/%s", pageName),
|
|
|
|
|
Count: "",
|
|
|
|
|
})
|
|
|
|
|
if fday != "" {
|
|
|
|
@ -447,6 +451,11 @@ func prepareDays(t time.Time) []Day {
|
|
|
|
|
return days
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func pageHasContent(repo PagesRepository, day string) bool {
|
|
|
|
|
page := repo.Get(day)
|
|
|
|
|
return page.Blocks.Children != nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func formatWeekPageName(year int, week int) string {
|
|
|
|
|
return fmt.Sprintf("%04dW%02d", year, week)
|
|
|
|
|
}
|
|
|
|
@ -464,13 +473,13 @@ func timeEqual(date time.Time, today time.Time) bool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getPageBase(t time.Time) pageBaseInfo {
|
|
|
|
|
func getPageBase(repo PagesRepository, t time.Time) pageBaseInfo {
|
|
|
|
|
clientID := *baseurl
|
|
|
|
|
|
|
|
|
|
pageBase := pageBaseInfo{
|
|
|
|
|
BaseURL: clientID,
|
|
|
|
|
RedirectURI: redirectURI,
|
|
|
|
|
Days: prepareDays(t),
|
|
|
|
|
Days: prepareDays(mp, t),
|
|
|
|
|
Month: t.Month().String(),
|
|
|
|
|
}
|
|
|
|
|
return pageBase
|
|
|
|
@ -578,7 +587,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
curDate = time.Now()
|
|
|
|
|
}
|
|
|
|
|
pageBase := getPageBase(curDate)
|
|
|
|
|
pageBase := getPageBase(mp, curDate)
|
|
|
|
|
title := cleanTitle(mpPage.Title)
|
|
|
|
|
if newTitle, err := PageTitle(pageText); err == nil {
|
|
|
|
|
title = newTitle
|
|
|
|
@ -688,7 +697,7 @@ func (h *graphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageBase := getPageBase(time.Now())
|
|
|
|
|
pageBase := getPageBase(mp, time.Now())
|
|
|
|
|
data := graphPage{
|
|
|
|
|
pageBaseInfo: pageBase,
|
|
|
|
|
Session: sess,
|
|
|
|
@ -857,7 +866,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
curDate = time.Now()
|
|
|
|
|
}
|
|
|
|
|
pageBase := getPageBase(curDate)
|
|
|
|
|
pageBase := getPageBase(mp, curDate)
|
|
|
|
|
data := indexPage{
|
|
|
|
|
pageBaseInfo: pageBase,
|
|
|
|
|
Session: sess,
|
|
|
|
@ -971,7 +980,7 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageBase := getPageBase(time.Now())
|
|
|
|
|
pageBase := getPageBase(mp, time.Now())
|
|
|
|
|
err = t.Execute(w, recentPage{
|
|
|
|
|
pageBaseInfo: pageBase,
|
|
|
|
|
Session: sess,
|
|
|
|
|