Compare commits

...

4 Commits

Author SHA1 Message Date
46f689725d
Selected based on setting
All checks were successful
the build was successful
2019-03-07 21:38:41 +01:00
2ab2ac5e3c
Load channelType from settings 2019-03-07 21:33:25 +01:00
19ee6c927a
Simplify channel update 2019-03-07 21:31:51 +01:00
9d3a23e5e4
Add channel type selection to the web interface 2019-03-07 21:30:12 +01:00
4 changed files with 30 additions and 32 deletions

View File

@ -1,20 +1,3 @@
/*
ekster - microsub server
Copyright (C) 2018 Peter Stuifzand
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package main package main
import ( import (
@ -643,27 +626,21 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} else if r.URL.Path == "/settings/channel" { } else if r.URL.Path == "/settings/channel" {
defer h.Backend.save() defer h.Backend.save()
uid := r.FormValue("uid") uid := r.FormValue("uid")
// name := r.FormValue("name")
excludeRegex := r.FormValue("exclude_regex") excludeRegex := r.FormValue("exclude_regex")
includeRegex := r.FormValue("include_regex")
channelType := r.FormValue("type")
if setting, e := h.Backend.Settings[uid]; e { if setting, e := h.Backend.Settings[uid]; e {
setting.ExcludeRegex = excludeRegex setting.ExcludeRegex = excludeRegex
setting.IncludeRegex = includeRegex
setting.ChannelType = channelType
h.Backend.Settings[uid] = setting h.Backend.Settings[uid] = setting
} else { } else {
setting = channelSetting{ setting = channelSetting{
ExcludeRegex: excludeRegex, ExcludeRegex: excludeRegex,
}
h.Backend.Settings[uid] = setting
}
includeRegex := r.FormValue("include_regex")
if setting, e := h.Backend.Settings[uid]; e {
setting.IncludeRegex = includeRegex
h.Backend.Settings[uid] = setting
} else {
setting = channelSetting{
IncludeRegex: includeRegex, IncludeRegex: includeRegex,
ChannelType: channelType,
} }
h.Backend.Settings[uid] = setting h.Backend.Settings[uid] = setting
} }

View File

@ -68,6 +68,7 @@ type memoryBackend struct {
type channelSetting struct { type channelSetting struct {
ExcludeRegex string ExcludeRegex string
IncludeRegex string IncludeRegex string
ChannelType string
} }
// Debug interface for easy of use in other packages // Debug interface for easy of use in other packages

View File

@ -22,7 +22,14 @@ func (b *memoryBackend) getTimeline(channel string) TimelineBackend {
timelineType := "sorted-set" timelineType := "sorted-set"
if channel == "notifications" { if channel == "notifications" {
timelineType = "stream" timelineType = "stream"
} else {
if setting, ok := b.Settings[channel]; ok {
if setting.ChannelType != "" {
timelineType = setting.ChannelType
} }
}
}
if timelineType == "sorted-set" { if timelineType == "sorted-set" {
timeline := &redisSortedSetTimeline{channel} timeline := &redisSortedSetTimeline{channel}
err := timeline.Init() err := timeline.Init()

View File

@ -67,6 +67,19 @@
<input type="text" class="input" name="include_regex" value="{{ .CurrentSetting.IncludeRegex }}" placeholder="enter regex to track items" /> <input type="text" class="input" name="include_regex" value="{{ .CurrentSetting.IncludeRegex }}" placeholder="enter regex to track items" />
</div> </div>
</div> </div>
<div class="field">
<div class="control">
<div class="select">
<label class="label" for="type">Tracking Regex</label>
<select name="type" id="type">
<option value="null" {{if eq (.CurrentSetting.ChannelType) "null" }}selected{{end}}>Null</option>
<option value="sorted-set" {{if eq (.CurrentSetting.ChannelType) "sorted-set" }}selected{{end}}>Sorted Set</option>
<option value="stream" {{if eq (.CurrentSetting.ChannelType) "stream" }}selected{{end}}>Streams</option>
</select>
</div>
<input type="text" class="input" name="include_regex" value="{{ .CurrentSetting.IncludeRegex }}" placeholder="enter regex to track items" />
</div>
</div>
<div class="field"> <div class="field">
<button type="submit" class="button is-primary">Save</button> <button type="submit" class="button is-primary">Save</button>
</div> </div>
@ -74,7 +87,7 @@
</div> </div>
<div class="column"> <div class="column">
<h3 class="title is-4">Channels</h3> <h3 class="title is-4">Feeds</h3>
<div class="channel"> <div class="channel">
{{ range .Feeds }} {{ range .Feeds }}