mirror of
https://github.com/Xevion/glance.git
synced 2025-12-09 14:07:23 -06:00
Allow specifying sort order and tags through config
This commit is contained in:
@@ -2,6 +2,7 @@ package feed
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -54,7 +55,22 @@ func getLobstersPostsFromFeed(feedUrl string) (ForumPosts, error) {
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func FetchLobstersTopPosts(feedUrl string) (ForumPosts, error) {
|
||||
func FetchLobstersPosts(sortBy string, tags []string) (ForumPosts, error) {
|
||||
var feedUrl string
|
||||
|
||||
if sortBy == "hot" {
|
||||
sortBy = "hottest"
|
||||
} else if sortBy == "new" {
|
||||
sortBy = "newest"
|
||||
}
|
||||
|
||||
if len(tags) == 0 {
|
||||
feedUrl = "https://lobste.rs/" + sortBy + ".json"
|
||||
} else {
|
||||
tags := strings.Join(tags, ",")
|
||||
feedUrl = "https://lobste.rs/t/" + tags + ".json"
|
||||
}
|
||||
|
||||
posts, err := getLobstersPostsFromFeed(feedUrl)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user