Show dot in calendar when daily note exists
continuous-integration/drone/push Build is passing Details

single-block-api
Peter Stuifzand 3 years ago
parent ad3cbe068a
commit 1e7924ef61

@ -264,6 +264,13 @@ mark {
padding: 3px 0 0 0;
position: relative;
&.has-content::after {
font-weight: bold;
content: '\00B7';
display: block;
margin-top: 6px;
}
}
.week {
background: #ebebff;
@ -281,9 +288,8 @@ mark {
}
.day .day-text {
font-size: 9pt;
text-align: right;
float: right;
margin-right: 3px;
display: block;
margin-top: 3px;
}
.day .day-count {
position: absolute;
@ -301,6 +307,12 @@ mark {
}
.current {
background: #f0f0f0;
&.has-content::after {
font-weight: bold;
content: '\00B7';
display: block;
margin-top: 6px;
}
}
}

@ -633,12 +633,13 @@ func saveWithGit(fp *FilePages, p string, summary, author string) error {
}
func (fp *FilePages) Exist(p string) bool {
f, err := os.Open(filepath.Join(fp.dirname, strings.Replace(p, " ", "_", -1)))
pageName := filepath.Join(fp.dirname, strings.Replace(p, " ", "_", -1))
log.Printf("Exist? %s\n", pageName)
_, err := os.Stat(pageName)
if err != nil {
return os.IsExist(err)
}
f.Close()
return true
return false
}
func DiffPrettyHtml(diffs []diffmatchpatch.Diff) string {

@ -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,

Loading…
Cancel
Save