diff --git a/history/history.go b/history/history.go index f3d117d..d02e156 100644 --- a/history/history.go +++ b/history/history.go @@ -10,7 +10,6 @@ import ( "strings" "time" - "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" ) @@ -77,8 +76,8 @@ func (rev Revision) TimeString() string { return rev.Time.Format(time.RFC822) } -// HyphaeLinks returns a comma-separated list of hyphae that were affected by this revision as HTML string. -func (rev Revision) HyphaeLinks() (html string) { +// HyphaeLinksHTML returns a comma-separated list of hyphae that were affected by this revision as HTML string. +func (rev Revision) HyphaeLinksHTML() (html string) { hyphae := rev.hyphaeAffected() for i, hyphaName := range hyphae { if i > 0 { @@ -92,7 +91,7 @@ func (rev Revision) HyphaeLinks() (html string) { func (rev *Revision) descriptionForFeed() (html string) { return fmt.Sprintf( `

%s

-

Hyphae affected: %s

`, rev.Message, rev.HyphaeLinks()) +

Hyphae affected: %s

`, rev.Message, rev.HyphaeLinksHTML()) } // Try and guess what link is the most important by looking at the message. @@ -111,23 +110,6 @@ func (rev *Revision) bestLink() string { } } -func (rev Revision) RecentChangesEntry() (html string) { - if user.AuthUsed && rev.Username != "anon" { - return fmt.Sprintf(` -
  • -
  • %[2]s
  • -
  • %[5]s
  • -
  • %[6]s by
  • -`, rev.TimeString(), rev.Hash, util.UserHypha, rev.Username, rev.HyphaeLinks(), rev.Message) - } - return fmt.Sprintf(` -
  • -
  • %[2]s
  • -
  • %[3]s
  • -
  • %[4]s
  • -`, rev.TimeString(), rev.Hash, rev.HyphaeLinks(), rev.Message) -} - // Path to git executable. Set at init() var gitpath string diff --git a/history/information.go b/history/information.go index 6610917..f3cf8a7 100644 --- a/history/information.go +++ b/history/information.go @@ -9,7 +9,6 @@ import ( "strings" "time" - "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/util" "github.com/gorilla/feeds" ) @@ -61,7 +60,7 @@ func RecentChangesJSON() (string, error) { return recentChangesFeed().ToJSON() } -func RecentChanges(n int) string { +func RecentChanges(n int) []Revision { var ( out, err = gitsh( "log", "--oneline", "--no-merges", @@ -75,11 +74,7 @@ func RecentChanges(n int) string { revs = append(revs, parseRevisionLine(line)) } } - entries := make([]string, len(revs)) - for i, rev := range revs { - entries[i] = rev.RecentChangesEntry() - } - return templates.RecentChangesHTML(entries, n) + return revs } // FileChanged tells you if the file has been changed. diff --git a/http_history.go b/http_history.go index a952682..110ca3a 100644 --- a/http_history.go +++ b/http_history.go @@ -46,7 +46,7 @@ func handlerRecentChanges(w http.ResponseWriter, rq *http.Request) { n, err = strconv.Atoi(noPrefix) ) if err == nil && n < 101 { - util.HTTP200Page(w, base(strconv.Itoa(n)+" recent changes", history.RecentChanges(n), user.FromRequest(rq))) + util.HTTP200Page(w, base(strconv.Itoa(n)+" recent changes", views.RecentChangesHTML(n), user.FromRequest(rq))) } else { http.Redirect(w, rq, "/recent-changes/20", http.StatusSeeOther) } diff --git a/templates/asset.qtpl.go b/templates/asset.qtpl.go index c739b62..f88dcac 100644 --- a/templates/asset.qtpl.go +++ b/templates/asset.qtpl.go @@ -151,10 +151,10 @@ figcaption { padding-bottom: .5rem; } #new-name {width:100%;} -.rc-entry { display: grid; list-style-type: none; padding: .25rem; grid-template-columns: 1fr 1fr; } +.rc-entry { display: grid; list-style-type: none; padding: .25rem; grid-template-columns: 1fr 1fr; border-radius: .25rem; } .rc-entry__time { font-style: italic; } .rc-entry__hash { font-style: italic; text-align: right; } -.rc-entry__links { grid-column: 1 / span 2; } +.rc-entry__links, .rc-entry__msg { grid-column: 1 / span 2; } .rc-entry__author { font-style: italic; } .prevnext__el { display: block-inline; min-width: 40%; padding: .5rem; margin-bottom: .25rem; text-decoration: none; border-radius: .25rem; } diff --git a/templates/default.css b/templates/default.css index 9984be5..db31f9c 100644 --- a/templates/default.css +++ b/templates/default.css @@ -126,10 +126,10 @@ figcaption { padding-bottom: .5rem; } #new-name {width:100%;} -.rc-entry { display: grid; list-style-type: none; padding: .25rem; grid-template-columns: 1fr 1fr; } +.rc-entry { display: grid; list-style-type: none; padding: .25rem; grid-template-columns: 1fr 1fr; border-radius: .25rem; } .rc-entry__time { font-style: italic; } .rc-entry__hash { font-style: italic; text-align: right; } -.rc-entry__links { grid-column: 1 / span 2; } +.rc-entry__links, .rc-entry__msg { grid-column: 1 / span 2; } .rc-entry__author { font-style: italic; } .prevnext__el { display: block-inline; min-width: 40%; padding: .5rem; margin-bottom: .25rem; text-decoration: none; border-radius: .25rem; } diff --git a/templates/recent_changes.qtpl.go b/templates/recent_changes.qtpl.go deleted file mode 100644 index e3cc346..0000000 --- a/templates/recent_changes.qtpl.go +++ /dev/null @@ -1,161 +0,0 @@ -// Code generated by qtc from "recent_changes.qtpl". DO NOT EDIT. -// See https://github.com/valyala/quicktemplate for details. - -//line templates/recent_changes.qtpl:1 -package templates - -//line templates/recent_changes.qtpl:1 -import ( - qtio422016 "io" - - qt422016 "github.com/valyala/quicktemplate" -) - -//line templates/recent_changes.qtpl:1 -var ( - _ = qtio422016.Copy - _ = qt422016.AcquireByteBuffer -) - -//line templates/recent_changes.qtpl:1 -func StreamRecentChangesHTML(qw422016 *qt422016.Writer, changes []string, n int) { -//line templates/recent_changes.qtpl:1 - qw422016.N().S(` -
    -
    -

    Recent Changes

    -

    ← Back

    - - - -

    Subscribe via RSS, Atom or JSON feed.

    - - `) -//line templates/recent_changes.qtpl:29 - qw422016.N().S(` - -
    - `) -//line templates/recent_changes.qtpl:32 - if len(changes) == 0 { -//line templates/recent_changes.qtpl:32 - qw422016.N().S(` -

    Could not find any recent changes.

    - `) -//line templates/recent_changes.qtpl:34 - } else { -//line templates/recent_changes.qtpl:34 - qw422016.N().S(` - `) -//line templates/recent_changes.qtpl:35 - for i, entry := range changes { -//line templates/recent_changes.qtpl:35 - qw422016.N().S(` -
      - `) -//line templates/recent_changes.qtpl:38 - qw422016.N().S(entry) -//line templates/recent_changes.qtpl:38 - qw422016.N().S(` -
    - `) -//line templates/recent_changes.qtpl:40 - } -//line templates/recent_changes.qtpl:40 - qw422016.N().S(` - `) -//line templates/recent_changes.qtpl:41 - } -//line templates/recent_changes.qtpl:41 - qw422016.N().S(` -
    -
    -
    -`) -//line templates/recent_changes.qtpl:45 -} - -//line templates/recent_changes.qtpl:45 -func WriteRecentChangesHTML(qq422016 qtio422016.Writer, changes []string, n int) { -//line templates/recent_changes.qtpl:45 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/recent_changes.qtpl:45 - StreamRecentChangesHTML(qw422016, changes, n) -//line templates/recent_changes.qtpl:45 - qt422016.ReleaseWriter(qw422016) -//line templates/recent_changes.qtpl:45 -} - -//line templates/recent_changes.qtpl:45 -func RecentChangesHTML(changes []string, n int) string { -//line templates/recent_changes.qtpl:45 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/recent_changes.qtpl:45 - WriteRecentChangesHTML(qb422016, changes, n) -//line templates/recent_changes.qtpl:45 - qs422016 := string(qb422016.B) -//line templates/recent_changes.qtpl:45 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/recent_changes.qtpl:45 - return qs422016 -//line templates/recent_changes.qtpl:45 -} diff --git a/templates/recent_changes.qtpl b/views/history.qtpl similarity index 57% rename from templates/recent_changes.qtpl rename to views/history.qtpl index 9082e96..7b5b0ef 100644 --- a/templates/recent_changes.qtpl +++ b/views/history.qtpl @@ -1,4 +1,9 @@ -{% func RecentChangesHTML(changes []string, n int) %} +{% import "net/http" %} + +{% import "github.com/bouncepaw/mycorrhiza/util" %} +{% import "github.com/bouncepaw/mycorrhiza/history" %} + +{% func RecentChangesHTML(n int) %}

    Recent Changes

    @@ -28,6 +33,9 @@ How come? I'll add the role anyway. -- bouncepaw {% endcomment %} + {% code + changes := history.RecentChanges(n) + %}
    {% if len(changes) == 0 %}

    Could not find any recent changes.

    @@ -35,7 +43,7 @@ {% for i, entry := range changes %}
      - {%s= entry %} + {%s= recentChangesEntry(entry) %}
    {% endfor %} {% endif %} @@ -43,3 +51,22 @@
    {% endfunc %} + +{% func recentChangesEntry(rev history.Revision) %} +
  • +
  • {%s rev.Hash %}
  • +
  • {%s= rev.HyphaeLinksHTML() %}
  • +
  • {%s rev.Message %} {% if rev.Username != "anon" %}by {% endif %}
  • +{% endfunc %} + +{% func HistoryHTML(rq *http.Request, hyphaName, list string) %} +{%= NavHTML(rq, hyphaName, "history") %} +
    +
    +
    +

    History of {%s util.BeautifulName(hyphaName) %}

    + {%s= list %} +
    +
    +
    +{% endfunc %} diff --git a/views/history.qtpl.go b/views/history.qtpl.go new file mode 100644 index 0000000..6d81497 --- /dev/null +++ b/views/history.qtpl.go @@ -0,0 +1,305 @@ +// Code generated by qtc from "history.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +//line views/history.qtpl:1 +package views + +//line views/history.qtpl:1 +import "net/http" + +//line views/history.qtpl:3 +import "github.com/bouncepaw/mycorrhiza/util" + +//line views/history.qtpl:4 +import "github.com/bouncepaw/mycorrhiza/history" + +//line views/history.qtpl:6 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line views/history.qtpl:6 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line views/history.qtpl:6 +func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) { +//line views/history.qtpl:6 + qw422016.N().S(` +
    +
    +

    Recent Changes

    +

    ← Back

    + + + +

    Subscribe via RSS, Atom or JSON feed.

    + + `) +//line views/history.qtpl:34 + qw422016.N().S(` + + `) +//line views/history.qtpl:37 + changes := history.RecentChanges(n) + +//line views/history.qtpl:38 + qw422016.N().S(` +
    + `) +//line views/history.qtpl:40 + if len(changes) == 0 { +//line views/history.qtpl:40 + qw422016.N().S(` +

    Could not find any recent changes.

    + `) +//line views/history.qtpl:42 + } else { +//line views/history.qtpl:42 + qw422016.N().S(` + `) +//line views/history.qtpl:43 + for i, entry := range changes { +//line views/history.qtpl:43 + qw422016.N().S(` +
      + `) +//line views/history.qtpl:46 + qw422016.N().S(recentChangesEntry(entry)) +//line views/history.qtpl:46 + qw422016.N().S(` +
    + `) +//line views/history.qtpl:48 + } +//line views/history.qtpl:48 + qw422016.N().S(` + `) +//line views/history.qtpl:49 + } +//line views/history.qtpl:49 + qw422016.N().S(` +
    +
    +
    +`) +//line views/history.qtpl:53 +} + +//line views/history.qtpl:53 +func WriteRecentChangesHTML(qq422016 qtio422016.Writer, n int) { +//line views/history.qtpl:53 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/history.qtpl:53 + StreamRecentChangesHTML(qw422016, n) +//line views/history.qtpl:53 + qt422016.ReleaseWriter(qw422016) +//line views/history.qtpl:53 +} + +//line views/history.qtpl:53 +func RecentChangesHTML(n int) string { +//line views/history.qtpl:53 + qb422016 := qt422016.AcquireByteBuffer() +//line views/history.qtpl:53 + WriteRecentChangesHTML(qb422016, n) +//line views/history.qtpl:53 + qs422016 := string(qb422016.B) +//line views/history.qtpl:53 + qt422016.ReleaseByteBuffer(qb422016) +//line views/history.qtpl:53 + return qs422016 +//line views/history.qtpl:53 +} + +//line views/history.qtpl:55 +func streamrecentChangesEntry(qw422016 *qt422016.Writer, rev history.Revision) { +//line views/history.qtpl:55 + qw422016.N().S(` +
  • +
  • `) +//line views/history.qtpl:57 + qw422016.E().S(rev.Hash) +//line views/history.qtpl:57 + qw422016.N().S(`
  • +
  • `) +//line views/history.qtpl:58 + qw422016.N().S(rev.HyphaeLinksHTML()) +//line views/history.qtpl:58 + qw422016.N().S(`
  • +
  • `) +//line views/history.qtpl:59 + qw422016.E().S(rev.Message) +//line views/history.qtpl:59 + qw422016.N().S(` `) +//line views/history.qtpl:59 + if rev.Username != "anon" { +//line views/history.qtpl:59 + qw422016.N().S(`by `) +//line views/history.qtpl:59 + } +//line views/history.qtpl:59 + qw422016.N().S(`
  • +`) +//line views/history.qtpl:60 +} + +//line views/history.qtpl:60 +func writerecentChangesEntry(qq422016 qtio422016.Writer, rev history.Revision) { +//line views/history.qtpl:60 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/history.qtpl:60 + streamrecentChangesEntry(qw422016, rev) +//line views/history.qtpl:60 + qt422016.ReleaseWriter(qw422016) +//line views/history.qtpl:60 +} + +//line views/history.qtpl:60 +func recentChangesEntry(rev history.Revision) string { +//line views/history.qtpl:60 + qb422016 := qt422016.AcquireByteBuffer() +//line views/history.qtpl:60 + writerecentChangesEntry(qb422016, rev) +//line views/history.qtpl:60 + qs422016 := string(qb422016.B) +//line views/history.qtpl:60 + qt422016.ReleaseByteBuffer(qb422016) +//line views/history.qtpl:60 + return qs422016 +//line views/history.qtpl:60 +} + +//line views/history.qtpl:62 +func StreamHistoryHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, list string) { +//line views/history.qtpl:62 + qw422016.N().S(` +`) +//line views/history.qtpl:63 + StreamNavHTML(qw422016, rq, hyphaName, "history") +//line views/history.qtpl:63 + qw422016.N().S(` +
    +
    +
    +

    History of `) +//line views/history.qtpl:67 + qw422016.E().S(util.BeautifulName(hyphaName)) +//line views/history.qtpl:67 + qw422016.N().S(`

    + `) +//line views/history.qtpl:68 + qw422016.N().S(list) +//line views/history.qtpl:68 + qw422016.N().S(` +
    +
    +
    +`) +//line views/history.qtpl:72 +} + +//line views/history.qtpl:72 +func WriteHistoryHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, list string) { +//line views/history.qtpl:72 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/history.qtpl:72 + StreamHistoryHTML(qw422016, rq, hyphaName, list) +//line views/history.qtpl:72 + qt422016.ReleaseWriter(qw422016) +//line views/history.qtpl:72 +} + +//line views/history.qtpl:72 +func HistoryHTML(rq *http.Request, hyphaName, list string) string { +//line views/history.qtpl:72 + qb422016 := qt422016.AcquireByteBuffer() +//line views/history.qtpl:72 + WriteHistoryHTML(qb422016, rq, hyphaName, list) +//line views/history.qtpl:72 + qs422016 := string(qb422016.B) +//line views/history.qtpl:72 + qt422016.ReleaseByteBuffer(qb422016) +//line views/history.qtpl:72 + return qs422016 +//line views/history.qtpl:72 +} diff --git a/views/readers.qtpl b/views/readers.qtpl index 4a9e834..9bbdb9e 100644 --- a/views/readers.qtpl +++ b/views/readers.qtpl @@ -67,15 +67,3 @@ If `contents` == "", a helpful message is shown instead. {%= RelativeHyphaeHTML(relatives) %} {% endfunc %} - -{% func HistoryHTML(rq *http.Request, hyphaName, list string) %} -{%= NavHTML(rq, hyphaName, "history") %} -
    -
    -
    -

    History of {%s hyphaName %}

    - {%s= list %} -
    -
    -
    -{% endfunc %} diff --git a/views/readers.qtpl.go b/views/readers.qtpl.go index 08015fc..fc358ff 100644 --- a/views/readers.qtpl.go +++ b/views/readers.qtpl.go @@ -281,58 +281,3 @@ func RevisionHTML(rq *http.Request, h *hyphae.Hypha, contents, revHash string) s return qs422016 //line views/readers.qtpl:69 } - -//line views/readers.qtpl:71 -func StreamHistoryHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, list string) { -//line views/readers.qtpl:71 - qw422016.N().S(` -`) -//line views/readers.qtpl:72 - StreamNavHTML(qw422016, rq, hyphaName, "history") -//line views/readers.qtpl:72 - qw422016.N().S(` -
    -
    -
    -

    History of `) -//line views/readers.qtpl:76 - qw422016.E().S(hyphaName) -//line views/readers.qtpl:76 - qw422016.N().S(`

    - `) -//line views/readers.qtpl:77 - qw422016.N().S(list) -//line views/readers.qtpl:77 - qw422016.N().S(` -
    -
    -
    -`) -//line views/readers.qtpl:81 -} - -//line views/readers.qtpl:81 -func WriteHistoryHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, list string) { -//line views/readers.qtpl:81 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/readers.qtpl:81 - StreamHistoryHTML(qw422016, rq, hyphaName, list) -//line views/readers.qtpl:81 - qt422016.ReleaseWriter(qw422016) -//line views/readers.qtpl:81 -} - -//line views/readers.qtpl:81 -func HistoryHTML(rq *http.Request, hyphaName, list string) string { -//line views/readers.qtpl:81 - qb422016 := qt422016.AcquireByteBuffer() -//line views/readers.qtpl:81 - WriteHistoryHTML(qb422016, rq, hyphaName, list) -//line views/readers.qtpl:81 - qs422016 := string(qb422016.B) -//line views/readers.qtpl:81 - qt422016.ReleaseByteBuffer(qb422016) -//line views/readers.qtpl:81 - return qs422016 -//line views/readers.qtpl:81 -}