all repos — homestead @ 10f9fb2d61199a57ee12d443c2d2d55b858e467c

Code for my website

change post changelog link to point to file's diff

Alan Pearce
commit

10f9fb2d61199a57ee12d443c2d2d55b858e467c

parent

44ac8121f566c71b3672db6609792063c1bb06f9

2 files changed, 13 insertions(+), 2 deletions(-)

changed files
M internal/vcs/filelog.gointernal/vcs/filelog.go
@@ -19,6 +19,7 @@ Email string
} type Commit struct { + repo *Repository ShortHash string Hash string Message string
@@ -54,6 +55,7 @@ cs := make([]*Commit, 0)
err = fl.ForEach(func(c *object.Commit) error { summary, description, _ := strings.Cut(c.Message, "\n") cs = append(cs, &Commit{ + repo: r, ShortHash: c.Hash.String()[:hashLength], Hash: c.Hash.String(), Message: c.Message,
@@ -81,3 +83,12 @@
func cleanupDescription(description string) string { return strings.TrimSpace(rewrap.ReplaceAllString(description, " $1")) } + +func (c *Commit) MakeFileLink(filename string) *url.URL { + u := c.repo.remoteURL.JoinPath("commit").JoinPath(filename) + q := u.Query() + q.Add("id", c.Hash) + u.RawQuery = q.Encode() + + return u +}
M templates/post.gotemplates/post.go
@@ -48,7 +48,7 @@ TitleAttr(commit.Description),
postDate(commit.Date, ""), g.Text(" "), A( - Href(commit.Link.String()), + Href(commit.MakeFileLink(post.Input).String()), g.Text(commit.Summary), ), g.Text(" "),
@@ -79,7 +79,7 @@ return Span(
Class("date last-updated"), g.Text("Last updated: "), A( - Href(post.Commits[0].Link.String()), + Href(post.Commits[0].MakeFileLink(post.Input).String()), postDate(post.Commits[0].Date, "dt-updated"), ), )