aboutsummaryrefslogtreecommitdiff
blob: 317c82b31c8c0f5e29998f78212117a46f6aaa52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package utils

import (
	"net/http"
	"time"

	"github.com/gorilla/feeds"

	"soko/pkg/models"
)

func OutdatedFeed(w http.ResponseWriter, link, title string, outdated []models.OutdatedPackages) {
	feed := &feeds.Feed{
		Title:   "Outdated Packages for " + title,
		Author:  &feeds.Author{Name: "Gentoo Packages Database"},
		Created: time.Now(),
		Link:    &feeds.Link{Href: link},
	}

	for _, entry := range outdated {
		feed.Add(&feeds.Item{
			Id:          entry.Atom,
			Title:       entry.Atom,
			Description: "Version " + entry.NewestVersion + " is available, while the latest version in the Gentoo tree is " + entry.GentooVersion + ".",
			Link:        &feeds.Link{Href: "https://packages.gentoo.org/packages/" + entry.Atom, Type: "text/html", Rel: "alternate"},
		})
	}
	feed.WriteAtom(w)
}