mirror of
https://github.com/Luzifer/go-latestver.git
synced 2024-11-09 23:50:05 +00:00
Simplify URL generation
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
662f340546
commit
b98c71497c
1 changed files with 9 additions and 14 deletions
23
api.go
23
api.go
|
@ -26,7 +26,7 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
func buildFullURL(u *url.URL) string {
|
||||
func buildFullURL(u *url.URL, _ error) string {
|
||||
return strings.Join([]string{
|
||||
strings.TrimRight(cfg.BaseURL, "/"),
|
||||
strings.TrimLeft(u.String(), "/"),
|
||||
|
@ -155,28 +155,23 @@ func handleLogFeed(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
var (
|
||||
feedTitle = "Latestver Update Log"
|
||||
feedURL, _ = router.Get("catalog").URL()
|
||||
)
|
||||
if vars["name"] != "" {
|
||||
feedTitle = fmt.Sprintf("Latestver Update Log of %s:%s", vars["name"], vars["tag"])
|
||||
feedURL, _ = router.Get("catalog-entry").URL("name", vars["name"], "tag", vars["tag"])
|
||||
}
|
||||
|
||||
feed := &feeds.Feed{
|
||||
Description: "Generated by go-latestver: https://github.com/Luzifer/go-latestver",
|
||||
Link: &feeds.Link{Href: buildFullURL(feedURL)},
|
||||
Title: feedTitle,
|
||||
Link: &feeds.Link{Href: buildFullURL(router.Get("catalog").URL())},
|
||||
Title: "Latestver Update Log",
|
||||
}
|
||||
|
||||
if vars["name"] != "" {
|
||||
feed.Title = fmt.Sprintf("Latestver Update Log of %s:%s", vars["name"], vars["tag"])
|
||||
feed.Link.Href = buildFullURL(router.Get("catalog-entry").URL("name", vars["name"], "tag", vars["tag"]))
|
||||
}
|
||||
|
||||
for _, le := range logs {
|
||||
catalogEntryURL, _ := router.Get("catalog-entry").URL("name", le.CatalogName, "tag", le.CatalogTag)
|
||||
feed.Add(&feeds.Item{
|
||||
Created: le.Timestamp.UTC(),
|
||||
Description: fmt.Sprintf("%s:%s updated to version %s from %s", le.CatalogName, le.CatalogTag, le.VersionTo, le.VersionFrom),
|
||||
Id: fmt.Sprintf("%s:%s-%s", le.CatalogName, le.CatalogTag, le.Timestamp.UTC().Format(time.RFC3339)),
|
||||
Link: &feeds.Link{Href: buildFullURL(catalogEntryURL)},
|
||||
Link: &feeds.Link{Href: buildFullURL(router.Get("catalog-entry").URL("name", le.CatalogName, "tag", le.CatalogTag))},
|
||||
Title: fmt.Sprintf("%s:%s %s", le.CatalogName, le.CatalogTag, le.VersionTo),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue