diff --git a/config/config.go b/config/config.go index f8a7d76a..0c5b35b2 100644 --- a/config/config.go +++ b/config/config.go @@ -27,6 +27,15 @@ func IsSukebei() bool { return Conf.Models.TorrentsTableName == "sukebei_torrents" } +// WebAddress : Returns web address for current site +func WebAddress() string { + if IsSukebei() { + return Conf.WebAddress.Sukebei + } else { + return Conf.WebAddress.Nyaa + } +} + var allowedDatabaseTypes = map[string]bool{ "sqlite3": true, "postgres": true, diff --git a/router/rss_handler.go b/router/rss_handler.go index 622e9f43..e4856b0e 100644 --- a/router/rss_handler.go +++ b/router/rss_handler.go @@ -64,9 +64,13 @@ func RSSHandler(w http.ResponseWriter, r *http.Request) { if len(torrents) > 0 { createdAsTime = torrents[0].Date } + title := "Nyaa Pantsu" + if config.IsSukebei() { + title = "Sukebei Pantsu" + } feed := &feeds.Feed{ - Title: "Nyaa Pantsu", - Link: &feeds.Link{Href: config.Conf.WebAddress.Nyaa + "/"}, + Title: title, + Link: &feeds.Link{Href: config.WebAddress() + "/"}, Created: createdAsTime, } feed.Items = make([]*feeds.Item, len(torrents)) @@ -74,7 +78,7 @@ func RSSHandler(w http.ResponseWriter, r *http.Request) { for i, torrent := range torrents { torrentJSON := torrent.ToJSON() feed.Items[i] = &feeds.Item{ - ID: config.Conf.WebAddress.Nyaa + "/view/" + strconv.FormatUint(uint64(torrentJSON.ID), 10), + ID: config.WebAddress() + "/view/" + strconv.FormatUint(uint64(torrentJSON.ID), 10), Title: torrent.Name, Link: &feeds.Link{Href: string("")}, Description: string(torrentJSON.Description),