summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2020-05-26 00:38:53 -0700
committerAlec Warner <antarus@gentoo.org>2020-05-26 00:43:24 -0700
commit1ea72450e1ba1c178959426ece6cee0b1b2f7b6a (patch)
tree1b2c432eaf4b974d53070036e42d49ecde8184fc
parentAdd docker files for development purposes (diff)
downloadsoko-master.tar.gz
soko-master.tar.bz2
soko-master.zip
Rewrite added feed with gorilla feed.HEADmaster
Signed-off-by: Alec Warner <antarus@gentoo.org>
-rw-r--r--go.mod2
-rw-r--r--pkg/app/handler/packages/added.go35
2 files changed, 31 insertions, 6 deletions
diff --git a/go.mod b/go.mod
index 0f641a7..2f6fc1c 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,6 @@ go 1.13
require (
github.com/go-pg/pg v8.0.6+incompatible
github.com/go-pg/pg/v9 v9.1.3
- github.com/gorilla/feeds v1.1.1 // indirect
+ github.com/gorilla/feeds v1.1.1
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2
)
diff --git a/pkg/app/handler/packages/added.go b/pkg/app/handler/packages/added.go
index 50f8e84..8ce2274 100644
--- a/pkg/app/handler/packages/added.go
+++ b/pkg/app/handler/packages/added.go
@@ -3,18 +3,43 @@
package packages
import (
+ "fmt"
+ "time"
"net/http"
- "soko/pkg/app/handler/feeds"
+ "github.com/gorilla/feeds"
)
-// Added renders a template containing
-// a list of 50 recently added versions
+// Added renders a template containing a list of 50 recently added versions.
func Added(w http.ResponseWriter, r *http.Request) {
addedVersions := getAddedVersions(50)
RenderPackageTemplates("changedVersions", "changedVersions", "changedVersionRow", GetFuncMap(), CreateFeedData("Added", addedVersions), w)
}
func AddedFeed(w http.ResponseWriter, r *http.Request) {
- addedVersions := getAddedVersions(1000)
- feeds.Changes(GetTextFuncMap(), CreateFeedData("Added", addedVersions), w)
+ addedVersions := getAddedVersions(10)
+ feed := &feeds.Feed{
+ Title: "Added packages in Gentoo.",
+ Description: "Added packages in Gentoo.",
+ Author: &feeds.Author{Name: "Gentoo Packages Database"},
+ Created: time.Now(),
+ Link: &feeds.Link{Href: "https://packages.gentoo.org"},
+ }
+ for _, added := range addedVersions {
+ item := &feeds.Item{
+ Title: added.Atom,
+ Link: &feeds.Link{Href: fmt.Sprintf("https://packages.gentoo.org/package/%s", added.Atom)},
+ Description: added.Description,
+ Author: &feeds.Author{Name: "Unknown"},
+ Created: time.Now(),
+ }
+ if len(added.Commits) > 0 {
+ lastCommit := added.Commits[0]
+ item.Author = &feeds.Author{Name: lastCommit.CommitterName}
+ item.Created = lastCommit.CommitterDate
+ item.Content = fmt.Sprintf("%s is now available in Gentoo on these architectures: %s. See Commit: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=%s",
+ added.Atom, added.Keywords, lastCommit.Id)
+ }
+ feed.Add(item)
+ }
+ feed.WriteAtom(w)
}