Compare commits
No commits in common. "acf0721ba5656ce09df43debe76e55110a470215" and "f3da9da58d7233194ab9b640586ec64b8b78de8e" have entirely different histories.
acf0721ba5
...
f3da9da58d
|
|
@ -50,7 +50,6 @@ type settingsPage struct {
|
||||||
Session session
|
Session session
|
||||||
|
|
||||||
CurrentChannel microsub.Channel
|
CurrentChannel microsub.Channel
|
||||||
CurrentSetting channelSetting
|
|
||||||
|
|
||||||
Channels []microsub.Channel
|
Channels []microsub.Channel
|
||||||
Feeds []microsub.Feed
|
Feeds []microsub.Feed
|
||||||
|
|
@ -273,11 +272,6 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
for _, v := range page.Channels {
|
for _, v := range page.Channels {
|
||||||
if v.UID == currentChannel {
|
if v.UID == currentChannel {
|
||||||
page.CurrentChannel = v
|
page.CurrentChannel = v
|
||||||
if setting, e := h.Backend.Settings[v.UID]; e {
|
|
||||||
page.CurrentSetting = setting
|
|
||||||
} else {
|
|
||||||
page.CurrentSetting = channelSetting{}
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -553,26 +547,6 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ import (
|
||||||
type memoryBackend struct {
|
type memoryBackend struct {
|
||||||
Channels map[string]microsub.Channel
|
Channels map[string]microsub.Channel
|
||||||
Feeds map[string][]microsub.Feed
|
Feeds map[string][]microsub.Feed
|
||||||
Settings map[string]channelSetting
|
|
||||||
NextUid int
|
NextUid int
|
||||||
Me string
|
Me string
|
||||||
TokenEndpoint string
|
TokenEndpoint string
|
||||||
|
|
@ -46,18 +45,15 @@ type memoryBackend struct {
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type channelSetting struct {
|
|
||||||
ExcludeRegex string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Debug interface {
|
type Debug interface {
|
||||||
Debug()
|
Debug()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) Debug() {
|
func (b *memoryBackend) Debug() {
|
||||||
fmt.Println(b.Channels)
|
fmt.Println(b.Channels)
|
||||||
fmt.Println(b.Feeds)
|
|
||||||
fmt.Println(b.Settings)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) load() error {
|
func (b *memoryBackend) load() error {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
<body>
|
<body>
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
|
||||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item" href="/">
|
<a class="navbar-item" href="/">
|
||||||
|
|
@ -48,40 +50,18 @@
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<h2 class="subtitle is-2">{{ $channel.Name }}</h2>
|
<h2 class="subtitle">{{ $channel.Name }}</h2>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="channel">
|
||||||
<div class="column">
|
{{ range .Feeds }}
|
||||||
<h3 class="title is-4">Settings</h3>
|
<div class="feed box">
|
||||||
<form action="/settings/channel" method="post">
|
<div class="name">
|
||||||
<input type="hidden" name="uid" value="{{ .CurrentChannel.UID }}" />
|
<a href="{{ .URL }}">{{ .URL }}</a>
|
||||||
<div class="field">
|
|
||||||
<div class="control">
|
|
||||||
<label class="label">Exclude regex</label>
|
|
||||||
<input type="text" class="input" name="exclude_regex" value="{{ .CurrentSetting.ExcludeRegex }}" placeholder="enter regex to block" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
|
||||||
<button type="submit" class="button is-primary">Save</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="column">
|
|
||||||
<h3 class="title is-4">Channels</h3>
|
|
||||||
|
|
||||||
<div class="channel">
|
|
||||||
{{ range .Feeds }}
|
|
||||||
<div class="feed box">
|
|
||||||
<div class="name">
|
|
||||||
<a href="{{ .URL }}">{{ .URL }}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{ else }}
|
|
||||||
<div class="no-channels">No feeds</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{ else }}
|
||||||
|
<div class="no-channels">No feeds</div>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user