From 81847fbbcc66e215c76bf745923836a75631e34f Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 5 Aug 2019 09:27:51 -0400 Subject: [PATCH 01/25] Land on Blogs page when SimpleNav is enabled This shows the Blogs page instead of the Editor to logged in users on the `/` path when the new `simple_nav` config option is enabled. Ref T680 --- app.go | 7 ++++++- config/config.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index 1fa6f8a..6d6a689 100644 --- a/app.go +++ b/app.go @@ -193,7 +193,12 @@ func handleViewHome(app *App, w http.ResponseWriter, r *http.Request) error { // Show correct page based on user auth status and configured landing path u := getUserSession(app, r) if u != nil { - // User is logged in, so show the Pad + // User is logged in, so show the Pad or Blogs page, depending on config + if app.cfg.App.SimpleNav { + // Simple nav, so home page is Blogs page + return viewCollections(app, u, w, r) + } + // Default config, so home page is editor return handleViewPad(app, w, r) } diff --git a/config/config.go b/config/config.go index f46282e..d026a74 100644 --- a/config/config.go +++ b/config/config.go @@ -68,6 +68,7 @@ type ( JSDisabled bool `ini:"disable_js"` WebFonts bool `ini:"webfonts"` Landing string `ini:"landing"` + SimpleNav bool `ini:"simple_nav"` // Users SingleUser bool `ini:"single_user"` From 90ad50c7f5c30f45065798304cf7708a47ac9342 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 5 Aug 2019 09:34:47 -0400 Subject: [PATCH 02/25] Use normal nav on user pages when SimpleNav This shows About, Reader, Log out links on backend user pages when logged in. It also adds "New post" buttons on the backend pages and blogs. --- less/core.less | 25 +++++++++++++++++++++++++ templates/base.tmpl | 2 +- templates/collection.tmpl | 1 + templates/user/include/header.tmpl | 23 ++++++++++++++++++++--- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/less/core.less b/less/core.less index 7e39f35..b1b8301 100644 --- a/less/core.less +++ b/less/core.less @@ -405,6 +405,31 @@ body { } } +nav#full-nav { + margin: 0; + + .left-side { + display: inline-block; + + a:first-child { + margin-left: 0; + } + } + + .right-side { + float: right; + } +} + +nav#full-nav a.simple-btn { + font-family: @sansFont; + border: 1px solid #ccc !important; + padding: .5rem 1rem; + margin: 0; + .rounded(.25em); + text-decoration: none; +} + .post-title { a { &:link { diff --git a/templates/base.tmpl b/templates/base.tmpl index 775dac9..c1f17ad 100644 --- a/templates/base.tmpl +++ b/templates/base.tmpl @@ -19,7 +19,7 @@ {{end}} diff --git a/templates/collection.tmpl b/templates/collection.tmpl index 18942a9..364ba15 100644 --- a/templates/collection.tmpl +++ b/templates/collection.tmpl @@ -48,6 +48,7 @@ {{else}}
  • {{.SiteName}}
  • {{end}} + {{if .SimpleNav}}
  • New Post
  • {{end}}
  • Customize
  • Stats

  • diff --git a/templates/user/include/header.tmpl b/templates/user/include/header.tmpl index 312d0b8..93020e2 100644 --- a/templates/user/include/header.tmpl +++ b/templates/user/include/header.tmpl @@ -38,7 +38,13 @@ {{else}} -

    {{.SiteName}}

    + {{ if .SimpleNav }} + {{end}} {{end}}
    From 1d25784d20537923889eb8a36d7efc2cfbdace32 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 5 Aug 2019 09:54:05 -0400 Subject: [PATCH 03/25] Add `bare` editor option This adds a new editor template that strips away most of the customization features in the default editor and includes only: - publishing - editing - viewing word count It also restricts publishing to a user's first collection, so it's optimized for instances that only allow users to have a single collection and don't use Drafts. Ref T680 T677 --- less/core.less | 2 +- less/pad-theme.less | 4 +- less/pad.less | 7 ++ templates/bare.tmpl | 235 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 templates/bare.tmpl diff --git a/less/core.less b/less/core.less index b1b8301..f4332a9 100644 --- a/less/core.less +++ b/less/core.less @@ -421,7 +421,7 @@ nav#full-nav { } } -nav#full-nav a.simple-btn { +nav#full-nav a.simple-btn, .tool button { font-family: @sansFont; border: 1px solid #ccc !important; padding: .5rem 1rem; diff --git a/less/pad-theme.less b/less/pad-theme.less index af1f95c..a8f668e 100644 --- a/less/pad-theme.less +++ b/less/pad-theme.less @@ -63,7 +63,7 @@ body#pad, body#pad-sub { } } #belt { - a { + a, button { color: #000; } } @@ -100,7 +100,7 @@ body#pad, body#pad-sub { } } #belt { - a { + a, button { color: white; } } diff --git a/less/pad.less b/less/pad.less index d37c6bc..a132b30 100644 --- a/less/pad.less +++ b/less/pad.less @@ -222,6 +222,13 @@ body#pad, body#pad-sub { font-style: italic; } } + button { + font-family: @sansFont; + background-color: transparent; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + border: 0; + } } } } diff --git a/templates/bare.tmpl b/templates/bare.tmpl new file mode 100644 index 0000000..1398a47 --- /dev/null +++ b/templates/bare.tmpl @@ -0,0 +1,235 @@ +{{define "pad"}} + + + + {{if .Editing}}Editing {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}}{{else}}New Post{{end}} — {{.SiteName}} + + + + + + + + +
    + + + +
    +
    + {{if not .SingleUser}}

    {{.SiteName}}

    {{end}} + + +
    + +
    + {{if .Editing}}{{end}} +
    +
    +
    + + + + +{{end}} From 17f7bc1becd321810694105535b5bc9ce892ddac Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 6 Aug 2019 09:15:05 -0400 Subject: [PATCH 04/25] Move user navigation to its own template section Ref T681 --- templates/user/include/header.tmpl | 37 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/templates/user/include/header.tmpl b/templates/user/include/header.tmpl index 93020e2..5f29646 100644 --- a/templates/user/include/header.tmpl +++ b/templates/user/include/header.tmpl @@ -1,20 +1,4 @@ -{{define "header"}} - - - - - {{.PageTitle}} {{if .Separator}}{{.Separator}}{{else}}—{{end}} {{.SiteName}} - - - - - - - - - - - +{{define "user-navigation"}} {{if .SingleUser}} {{else}} - {{ if .SimpleNav }} - {{if .SimpleNav}}{{if .Username}}
    + {{if .Chorus}}{{if .Username}}{{end}} From d8405680b4e1720a020b86a94a4684700d0c2e9c Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 9 Aug 2019 14:57:09 -0400 Subject: [PATCH 18/25] Respect `private` setting with home page Reader Ref T681 --- app.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app.go b/app.go index 8b630df..1e24c75 100644 --- a/app.go +++ b/app.go @@ -193,16 +193,20 @@ func handleViewHome(app *App, w http.ResponseWriter, r *http.Request) error { return handleViewCollection(app, w, r) } - if app.cfg.App.Chorus { - // This instance is focused on reading, so show Reader on home route - return viewLocalTimeline(app, w, r) - } - // Multi-user instance forceLanding := r.FormValue("landing") == "1" if !forceLanding { // Show correct page based on user auth status and configured landing path u := getUserSession(app, r) + + if app.cfg.App.Chorus { + // This instance is focused on reading, so show Reader on home route if not + // private or a private-instance user is logged in. + if !app.cfg.App.Private || u != nil { + return viewLocalTimeline(app, w, r) + } + } + if u != nil { // User is logged in, so show the Pad return handleViewPad(app, w, r) From 047ad0323b12c702cef5ebcfde3af88fa0c3d610 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 9 Aug 2019 14:58:17 -0400 Subject: [PATCH 19/25] Don't show user pages in nav when unauth'd Ref T681 T680 --- templates/base.tmpl | 2 ++ templates/user/include/header.tmpl | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/base.tmpl b/templates/base.tmpl index 678ada8..f8b66c8 100644 --- a/templates/base.tmpl +++ b/templates/base.tmpl @@ -41,9 +41,11 @@ {{ end }} About {{ if not .SingleUser }} + {{ if .Username }} {{if gt .MaxBlogs 1}}Blogs{{end}} {{if and (and .Chorus (eq .MaxBlogs 1)) .Username}}My Posts{{end}} {{if not .DisableDrafts}}Drafts{{end}} + {{ end }} {{if and (and .LocalTimeline .CanViewReader) (not .Chorus)}}Reader{{end}} {{if and (and .Chorus .OpenRegistration) (not .Username)}}Sign up{{end}} {{if not .Username}}Log in{{else if .SimpleNav}}Log out{{end}} diff --git a/templates/user/include/header.tmpl b/templates/user/include/header.tmpl index 5923c83..9d5bb54 100644 --- a/templates/user/include/header.tmpl +++ b/templates/user/include/header.tmpl @@ -50,9 +50,11 @@ {{ end }} About {{ if not .SingleUser }} + {{ if .Username }} {{if gt .MaxBlogs 1}}Blogs{{end}} - {{if and (and .Chorus (eq .MaxBlogs 1)) .Username}}My Posts{{end}} + {{if and .Chorus (eq .MaxBlogs 1)}}My Posts{{end}} {{if not .DisableDrafts}}Drafts{{end}} + {{ end }} {{if and (and .LocalTimeline .CanViewReader) (not .Chorus)}}Reader{{end}} {{if and (and .Chorus .OpenRegistration) (not .Username)}}Sign up{{end}} {{if .Username}}Log out{{else}}Log in{{end}} From 8a29a4dfc94b91a753391c4752b1ea4116d97ef6 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 14 Aug 2019 23:14:34 -0400 Subject: [PATCH 20/25] Link to home page in bare editor in chorus mode Ref T681 --- templates/bare.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/bare.tmpl b/templates/bare.tmpl index 1398a47..a4194c9 100644 --- a/templates/bare.tmpl +++ b/templates/bare.tmpl @@ -19,7 +19,7 @@
    - {{if not .SingleUser}}

    {{.SiteName}}

    {{end}} + {{if not .SingleUser}}

    {{if .Chorus}}{{else}}{{end}}{{.SiteName}}

    {{end}} From 55808233fd322373452f0c41240b542470251e6c Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 14 Aug 2019 23:25:02 -0400 Subject: [PATCH 21/25] Fix logic for showing sign up link This prevents the link from showing when an instance lands on the sign up page anyway. Ref T681 --- templates/base.tmpl | 2 +- templates/user/include/header.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/base.tmpl b/templates/base.tmpl index f8b66c8..aae7850 100644 --- a/templates/base.tmpl +++ b/templates/base.tmpl @@ -47,7 +47,7 @@ {{if not .DisableDrafts}}Drafts{{end}} {{ end }} {{if and (and .LocalTimeline .CanViewReader) (not .Chorus)}}Reader{{end}} - {{if and (and .Chorus .OpenRegistration) (not .Username)}}Sign up{{end}} + {{if and (and (and .Chorus .OpenRegistration) (not .Username)) (or (not .Private) (ne .Landing ""))}}Sign up{{end}} {{if not .Username}}Log in{{else if .SimpleNav}}Log out{{end}} {{ end }} diff --git a/templates/user/include/header.tmpl b/templates/user/include/header.tmpl index 9d5bb54..0feca89 100644 --- a/templates/user/include/header.tmpl +++ b/templates/user/include/header.tmpl @@ -56,7 +56,7 @@ {{if not .DisableDrafts}}Drafts{{end}} {{ end }} {{if and (and .LocalTimeline .CanViewReader) (not .Chorus)}}Reader{{end}} - {{if and (and .Chorus .OpenRegistration) (not .Username)}}Sign up{{end}} + {{if and (and (and .Chorus .OpenRegistration) (not .Username)) (or (not .Private) (ne .Landing ""))}}Sign up{{end}} {{if .Username}}Log out{{else}}Log in{{end}} {{ end }} {{else}} From 954e57897bd335fba16864aa8ed24f16faeaaddb Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 3 Sep 2019 17:40:02 -0400 Subject: [PATCH 22/25] Fix unpinning on chorus post page --- templates/chorus-collection-post.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/chorus-collection-post.tmpl b/templates/chorus-collection-post.tmpl index 392ebe6..bab2e31 100644 --- a/templates/chorus-collection-post.tmpl +++ b/templates/chorus-collection-post.tmpl @@ -100,14 +100,14 @@ function unpinPost(e, postID) { } pinning = true; - var $header = document.getElementsByTagName('header')[0]; + var $footer = document.getElementsByTagName('footer')[0]; var callback = function() { // Hide current page - var $pinnedNavLink = $header.getElementsByTagName('nav')[0].querySelector('.pinned.selected'); + var $pinnedNavLink = $footer.getElementsByTagName('nav')[0].querySelector('.pinned.selected'); $pinnedNavLink.style.display = 'none'; }; - var $pinBtn = $header.getElementsByClassName('unpin')[0]; + var $pinBtn = $footer.getElementsByClassName('unpin')[0]; $pinBtn.innerHTML = '...'; var http = new XMLHttpRequest(); From 8ec25f1fb49ad720569716d3afb1b21581850470 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 3 Sep 2019 17:42:23 -0400 Subject: [PATCH 23/25] Fix pinning on chorus collection page Previously, the new pinned post link would appear in the site header, instead of the blog header. --- templates/chorus-collection.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/chorus-collection.tmpl b/templates/chorus-collection.tmpl index 06695b1..e36d3b5 100644 --- a/templates/chorus-collection.tmpl +++ b/templates/chorus-collection.tmpl @@ -174,7 +174,7 @@ function pinPost(e, postID, slug, title) { // Visibly remove post from collection var $postEl = document.getElementById('post-' + postID); $postEl.parentNode.removeChild($postEl); - var $header = document.getElementsByTagName('header')[0]; + var $header = document.querySelector('header:not(.multiuser)'); var $pinnedNavs = $header.getElementsByTagName('nav'); // Add link to nav var link = ''+title+''; From 4419632f83da051c48f98d74760d24658d065942 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 3 Sep 2019 17:56:27 -0400 Subject: [PATCH 24/25] Fix false login state on failed login Previously, a failed login would change the site-wide navigation so that it looked like the user was logged in, even though they weren't. This fixes that. --- account.go | 8 ++++---- pages/login.tmpl | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/account.go b/account.go index 357bae5..a3eb39d 100644 --- a/account.go +++ b/account.go @@ -309,10 +309,10 @@ func viewLogin(app *App, w http.ResponseWriter, r *http.Request) error { p := &struct { page.StaticPage - To string - Message template.HTML - Flashes []template.HTML - Username string + To string + Message template.HTML + Flashes []template.HTML + LoginUsername string }{ pageForReq(app, r), r.FormValue("to"), diff --git a/pages/login.tmpl b/pages/login.tmpl index 9b58523..1c8e862 100644 --- a/pages/login.tmpl +++ b/pages/login.tmpl @@ -12,8 +12,8 @@ {{end}} -
    -
    +
    +
    {{if .To}}{{end}} From c7a90d2ace4adb33f8e8eb405545000cb02bccf0 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 10 Sep 2019 22:07:14 +0200 Subject: [PATCH 25/25] Fix blog post links when `chorus` enabled This ensures the "new post" link under each blog on the user Blogs page goes to /new instead of /. Ref T681 --- templates/user/collections.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/user/collections.tmpl b/templates/user/collections.tmpl index 6ce4b75..481fd8f 100644 --- a/templates/user/collections.tmpl +++ b/templates/user/collections.tmpl @@ -13,7 +13,7 @@ {{if .Title}}{{.Title}}{{else}}{{.Alias}}{{end}}

    - new post + new post customize stats