Skip to content

Commit

Permalink
Make a better recent changes page
Browse files Browse the repository at this point in the history
  • Loading branch information
bouncepaw committed Nov 4, 2020
1 parent 7a0e9eb commit 1fbbf81
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 71 deletions.
10 changes: 5 additions & 5 deletions history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (rev Revision) HyphaeLinks() (html string) {
if len(set) > 1 {
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)
}
}
}
Expand All @@ -77,10 +77,10 @@ func (rev Revision) HyphaeLinks() (html string) {

func (rev Revision) RecentChangesEntry() (html string) {
return fmt.Sprintf(`
<li><time>%s</time></li>
<li>%s</li>
<li>%s</li>
<li>%s</li>
<li class="rc-entry__time"><time>%s</time></li>
<li class="rc-entry__hash">%s</li>
<li class="rc-entry__links">%s</li>
<li class="rc-entry__msg">%s</li>
`, rev.TimeString(), rev.Hash, rev.HyphaeLinks(), rev.Message)
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion markup/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions templates/css.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
31 changes: 18 additions & 13 deletions templates/css.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion templates/recent_changes.qtpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% func RecentChangesHTML(changes []string, n int) %}
<main class="recent-changes">
<h1>Recent Changes</h1>
<p><a href="/">← Back</a></p>

<nav class="recent-changes__count">
See
Expand Down Expand Up @@ -29,7 +30,7 @@
<p>Could not find any recent changes.</p>
{% else %}
{% 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 %}">
{%s= entry %}
</ul>
Expand Down
101 changes: 51 additions & 50 deletions templates/recent_changes.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1fbbf81

Please sign in to comment.