mirror of
https://github.com/writefreely/writefreely
synced 2024-11-12 20:27:10 +00:00
Add inter-blog navigation
This makes it easier to navigate between different blog sections: Customize, Stats, View.
This commit is contained in:
parent
dfa14c9c92
commit
0ed9c9c746
9 changed files with 93 additions and 15 deletions
|
@ -32,6 +32,19 @@ nav#admin {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
|
&:not(.pages) {
|
||||||
|
display: block;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
a {
|
||||||
|
margin-left: 0;
|
||||||
|
.rounded(.25em);
|
||||||
|
|
||||||
|
&+a {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #333;
|
color: #333;
|
||||||
font-family: @sansFont;
|
font-family: @sansFont;
|
||||||
|
|
|
@ -430,6 +430,15 @@ nav#full-nav a.simple-btn, .tool button {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#user-nav {
|
||||||
|
a:link, a:visited, a:hover {
|
||||||
|
color: @primary;
|
||||||
|
}
|
||||||
|
>a:hover {
|
||||||
|
text-decoration: underline !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.post-title {
|
.post-title {
|
||||||
a {
|
a {
|
||||||
&:link {
|
&: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 {
|
div.flat-select {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -965,7 +986,12 @@ footer.contain-me {
|
||||||
}
|
}
|
||||||
ul {
|
ul {
|
||||||
&.collections {
|
&.collections {
|
||||||
|
padding-left: 0;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
h3 {
|
||||||
|
margin-top: 0;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
li {
|
li {
|
||||||
&.collection {
|
&.collection {
|
||||||
a.title {
|
a.title {
|
||||||
|
@ -1095,7 +1121,8 @@ body#pad-sub #posts, .atoms {
|
||||||
}
|
}
|
||||||
.electron {
|
.electron {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
margin-left: 0.5em;
|
font-size: 0.86em;
|
||||||
|
margin-left: 0.75rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h3, h4 {
|
h3, h4 {
|
||||||
|
|
|
@ -127,7 +127,6 @@ textarea {
|
||||||
&.collection {
|
&.collection {
|
||||||
a.title {
|
a.title {
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
font-weight: bold;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
templates.go
21
templates.go
|
@ -11,6 +11,7 @@
|
||||||
package writefreely
|
package writefreely
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -38,6 +39,9 @@ var (
|
||||||
"localhtml": localHTML,
|
"localhtml": localHTML,
|
||||||
"tolower": strings.ToLower,
|
"tolower": strings.ToLower,
|
||||||
"title": strings.Title,
|
"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", "header.tmpl"),
|
||||||
filepath.Join(parentDir, templatesDir, "user", "include", "footer.tmpl"),
|
filepath.Join(parentDir, templatesDir, "user", "include", "footer.tmpl"),
|
||||||
filepath.Join(parentDir, templatesDir, "user", "include", "silenced.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", "<a href=\"https://writefreely.org\">writefreely</a>", 1)
|
s = strings.Replace(s, "write.as", "<a href=\"https://writefreely.org\">writefreely</a>", 1)
|
||||||
return template.HTML(s)
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<nav class="pager">
|
<nav class="pager pages">
|
||||||
{{range $n := .TotalPages}}<a href="/admin/users{{if ne $n 1}}?p={{$n}}{{end}}" {{if eq $.CurPage $n}}class="selected"{{end}}>{{$n}}</a>{{end}}
|
{{range $n := .TotalPages}}<a href="/admin/users{{if ne $n 1}}?p={{$n}}{{end}}" {{if eq $.CurPage $n}}class="selected"{{end}}>{{$n}}</a>{{end}}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ textarea.section.norm {
|
||||||
{{if .Silenced}}
|
{{if .Silenced}}
|
||||||
{{template "user-silenced"}}
|
{{template "user-silenced"}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<h2>Customize {{.DisplayTitle}} <a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">view blog</a></h2>
|
<h1>Customize {{.DisplayTitle}}</h1>
|
||||||
|
|
||||||
|
{{template "collection-nav" (dict "Alias" .Alias "Path" .Path "SingleUser" .SingleUser)}}
|
||||||
|
|
||||||
{{if .Flashes}}<ul class="errors">
|
{{if .Flashes}}<ul class="errors">
|
||||||
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
|
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
|
||||||
|
|
|
@ -12,16 +12,18 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
<h1>Blogs</h1>
|
<h1>Blogs</h1>
|
||||||
<ul class="atoms collections">
|
<ul class="atoms collections">
|
||||||
{{range $i, $el := .Collections}}<li class="collection"><h3>
|
{{range $i, $el := .Collections}}<li class="collection">
|
||||||
<a class="title" href="/{{.Alias}}/">{{if .Title}}{{.Title}}{{else}}{{.Alias}}{{end}}</a>
|
<div class="row lineitem">
|
||||||
</h3>
|
<div>
|
||||||
<h4>
|
<h3>
|
||||||
<a class="action new-post" href="{{if $.Chorus}}/new{{else}}/{{end}}#{{.Alias}}">new post</a>
|
<a class="title" href="/{{.Alias}}/" >{{if .Title}}{{.Title}}{{else}}{{.Alias}}{{end}}</a>
|
||||||
<a class="action" href="/me/c/{{.Alias}}">customize</a>
|
<span class="electron" {{if .IsPrivate}}style="font-style: italic"{{end}}>{{if .IsPrivate}}private{{else}}{{.DisplayCanonicalURL}}{{end}}</span>
|
||||||
<a class="action" href="/me/c/{{.Alias}}/stats">stats</a>
|
</h3>
|
||||||
</h4>
|
{{template "collection-nav" (dict "Alias" .Alias "Path" $.Path "SingleUser" $.SingleUser)}}
|
||||||
{{if .Description}}<p class="description">{{.Description}}</p>{{end}}
|
{{if .Description}}<p class="description">{{.Description}}</p>{{end}}
|
||||||
</li>{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>{{end}}
|
||||||
<li id="create-collection">
|
<li id="create-collection">
|
||||||
{{if not .NewBlogsDisabled}}
|
{{if not .NewBlogsDisabled}}
|
||||||
<form method="POST" action="/api/collections" id="new-collection-form" onsubmit="return createCollection()">
|
<form method="POST" action="/api/collections" id="new-collection-form" onsubmit="return createCollection()">
|
||||||
|
|
10
templates/user/include/nav.tmpl
Normal file
10
templates/user/include/nav.tmpl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{{define "collection-nav"}}
|
||||||
|
<header class="admin">
|
||||||
|
<nav class="pager">
|
||||||
|
<a href="{{if .SingleUser}}/me/new{{else}}/#{{.Alias}}{{end}}" class="btn gentlecta">New Post</a>
|
||||||
|
<a href="/me/c/{{.Alias}}" {{if and (hasPrefix .Path "/me/c/") (hasSuffix .Path .Alias)}}class="selected"{{end}}>Customize</a>
|
||||||
|
<a href="/me/c/{{.Alias}}/stats" {{if hasSuffix .Path "/stats"}}class="selected"{{end}}>Stats</a>
|
||||||
|
<a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">View Blog →</a>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
{{end}}
|
|
@ -20,7 +20,11 @@ td.none {
|
||||||
{{if .Silenced}}
|
{{if .Silenced}}
|
||||||
{{template "user-silenced"}}
|
{{template "user-silenced"}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<h2 id="posts-header">{{if .Collection}}{{.Collection.DisplayTitle}} {{end}}Stats</h2>
|
<h1 id="posts-header">{{if .Collection}}{{.Collection.DisplayTitle}} {{end}}Stats</h1>
|
||||||
|
|
||||||
|
{{if .Collection}}
|
||||||
|
{{template "collection-nav" (dict "Alias" .Collection.Alias "Path" .Path "SingleUser" .SingleUser)}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<p>Stats for all time.</p>
|
<p>Stats for all time.</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue