1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 13:30:26 +00:00

Make a better recent changes page

This commit is contained in:
bouncepaw 2020-11-04 16:00:17 +05:00
parent 7a0e9ebcc9
commit 1fbbf81794
7 changed files with 83 additions and 71 deletions

View File

@ -68,7 +68,7 @@ func (rev Revision) HyphaeLinks() (html string) {
if len(set) > 1 { if len(set) > 1 {
html += `<span aria-hidden="true">, </span>` html += `<span aria-hidden="true">, </span>`
} }
html += fmt.Sprintf(`<a href="/rev/%[1]s/%[2]s">%[2]s</a>`, rev.Hash, hyphaName) html += fmt.Sprintf(`<a href="/page/%[1]s">%[1]s</a>`, hyphaName)
} }
} }
} }
@ -77,10 +77,10 @@ func (rev Revision) HyphaeLinks() (html string) {
func (rev Revision) RecentChangesEntry() (html string) { func (rev Revision) RecentChangesEntry() (html string) {
return fmt.Sprintf(` return fmt.Sprintf(`
<li><time>%s</time></li> <li class="rc-entry__time"><time>%s</time></li>
<li>%s</li> <li class="rc-entry__hash">%s</li>
<li>%s</li> <li class="rc-entry__links">%s</li>
<li>%s</li> <li class="rc-entry__msg">%s</li>
`, rev.TimeString(), rev.Hash, rev.HyphaeLinks(), rev.Message) `, rev.TimeString(), rev.Hash, rev.HyphaeLinks(), rev.Message)
} }

View File

@ -92,7 +92,7 @@ func handlerRecentChanges(w http.ResponseWriter, rq *http.Request) {
noPrefix = strings.TrimPrefix(rq.URL.String(), "/recent-changes/") noPrefix = strings.TrimPrefix(rq.URL.String(), "/recent-changes/")
n, err = strconv.Atoi(noPrefix) 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))) util.HTTP200Page(w, base(strconv.Itoa(n)+" recent changes", history.RecentChanges(n)))
} else { } else {
http.Redirect(w, rq, "/recent-changes/20", http.StatusSeeOther) http.Redirect(w, rq, "/recent-changes/20", http.StatusSeeOther)

View File

@ -67,7 +67,7 @@ func wikilink(src string, state *GemLexerState) (href, text, class string) {
case strings.ContainsRune(href, ':'): case strings.ContainsRune(href, ':'):
class = "wikilink_external" class = "wikilink_external"
default: default:
if !HyphaExists(href) { if !HyphaExists(canonicalName(href)) {
class += " wikilink_new" class += " wikilink_new"
} }
href = path.Join("/page", href) href = path.Join("/page", href)

View File

@ -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;} nav ul li {list-style-type:none;margin-right:1rem;}
#new-name {width:100%;} #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 %} {% endfunc %}

View File

@ -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;} nav ul li {list-style-type:none;margin-right:1rem;}
#new-name {width:100%;} #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) { func WriteDefaultCSS(qq422016 qtio422016.Writer) {
//line templates/css.qtpl:43 //line templates/css.qtpl:48
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/css.qtpl:43 //line templates/css.qtpl:48
StreamDefaultCSS(qw422016) StreamDefaultCSS(qw422016)
//line templates/css.qtpl:43 //line templates/css.qtpl:48
qt422016.ReleaseWriter(qw422016) 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 { func DefaultCSS() string {
//line templates/css.qtpl:43 //line templates/css.qtpl:48
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/css.qtpl:43 //line templates/css.qtpl:48
WriteDefaultCSS(qb422016) WriteDefaultCSS(qb422016)
//line templates/css.qtpl:43 //line templates/css.qtpl:48
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/css.qtpl:43 //line templates/css.qtpl:48
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/css.qtpl:43 //line templates/css.qtpl:48
return qs422016 return qs422016
//line templates/css.qtpl:43 //line templates/css.qtpl:48
} }

