From 0ed9c9c7468087da67e399a938299a961c7fa1c7 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 19 Aug 2020 16:24:37 -0400 Subject: [PATCH 1/7] Add inter-blog navigation This makes it easier to navigate between different blog sections: Customize, Stats, View. --- less/admin.less | 13 +++++++++++++ less/core.less | 29 ++++++++++++++++++++++++++++- less/new-core.less | 1 - templates.go | 21 +++++++++++++++++++++ templates/user/admin/users.tmpl | 2 +- templates/user/collection.tmpl | 4 +++- templates/user/collections.tmpl | 22 ++++++++++++---------- templates/user/include/nav.tmpl | 10 ++++++++++ templates/user/stats.tmpl | 6 +++++- 9 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 templates/user/include/nav.tmpl diff --git a/less/admin.less b/less/admin.less index d9d659e..86dc9ff 100644 --- a/less/admin.less +++ b/less/admin.less @@ -32,6 +32,19 @@ nav#admin { display: flex; justify-content: center; + &:not(.pages) { + display: block; + margin: 0.5em 0; + a { + margin-left: 0; + .rounded(.25em); + + &+a { + margin-left: 0.5em; + } + } + } + a { color: #333; font-family: @sansFont; diff --git a/less/core.less b/less/core.less index b502c5d..85e97e6 100644 --- a/less/core.less +++ b/less/core.less @@ -430,6 +430,15 @@ nav#full-nav a.simple-btn, .tool button { text-decoration: none; } +#user-nav { + a:link, a:visited, a:hover { + color: @primary; + } + >a:hover { + text-decoration: underline !important; + } +} + .post-title { a { &:link { @@ -743,6 +752,18 @@ input, button, select.inputform, textarea.inputform, a.btn { } } +.btn.pager { + border: 1px solid @lightNavBorder; + font-size: .86em; + padding: .5em 1em; + white-space: nowrap; + font-family: @sansFont; + &:hover { + text-decoration: none; + background: @lightNavBorder; + } +} + div.flat-select { display: inline-block; position: relative; @@ -965,7 +986,12 @@ footer.contain-me { } ul { &.collections { + padding-left: 0; margin-left: 0; + h3 { + margin-top: 0; + font-weight: normal; + } li { &.collection { a.title { @@ -1095,7 +1121,8 @@ body#pad-sub #posts, .atoms { } .electron { font-weight: normal; - margin-left: 0.5em; + font-size: 0.86em; + margin-left: 0.75rem; } } h3, h4 { diff --git a/less/new-core.less b/less/new-core.less index 87d8158..c9e7a17 100644 --- a/less/new-core.less +++ b/less/new-core.less @@ -127,7 +127,6 @@ textarea { &.collection { a.title { font-size: 1.3em; - font-weight: bold; } } } diff --git a/templates.go b/templates.go index 5ee4bcf..e29b390 100644 --- a/templates.go +++ b/templates.go @@ -11,6 +11,7 @@ package writefreely import ( + "errors" "html/template" "io" "io/ioutil" @@ -38,6 +39,9 @@ var ( "localhtml": localHTML, "tolower": strings.ToLower, "title": strings.Title, + "hasPrefix": strings.HasPrefix, + "hasSuffix": strings.HasSuffix, + "dict": dict, } ) @@ -103,6 +107,7 @@ func initUserPage(parentDir, path, key string) { filepath.Join(parentDir, templatesDir, "user", "include", "header.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "footer.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "silenced.tmpl"), + filepath.Join(parentDir, templatesDir, "user", "include", "nav.tmpl"), )) } @@ -200,3 +205,19 @@ func localHTML(term, lang string) template.HTML { s = strings.Replace(s, "write.as", "writefreely", 1) return template.HTML(s) } + +// from: https://stackoverflow.com/a/18276968/1549194 +func dict(values ...interface{}) (map[string]interface{}, error) { + if len(values)%2 != 0 { + return nil, errors.New("dict: invalid number of parameters") + } + dict := make(map[string]interface{}, len(values)/2) + for i := 0; i < len(values); i += 2 { + key, ok := values[i].(string) + if !ok { + return nil, errors.New("dict: keys must be strings") + } + dict[key] = values[i+1] + } + return dict, nil +} diff --git a/templates/user/admin/users.tmpl b/templates/user/admin/users.tmpl index 714fa24..4b2404e 100644 --- a/templates/user/admin/users.tmpl +++ b/templates/user/admin/users.tmpl @@ -26,7 +26,7 @@ {{end}} -