Compare commits

..

No commits in common. "1e7924ef617dd5666e9acc323f236f851052b8c2" and "a4a9a5ca7a0ebcb80137a76c6ade117c3fb842c4" have entirely different histories.

3 changed files with 18 additions and 40 deletions

View File

@ -246,15 +246,15 @@ mark {
.calendar-grid {
display: grid;
width: 257px;
width: calc(8*48px);
grid-template-columns: repeat(8, auto);
border-right: 1px solid #444;
border-bottom: 1px solid #444;
.day {
width: 32px;
height: 32px;
width: 48px;
height: 48px;
border-left: 1px solid #444;
border-top: 1px solid #444;
@ -264,13 +264,6 @@ mark {
padding: 3px 0 0 0;
position: relative;
&.has-content::after {
font-weight: bold;
content: '\00B7';
display: block;
margin-top: 6px;
}
}
.week {
background: #ebebff;
@ -288,8 +281,9 @@ mark {
}
.day .day-text {
font-size: 9pt;
display: block;
margin-top: 3px;
text-align: right;
float: right;
margin-right: 3px;
}
.day .day-count {
position: absolute;
@ -307,12 +301,6 @@ mark {
}
.current {
background: #f0f0f0;
&.has-content::after {
font-weight: bold;
content: '\00B7';
display: block;
margin-top: 6px;
}
}
}

View File

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

27
main.go
View File

@ -363,7 +363,7 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
pageBase := getPageBase(mp, time.Now())
pageBase := getPageBase(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(repo PagesRepository, t time.Time) []Day {
func prepareDays(t time.Time) []Day {
today := time.Now()
var days []Day
@ -425,14 +425,10 @@ func prepareDays(repo PagesRepository, 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", pageName),
URL: fmt.Sprintf("/edit/%s", formatDatePageName(curDate)),
Count: "",
})
if fday != "" {
@ -451,11 +447,6 @@ func prepareDays(repo PagesRepository, 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)
}
@ -473,13 +464,13 @@ func timeEqual(date time.Time, today time.Time) bool {
return true
}
func getPageBase(repo PagesRepository, t time.Time) pageBaseInfo {
func getPageBase(t time.Time) pageBaseInfo {
clientID := *baseurl
pageBase := pageBaseInfo{
BaseURL: clientID,
RedirectURI: redirectURI,
Days: prepareDays(mp, t),
Days: prepareDays(t),
Month: t.Month().String(),
}
return pageBase
@ -587,7 +578,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err != nil {
curDate = time.Now()
}
pageBase := getPageBase(mp, curDate)
pageBase := getPageBase(curDate)
title := cleanTitle(mpPage.Title)
if newTitle, err := PageTitle(pageText); err == nil {
title = newTitle
@ -697,7 +688,7 @@ func (h *graphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
pageBase := getPageBase(mp, time.Now())
pageBase := getPageBase(time.Now())
data := graphPage{
pageBaseInfo: pageBase,
Session: sess,
@ -866,7 +857,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err != nil {
curDate = time.Now()
}
pageBase := getPageBase(mp, curDate)
pageBase := getPageBase(curDate)
data := indexPage{
pageBaseInfo: pageBase,
Session: sess,
@ -980,7 +971,7 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
pageBase := getPageBase(mp, time.Now())
pageBase := getPageBase(time.Now())
err = t.Execute(w, recentPage{
pageBaseInfo: pageBase,
Session: sess,