View File

@ -1,6 +1,7 @@
{% func RecentChangesHTML(changes []string, n int) %} {% func RecentChangesHTML(changes []string, n int) %}
<main class="recent-changes"> <main class="recent-changes">
<h1>Recent Changes</h1> <h1>Recent Changes</h1>
<p><a href="/">← Back</a></p>
<nav class="recent-changes__count"> <nav class="recent-changes__count">
See See
@ -29,7 +30,7 @@
<p>Could not find any recent changes.</p> <p>Could not find any recent changes.</p>
{% else %} {% else %}
{% for i, entry := range changes %} {% for i, entry := range changes %}
<ul class="recent-changes__entry" role="article" <ul class="recent-changes__entry rc-entry" role="article"
aria-setsize="{%d n %}" aria-posinset="{%d i %}"> aria-setsize="{%d n %}" aria-posinset="{%d i %}">
{%s= entry %} {%s= entry %}
</ul> </ul>

View File

@ -23,134 +23,135 @@ func StreamRecentChangesHTML(qw422016 *qt422016.Writer, changes []string, n int)
qw422016.N().S(` qw422016.N().S(`
<main class="recent-changes"> <main class="recent-changes">
<h1>Recent Changes</h1> <h1>Recent Changes</h1>
<p><a href="/"> Back</a></p>
<nav class="recent-changes__count"> <nav class="recent-changes__count">
See See
`) `)
//line templates/recent_changes.qtpl:7 //line templates/recent_changes.qtpl:8
for _, m := range []int{20, 0, 50, 0, 100} { for _, m := range []int{20, 0, 50, 0, 100} {
//line templates/recent_changes.qtpl:7 //line templates/recent_changes.qtpl:8
qw422016.N().S(` qw422016.N().S(`
`) `)
//line templates/recent_changes.qtpl:8 //line templates/recent_changes.qtpl:9
switch m { switch m {
//line templates/recent_changes.qtpl:9 //line templates/recent_changes.qtpl:10
case 0: case 0:
//line templates/recent_changes.qtpl:9 //line templates/recent_changes.qtpl:10
qw422016.N().S(` qw422016.N().S(`
<span aria-hidden="true">|</span> <span aria-hidden="true">|</span>
`) `)
//line templates/recent_changes.qtpl:11 //line templates/recent_changes.qtpl:12
case n: case n:
//line templates/recent_changes.qtpl:11 //line templates/recent_changes.qtpl:12
qw422016.N().S(` qw422016.N().S(`
<b>`) <b>`)
//line templates/recent_changes.qtpl:12 //line templates/recent_changes.qtpl:13
qw422016.N().D(n) qw422016.N().D(n)
//line templates/recent_changes.qtpl:12 //line templates/recent_changes.qtpl:13
qw422016.N().S(`</b> qw422016.N().S(`</b>
`) `)
//line templates/recent_changes.qtpl:13 //line templates/recent_changes.qtpl:14
default: default:
//line templates/recent_changes.qtpl:13 //line templates/recent_changes.qtpl:14
qw422016.N().S(` qw422016.N().S(`
<a href="/recent-changes/`) <a href="/recent-changes/`)
//line templates/recent_changes.qtpl:14 //line templates/recent_changes.qtpl:15
qw422016.N().D(m) qw422016.N().D(m)
//line templates/recent_changes.qtpl:14 //line templates/recent_changes.qtpl:15
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line templates/recent_changes.qtpl:14 //line templates/recent_changes.qtpl:15
qw422016.N().D(m) qw422016.N().D(m)
//line templates/recent_changes.qtpl:14 //line templates/recent_changes.qtpl:15
qw422016.N().S(`</a> qw422016.N().S(`</a>
`) `)
//line templates/recent_changes.qtpl:15 //line templates/recent_changes.qtpl:16
} }
//line templates/recent_changes.qtpl:15 //line templates/recent_changes.qtpl:16
qw422016.N().S(` qw422016.N().S(`
`) `)
//line templates/recent_changes.qtpl:16 //line templates/recent_changes.qtpl:17
} }
//line templates/recent_changes.qtpl:16 //line templates/recent_changes.qtpl:17
qw422016.N().S(` qw422016.N().S(`
recent changes recent changes
</nav> </nav>
`) `)
//line templates/recent_changes.qtpl:25 //line templates/recent_changes.qtpl:26
qw422016.N().S(` qw422016.N().S(`
<section class="recent-changes__list" role="feed"> <section class="recent-changes__list" role="feed">
`) `)
//line templates/recent_changes.qtpl:28 //line templates/recent_changes.qtpl:29
if len(changes) == 0 { if len(changes) == 0 {
//line templates/recent_changes.qtpl:28 //line templates/recent_changes.qtpl:29
qw422016.N().S(` qw422016.N().S(`
<p>Could not find any recent changes.</p> <p>Could not find any recent changes.</p>
`) `)
//line templates/recent_changes.qtpl:30 //line templates/recent_changes.qtpl:31
} else { } else {
//line templates/recent_changes.qtpl:30 //line templates/recent_changes.qtpl:31
qw422016.N().S(` qw422016.N().S(`
`) `)
//line templates/recent_changes.qtpl:31 //line templates/recent_changes.qtpl:32
for i, entry := range changes { for i, entry := range changes {
//line templates/recent_changes.qtpl:31 //line templates/recent_changes.qtpl:32
qw422016.N().S(` qw422016.N().S(`
<ul class="recent-changes__entry" role="article" <ul class="recent-changes__entry rc-entry" role="article"
aria-setsize="`) aria-setsize="`)
//line templates/recent_changes.qtpl:33 //line templates/recent_changes.qtpl:34
qw422016.N().D(n) qw422016.N().D(n)
//line templates/recent_changes.qtpl:33 //line templates/recent_changes.qtpl:34
qw422016.N().S(`" aria-posinset="`) qw422016.N().S(`" aria-posinset="`)
//line templates/recent_changes.qtpl:33 //line templates/recent_changes.qtpl:34
qw422016.N().D(i) qw422016.N().D(i)
//line templates/recent_changes.qtpl:33 //line templates/recent_changes.qtpl:34
qw422016.N().S(`"> qw422016.N().S(`">
`) `)
//line templates/recent_changes.qtpl:34 //line templates/recent_changes.qtpl:35
qw422016.N().S(entry) qw422016.N().S(entry)
//line templates/recent_changes.qtpl:34 //line templates/recent_changes.qtpl:35
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
`) `)
//line templates/recent_changes.qtpl:36 //line templates/recent_changes.qtpl:37
} }
//line templates/recent_changes.qtpl:36 //line templates/recent_changes.qtpl:37
qw422016.N().S(` qw422016.N().S(`
`) `)
//line templates/recent_changes.qtpl:37 //line templates/recent_changes.qtpl:38
} }
//line templates/recent_changes.qtpl:37 //line templates/recent_changes.qtpl:38
qw422016.N().S(` qw422016.N().S(`
</section> </section>
</main> </main>
`) `)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
} }
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
func WriteRecentChangesHTML(qq422016 qtio422016.Writer, changes []string, n int) { func WriteRecentChangesHTML(qq422016 qtio422016.Writer, changes []string, n int) {
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
StreamRecentChangesHTML(qw422016, changes, n) StreamRecentChangesHTML(qw422016, changes, n)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
} }
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
func RecentChangesHTML(changes []string, n int) string { func RecentChangesHTML(changes []string, n int) string {
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
WriteRecentChangesHTML(qb422016, changes, n) WriteRecentChangesHTML(qb422016, changes, n)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
return qs422016 return qs422016
//line templates/recent_changes.qtpl:40 //line templates/recent_changes.qtpl:41
} }