Skip to content

Commit

Permalink
www/pacakge- add diff url for approved versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Apr 18, 2021
1 parent dd8ac8d commit dcb6057
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ func main() {
}
return newv[x-1].CommitTo[:8]
})
raymond.RegisterHelper("notequal", func(a interface{}, b interface{}, options *raymond.Options) interface{} {
if raymond.Str(a) == raymond.Str(b) {
return options.Inverse()
}
return options.Fn()
})
raymond.RegisterHelper("diff_url_off", func(r int64, n string, x int, to string, appv []*db.Version) string {
return "https://github.com/" + n + "/compare/" + appv[x-1].CommitTo[:10] + "..." + to[:10]
})
raymond.RegisterHelper("prev_commit_off", func(x int, appv []*db.Version) string {
return appv[x-1].CommitTo[:8]
})

handler.Init()

Expand Down
4 changes: 2 additions & 2 deletions www/package.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
<th></th>
<th>Published On</th>
<th>Tree @ Commit</th>
<th>Compare Diff</th>
<th>Unpacked Size</th>
<th>Total Size</th>
<th>Tar Size</th>
</tr>
</thead>
Expand All @@ -67,8 +67,8 @@
<td><a href="./{{pkg.Name}}/v{{this.RealMajor}}.{{this.RealMinor}}">v{{this.RealMajor}}.{{this.RealMinor}}</a></td>
<td>{{fix_date this.CreatedOn}}</td>
<td><a href="{{tree_url pkg.Remote pkg.RemoteName this.CommitTo}}"><code>{{trim_str this.CommitTo 14}}</code></a></td>
<td>{{#notequal @index 0}}<a href="{{diff_url_off pkg.Remote pkg.RemoteName @index this.CommitTo versions}}"><code>{{prev_commit_off @index versions}}...{{trim_str this.CommitTo 8}}</code></a>{{/notequal}}</td>
<td>{{fix_bytes this.UnpackedSize}}</td>
<td>{{fix_bytes this.TotalSize}}</td>
<td>{{fix_bytes this.TarSize}}</td>
</tr>
{{/each}}
Expand Down

0 comments on commit dcb6057

Please sign in to comment.