From 001fc8bb2d157bf3e44b06ba5fc7426dccbb8956 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 9 Nov 2018 22:10:46 -0500 Subject: [PATCH] Fully support single-user mode - New editor nav - New backend nav - Support for drafts - Different footers on backend --- less/core.less | 23 +++++++++++++++++++---- less/new-core.less | 2 +- nodeinfo.go | 12 ++++++++++-- pad.go | 9 +++++++++ pages/login.tmpl | 6 +++--- postrender.go | 2 +- posts.go | 2 ++ routes.go | 10 ++++++---- static/js/postactions.js | 28 ++++++++++++++++++++++------ templates/base.tmpl | 4 ++-- templates/collection-post.tmpl | 4 ++-- templates/collection-tags.tmpl | 2 +- templates/collection.tmpl | 10 +++++++--- templates/edit-meta.tmpl | 4 ++-- templates/include/footer.tmpl | 12 +++++++++++- templates/include/posts.tmpl | 20 ++++++++++---------- templates/pad.tmpl | 17 +++++++++++------ templates/post.tmpl | 2 +- templates/user/articles.tmpl | 8 ++++---- templates/user/collection.tmpl | 2 +- templates/user/include/header.tmpl | 24 +++++++++++++++++++++++- 21 files changed, 148 insertions(+), 55 deletions(-) diff --git a/less/core.less b/less/core.less index 80b2b22..8f6df46 100644 --- a/less/core.less +++ b/less/core.less @@ -17,7 +17,7 @@ body { -moz-osx-font-smoothing: grayscale; color: #111; - h1 { + h1, header h2 { a { color: @headerTextColor; .transition-duration(0.2s); @@ -1161,9 +1161,11 @@ header { text-transform: uppercase; margin-left: 0.5em; margin-right: 0.5em; - &.pro { - color: @proSelectedCol; - } + } + &.title { + font-size: 1.6em; + font-family: @serifFont; + font-weight: bold; } } nav > ul > li:first-child { @@ -1188,9 +1190,22 @@ header { } } &.tabs { + margin: 0 0 0 1em; + } + &+ nav.tabs { margin: 0; } } + &.singleuser { + margin: 0.5em 0.25em; + nav#user-nav { + nav > ul > li:first-child { + img { + top: -0.75em; + } + } + } + } .dash-nav { font-weight: bold; } diff --git a/less/new-core.less b/less/new-core.less index 7c46203..802f34d 100644 --- a/less/new-core.less +++ b/less/new-core.less @@ -39,7 +39,7 @@ body { header { margin: 1em; - h1 { + h1, h2 { display: inline; } nav { diff --git a/nodeinfo.go b/nodeinfo.go index b2c58fa..fd4b445 100644 --- a/nodeinfo.go +++ b/nodeinfo.go @@ -12,15 +12,23 @@ type nodeInfoResolver struct { db *datastore } -func nodeInfoConfig(cfg *config.Config) *nodeinfo.Config { +func nodeInfoConfig(db *datastore, cfg *config.Config) *nodeinfo.Config { name := cfg.App.SiteName + desc := "Minimal, federated blogging platform." + if cfg.App.SingleUser { + // Fetch blog information, instead + coll, err := db.GetCollectionByID(1) + if err == nil { + desc = coll.Description + } + } return &nodeinfo.Config{ BaseURL: cfg.App.Host, InfoURL: "/api/nodeinfo", Metadata: nodeinfo.Metadata{ NodeName: name, - NodeDescription: "Minimal, federated blogging platform.", + NodeDescription: desc, Private: cfg.App.Private, Software: nodeinfo.SoftwareMeta{ HomePage: softwareURL, diff --git a/pad.go b/pad.go index 6a04030..017b8e4 100644 --- a/pad.go +++ b/pad.go @@ -14,6 +14,14 @@ func handleViewPad(app *app, w http.ResponseWriter, r *http.Request) error { action := vars["action"] slug := vars["slug"] collAlias := vars["collection"] + if app.cfg.App.SingleUser { + // TODO: refactor all of this, especially for single-user blogs + c, err := app.db.GetCollectionByID(1) + if err != nil { + return err + } + collAlias = c.Alias + } appData := &struct { page.StaticPage Post *RawPost @@ -52,6 +60,7 @@ func handleViewPad(app *app, w http.ResponseWriter, r *http.Request) error { w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Expires", "Thu, 04 Oct 1990 20:00:00 GMT") if slug != "" { + // TODO: refactor all of this, especially for single-user blogs appData.Post = getRawCollectionPost(app, slug, collAlias) if appData.Post.OwnerID != appData.User.ID { // TODO: add ErrForbiddenEditPost message to flashes diff --git a/pages/login.tmpl b/pages/login.tmpl index 411da50..9b58523 100644 --- a/pages/login.tmpl +++ b/pages/login.tmpl @@ -1,6 +1,6 @@ {{define "head"}}Log in — {{.SiteName}} - - + + {{end}} {{define "content"}} @@ -18,7 +18,7 @@ -

{{if .Message}}{{.Message}}{{else}}No account yet? Sign up to start a blog.{{end}}

+ {{if and (not .SingleUser) .OpenRegistration}}

{{if .Message}}{{.Message}}{{else}}No account yet? Sign up to start a blog.{{end}}

{{end}}