clone

a self-hosted multitenant nostr relay with sites, file storage, git hosting, and inbox and outbox delivery

feat/ui-updates
tinyrelay / tinyclient / social_navigation.go
social_navigation.go 1.7K
1package tinyclient23import "net/url"45type socialViewItem struct {6 Key, Label, Summary, URL string7}89func socialViews() []socialViewItem {10 return []socialViewItem{11 {"feed", "Feed", "Notes, posts and media, together in one place.", "/social"},12 {"notes", "Notes", "Quick thoughts and everyday updates.", "/social?kind=notes"},13 {"posts", "Posts", "Stories, essays and longer reads.", "/social?kind=posts"},14 {"photos", "Photos", "Pictures and the stories behind them.", "/social?kind=photos"},15 {"videos", "Videos", "Clips and films shared in posts.", "/social?kind=videos"},16 {"podcasts", "Podcasts", "Shows and episodes, ready for your favorite player.", "/social?kind=podcasts"},17 }18}1920func socialView(query url.Values) socialViewItem {21 kind := query.Get("kind")22 if kind == "" {23 switch query.Get("kinds") {24 case "1":25 kind = "notes"26 case "30023":27 kind = "posts"28 }29 }30 if kind == "articles" {31 kind = "posts"32 }33 for _, view := range socialViews() {34 if view.Key == kind {35 return view36 }37 }38 return socialViews()[0]39}4041func socialFeedPage(data PageData, cursor string) string {42 path := "/social"43 if data.Tab == "social-profile" {44 path = "/social/profile"45 }46 query := url.Values{}47 for _, key := range []string{"kind", "kinds", "author", "q"} {48 if value := data.Query.Get(key); value != "" {49 query.Set(key, value)50 }51 }52 query.Set("cursor", cursor)53 return path + "?" + query.Encode()54}5556func podcastFeedURL(query url.Values) string {57 values := url.Values{}58 for _, key := range []string{"author", "q"} {59 if value := query.Get(key); value != "" {60 values.Set(key, value)61 }62 }63 path := "/social/podcasts.rss"64 if len(values) > 0 {65 path += "?" + values.Encode()66 }67 return path68}