Show dot in calendar when daily note exists
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
ad3cbe068a
commit
1e7924ef61
|
|
@ -264,6 +264,13 @@ mark {
|
||||||
|
|
||||||
padding: 3px 0 0 0;
|
padding: 3px 0 0 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
&.has-content::after {
|
||||||
|
font-weight: bold;
|
||||||
|
content: '\00B7';
|
||||||
|
display: block;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.week {
|
.week {
|
||||||
background: #ebebff;
|
background: #ebebff;
|
||||||
|
|
@ -281,9 +288,8 @@ mark {
|
||||||
}
|
}
|
||||||
.day .day-text {
|
.day .day-text {
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
text-align: right;
|
display: block;
|
||||||
float: right;
|
margin-top: 3px;
|
||||||
margin-right: 3px;
|
|
||||||
}
|
}
|
||||||
.day .day-count {
|
.day .day-count {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
@ -301,6 +307,12 @@ mark {
|
||||||
}
|
}
|
||||||
.current {
|
.current {
|
||||||
background: #f0f0f0;
|
background: #f0f0f0;
|
||||||
|
&.has-content::after {
|
||||||
|
font-weight: bold;
|
||||||
|
content: '\00B7';
|
||||||
|
display: block;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
file.go
7
file.go
|
|
@ -633,12 +633,13 @@ func saveWithGit(fp *FilePages, p string, summary, author string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fp *FilePages) Exist(p string) bool {
|
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 {
|
if err != nil {
|
||||||
return os.IsExist(err)
|
return os.IsExist(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
return false
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiffPrettyHtml(diffs []diffmatchpatch.Diff) string {
|
func DiffPrettyHtml(diffs []diffmatchpatch.Diff) string {
|
||||||
|
|
|
||||||
27
main.go
27
main.go
|
|
@ -363,7 +363,7 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pageBase := getPageBase(time.Now())
|
pageBase := getPageBase(mp, time.Now())
|
||||||
pageData := historyPage{
|
pageData := historyPage{
|
||||||
pageBaseInfo: pageBase,
|
pageBaseInfo: pageBase,
|
||||||
Session: sess,
|
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()
|
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()
|
today := time.Now()
|
||||||
|
|
||||||
var days []Day
|
var days []Day
|
||||||
|
|
@ -425,10 +425,14 @@ func prepareDays(t time.Time) []Day {
|
||||||
if timeEqual(curDate, t) {
|
if timeEqual(curDate, t) {
|
||||||
class += " current"
|
class += " current"
|
||||||
}
|
}
|
||||||
|
pageName := formatDatePageName(curDate)
|
||||||
|
if fday != "" && pageHasContent(mp, pageName) {
|
||||||
|
class += " has-content"
|
||||||
|
}
|
||||||
days = append(days, Day{
|
days = append(days, Day{
|
||||||
Class: class,
|
Class: class,
|
||||||
Text: fday,
|
Text: fday,
|
||||||
URL: fmt.Sprintf("/edit/%s", formatDatePageName(curDate)),
|
URL: fmt.Sprintf("/edit/%s", pageName),
|
||||||
Count: "",
|
Count: "",
|
||||||
})
|
})
|
||||||
if fday != "" {
|
if fday != "" {
|
||||||
|
|
@ -447,6 +451,11 @@ func prepareDays(t time.Time) []Day {
|
||||||
return days
|
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 {
|
func formatWeekPageName(year int, week int) string {
|
||||||
return fmt.Sprintf("%04dW%02d", year, week)
|
return fmt.Sprintf("%04dW%02d", year, week)
|
||||||
}
|
}
|
||||||
|
|
@ -464,13 +473,13 @@ func timeEqual(date time.Time, today time.Time) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPageBase(t time.Time) pageBaseInfo {
|
func getPageBase(repo PagesRepository, t time.Time) pageBaseInfo {
|
||||||
clientID := *baseurl
|
clientID := *baseurl
|
||||||
|
|
||||||
pageBase := pageBaseInfo{
|
pageBase := pageBaseInfo{
|
||||||
BaseURL: clientID,
|
BaseURL: clientID,
|
||||||
RedirectURI: redirectURI,
|
RedirectURI: redirectURI,
|
||||||
Days: prepareDays(t),
|
Days: prepareDays(mp, t),
|
||||||
Month: t.Month().String(),
|
Month: t.Month().String(),
|
||||||
}
|
}
|
||||||
return pageBase
|
return pageBase
|
||||||
|
|
@ -578,7 +587,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
curDate = time.Now()
|
curDate = time.Now()
|
||||||
}
|
}
|
||||||
pageBase := getPageBase(curDate)
|
pageBase := getPageBase(mp, curDate)
|
||||||
title := cleanTitle(mpPage.Title)
|
title := cleanTitle(mpPage.Title)
|
||||||
if newTitle, err := PageTitle(pageText); err == nil {
|
if newTitle, err := PageTitle(pageText); err == nil {
|
||||||
title = newTitle
|
title = newTitle
|
||||||
|
|
@ -688,7 +697,7 @@ func (h *graphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pageBase := getPageBase(time.Now())
|
pageBase := getPageBase(mp, time.Now())
|
||||||
data := graphPage{
|
data := graphPage{
|
||||||
pageBaseInfo: pageBase,
|
pageBaseInfo: pageBase,
|
||||||
Session: sess,
|
Session: sess,
|
||||||
|
|
@ -857,7 +866,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
curDate = time.Now()
|
curDate = time.Now()
|
||||||
}
|
}
|
||||||
pageBase := getPageBase(curDate)
|
pageBase := getPageBase(mp, curDate)
|
||||||
data := indexPage{
|
data := indexPage{
|
||||||
pageBaseInfo: pageBase,
|
pageBaseInfo: pageBase,
|
||||||
Session: sess,
|
Session: sess,
|
||||||
|
|
@ -971,7 +980,7 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pageBase := getPageBase(time.Now())
|
pageBase := getPageBase(mp, time.Now())
|
||||||
err = t.Execute(w, recentPage{
|
err = t.Execute(w, recentPage{
|
||||||
pageBaseInfo: pageBase,
|
pageBaseInfo: pageBase,
|
||||||
Session: sess,
|
Session: sess,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user