From 1fbbf81794e9b35508abef365e1a3e5153a2ecfe Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Wed, 4 Nov 2020 16:00:17 +0500 Subject: [PATCH] Make a better recent changes page --- history/history.go | 10 +-- main.go | 2 +- markup/lexer.go | 2 +- templates/css.qtpl | 5 ++ templates/css.qtpl.go | 31 ++++++---- templates/recent_changes.qtpl | 3 +- templates/recent_changes.qtpl.go | 101 ++++++++++++++++--------------- 7 files changed, 83 insertions(+), 71 deletions(-) diff --git a/history/history.go b/history/history.go index e1c747b..ec409c2 100644 --- a/history/history.go +++ b/history/history.go @@ -68,7 +68,7 @@ func (rev Revision) HyphaeLinks() (html string) { if len(set) > 1 { html += `` } - html += fmt.Sprintf(`%[2]s`, rev.Hash, hyphaName) + html += fmt.Sprintf(`%[1]s`, hyphaName) } } } @@ -77,10 +77,10 @@ func (rev Revision) HyphaeLinks() (html string) { func (rev Revision) RecentChangesEntry() (html string) { return fmt.Sprintf(` -
  • -
  • %s
  • -
  • %s
  • -
  • %s
  • +
  • +
  • %s
  • +
  • %s
  • +
  • %s
  • `, rev.TimeString(), rev.Hash, rev.HyphaeLinks(), rev.Message) } diff --git a/main.go b/main.go index 422bc8b..0f63208 100644 --- a/main.go +++ b/main.go @@ -92,7 +92,7 @@ func handlerRecentChanges(w http.ResponseWriter, rq *http.Request) { noPrefix = strings.TrimPrefix(rq.URL.String(), "/recent-changes/") n, err = strconv.Atoi(noPrefix) ) - if err == nil { + if err == nil && n < 101 { util.HTTP200Page(w, base(strconv.Itoa(n)+" recent changes", history.RecentChanges(n))) } else { http.Redirect(w, rq, "/recent-changes/20", http.StatusSeeOther) diff --git a/markup/lexer.go b/markup/lexer.go index d2002b0..b29b7fc 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -67,7 +67,7 @@ func wikilink(src string, state *GemLexerState) (href, text, class string) { case strings.ContainsRune(href, ':'): class = "wikilink_external" default: - if !HyphaExists(href) { + if !HyphaExists(canonicalName(href)) { class += " wikilink_new" } href = path.Join("/page", href) diff --git a/templates/css.qtpl b/templates/css.qtpl index c66fe91..55e86d6 100644 --- a/templates/css.qtpl +++ b/templates/css.qtpl @@ -40,4 +40,9 @@ nav ul {display:flex; padding-left:0; flex-wrap:wrap; margin-top:0;} nav ul li {list-style-type:none;margin-right:1rem;} #new-name {width:100%;} + +.rc-entry { display: grid; list-style-type: none; padding: .25rem; background-color: #eee; grid-template-columns: 1fr 1fr; } +.rc-entry__time { font-style: italic; } +.rc-entry__hash { font-style: italic; text-align: right; } +.rc-entry__links { grid-column: 1 / span 2; } {% endfunc %} diff --git a/templates/css.qtpl.go b/templates/css.qtpl.go index 17f118f..09519d7 100644 --- a/templates/css.qtpl.go +++ b/templates/css.qtpl.go @@ -62,32 +62,37 @@ nav ul {display:flex; padding-left:0; flex-wrap:wrap; margin-top:0;} nav ul li {list-style-type:none;margin-right:1rem;} #new-name {width:100%;} + +.rc-entry { display: grid; list-style-type: none; padding: .25rem; background-color: #eee; grid-template-columns: 1fr 1fr; } +.rc-entry__time { font-style: italic; } +.rc-entry__hash { font-style: italic; text-align: right; } +.rc-entry__links { grid-column: 1 / span 2; } `) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 } -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 func WriteDefaultCSS(qq422016 qtio422016.Writer) { -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 StreamDefaultCSS(qw422016) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 qt422016.ReleaseWriter(qw422016) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 } -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 func DefaultCSS() string { -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 qb422016 := qt422016.AcquireByteBuffer() -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 WriteDefaultCSS(qb422016) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 qs422016 := string(qb422016.B) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 qt422016.ReleaseByteBuffer(qb422016) -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 return qs422016 -//line templates/css.qtpl:43 +//line templates/css.qtpl:48 } diff --git a/templates/recent_changes.qtpl b/templates/recent_changes.qtpl index 2f9f8c4..738f39a 100644 --- a/templates/recent_changes.qtpl +++ b/templates/recent_changes.qtpl @@ -1,6 +1,7 @@ {% func RecentChangesHTML(changes []string, n int) %}

    Recent Changes

    +

    ← Back