Add information about channels
This commit is contained in:
parent
a69c6c2fde
commit
4000e2b441
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/alecthomas/template"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/pstuifzand/ekster/pkg/indieauth"
|
||||
"github.com/pstuifzand/ekster/pkg/microsub"
|
||||
"github.com/pstuifzand/ekster/pkg/util"
|
||||
)
|
||||
|
||||
|
@ -39,6 +40,11 @@ type indexPage struct {
|
|||
}
|
||||
type settingsPage struct {
|
||||
Session session
|
||||
|
||||
CurrentChannel string
|
||||
|
||||
Channels map[string]microsub.Channel
|
||||
Feeds map[string][]microsub.Feed
|
||||
}
|
||||
|
||||
func newMainHandler(backend *memoryBackend) (*mainHandler, error) {
|
||||
|
@ -195,6 +201,27 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
return
|
||||
} else if r.URL.Path == "/settings/channel" {
|
||||
c, err := r.Cookie("session")
|
||||
if err == http.ErrNoCookie {
|
||||
http.Redirect(w, r, "/", 302)
|
||||
return
|
||||
}
|
||||
sessionVar := c.Value
|
||||
sess, err := loadSession(sessionVar, conn)
|
||||
|
||||
var page settingsPage
|
||||
page.Session = sess
|
||||
page.Channels = h.Backend.Channels
|
||||
page.Feeds = h.Backend.Feeds
|
||||
page.CurrentChannel = r.URL.Query().Get("uid")
|
||||
|
||||
err = h.Templates.ExecuteTemplate(w, "channel.html", page)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "ERROR: %q\n", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
} else if r.URL.Path == "/settings" {
|
||||
c, err := r.Cookie("session")
|
||||
if err == http.ErrNoCookie {
|
||||
|
@ -206,6 +233,8 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var page settingsPage
|
||||
page.Session = sess
|
||||
page.Channels = h.Backend.Channels
|
||||
page.Feeds = h.Backend.Feeds
|
||||
|
||||
err = h.Templates.ExecuteTemplate(w, "settings.html", page)
|
||||
if err != nil {
|
||||
|
|
61
templates/channel.html
Normal file
61
templates/channel.html
Normal file
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Ekster</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
|
||||
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="/">
|
||||
Ekster
|
||||
</a>
|
||||
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="menu">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{{ if .Session.LoggedIn }}
|
||||
<div id="menu" class="navbar-menu">
|
||||
<a class="navbar-item" href="/settings">
|
||||
Settings
|
||||
</a>
|
||||
<a class="navbar-item" href="{{ .Session.Me }}">
|
||||
Profile
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</nav>
|
||||
|
||||
<h1 class="title">Ekster - Microsub server</h1>
|
||||
|
||||
{{ if .Session.LoggedIn }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
<h2 class="subtitle">Channel</h2>
|
||||
|
||||
<div class="channel">
|
||||
{{ range index .Feeds .CurrentChannel }}
|
||||
<div class="feed box">
|
||||
<div class="name">
|
||||
<a href="{{ .URL }}">{{ or .Name "Untitled" }}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="no-channels">No feeds</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
|
@ -40,6 +40,24 @@
|
|||
|
||||
{{ if .Session.LoggedIn }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
<h2 class="subtitle">Channels</h2>
|
||||
|
||||
<div class="channels">
|
||||
{{ range .Channels }}
|
||||
<div class="channel box">
|
||||
<div class="name">
|
||||
<a href="/settings/channel?uid={{ .UID }}">
|
||||
{{ .Name }}
|
||||
<span class="unread tag is-dark">{{ index $.Feeds .UID | len }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="no-channels">No channels</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user