diff --git a/cmd/eksterd/http.go b/cmd/eksterd/http.go index c10454d..5c93f0e 100644 --- a/cmd/eksterd/http.go +++ b/cmd/eksterd/http.go @@ -50,6 +50,7 @@ type settingsPage struct { Session session CurrentChannel microsub.Channel + CurrentSetting channelSetting Channels []microsub.Channel Feeds []microsub.Feed @@ -272,6 +273,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { for _, v := range page.Channels { if v.UID == currentChannel { page.CurrentChannel = v + if setting, e := h.Backend.Settings[v.UID]; e { + page.CurrentSetting = setting + } else { + page.CurrentSetting = channelSetting{} + } break } } @@ -547,6 +553,26 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } return + } else if r.URL.Path == "/settings/channel" { + defer h.Backend.save() + uid := r.FormValue("uid") + //name := r.FormValue("name") + excludeRegex := r.FormValue("exclude_regex") + + if setting, e := h.Backend.Settings[uid]; e { + setting.ExcludeRegex = excludeRegex + h.Backend.Settings[uid] = setting + } else { + setting = channelSetting{ + ExcludeRegex: excludeRegex, + } + h.Backend.Settings[uid] = setting + } + + h.Backend.Debug() + + http.Redirect(w, r, "/settings", 302) + return } } diff --git a/cmd/eksterd/memory.go b/cmd/eksterd/memory.go index 0f5d73d..56c7b99 100644 --- a/cmd/eksterd/memory.go +++ b/cmd/eksterd/memory.go @@ -37,6 +37,7 @@ import ( type memoryBackend struct { Channels map[string]microsub.Channel Feeds map[string][]microsub.Feed + Settings map[string]channelSetting NextUid int Me string TokenEndpoint string @@ -45,12 +46,18 @@ type memoryBackend struct { quit chan struct{} } +type channelSetting struct { + ExcludeRegex string +} + type Debug interface { Debug() } func (b *memoryBackend) Debug() { fmt.Println(b.Channels) + fmt.Println(b.Feeds) + fmt.Println(b.Settings) } func (b *memoryBackend) load() error { diff --git a/templates/channel.html b/templates/channel.html index 4d0c58c..6332864 100644 --- a/templates/channel.html +++ b/templates/channel.html @@ -9,8 +9,6 @@
- - -

{{ $channel.Name }}

+

{{ $channel.Name }}

-
- {{ range .Feeds }} -
-
- {{ .URL }} +
+
+

Settings

+
+ +
+
+ + +
+
+ +
+
+
+ +
+

Channels

+ +
+ {{ range .Feeds }} +
+ +
+ {{ else }} +
No feeds
+ {{ end }}
- {{ else }} -
No feeds
- {{ end }} +