added author name. Resolves #21
This commit is contained in:
parent
1179263818
commit
4cc69ff257
|
@ -5,12 +5,12 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{ .Title }} - {{ .UserConfig.Title }}</title>
|
<title>{{ .Title }} - {{ .User.Config.Title }}</title>
|
||||||
<link rel="stylesheet" href="/static/pico.min.css">
|
<link rel="stylesheet" href="/static/pico.min.css">
|
||||||
<link rel="webmention" href="{{ .User.WebmentionUrl }}">
|
<link rel="webmention" href="{{ .User.WebmentionUrl }}">
|
||||||
<style>
|
<style>
|
||||||
header {
|
header {
|
||||||
background-color: {{.UserConfig.HeaderColor}};
|
background-color: {{.User.Config.HeaderColor}};
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
|
@ -47,21 +47,21 @@
|
||||||
<header>
|
<header>
|
||||||
<div class="container header h-card">
|
<div class="container header h-card">
|
||||||
<hgroup class="header-title">
|
<hgroup class="header-title">
|
||||||
<h2><a class="p-name u-url" href="{{ .User.UrlPath }}">{{ .UserConfig.Title }}</a></h2>
|
<h2><a class="p-name u-url" href="{{ .User.UrlPath }}">{{ .User.Config.Title }}</a></h2>
|
||||||
<h3 class="p-note">{{ .UserConfig.SubTitle }}</h3>
|
<h3 class="p-note">{{ .User.Config.SubTitle }}</h3>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
||||||
<div class="header-profile">
|
<div class="header-profile">
|
||||||
{{ if .User.AvatarUrl }}
|
{{ if .User.AvatarUrl }}
|
||||||
<img class="u-logo avatar" src="{{ .User.AvatarUrl }}" alt="{{ .UserConfig.Title }}" width="100" height="100" />
|
<img class="u-logo avatar" src="{{ .User.AvatarUrl }}" alt="{{ .User.Config.Title }}" width="100" height="100" />
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<div style="float: right; list-style: none;">
|
<div style="float: right; list-style: none;">
|
||||||
{{ if .UserConfig.TwitterHandle}}
|
{{ if .User.Config.TwitterHandle}}
|
||||||
<li><a href="https://twitter.com/{{.UserConfig.TwitterHandle}}" rel="me">@{{.UserConfig.TwitterHandle}} on Twitter</a>
|
<li><a href="https://twitter.com/{{.User.Config.TwitterHandle}}" rel="me">@{{.User.Config.TwitterHandle}} on Twitter</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if .UserConfig.GitHubHandle}}
|
{{ if .User.Config.GitHubHandle}}
|
||||||
<li><a href="https://github.com/{{.UserConfig.GitHubHandle}}" rel="me">@{{.UserConfig.GitHubHandle}} on GitHub</a>
|
<li><a href="https://github.com/{{.User.Config.GitHubHandle}}" rel="me">@{{.User.Config.GitHubHandle}} on GitHub</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
<time class="dt-published" datetime="{{.Post.Meta.Date}}">
|
<time class="dt-published" datetime="{{.Post.Meta.Date}}">
|
||||||
{{.Post.Meta.FormattedDate}}
|
{{.Post.Meta.FormattedDate}}
|
||||||
</time>
|
</time>
|
||||||
|
{{ if .Post.User.Config.AuthorName }}
|
||||||
|
by
|
||||||
|
<a class="p-author h-card" href="{{.Post.User.FullUrl}}">{{.Post.User.Config.AuthorName}}</a>
|
||||||
|
{{ end }}
|
||||||
<a class="u-url" href="{{.Post.FullUrl}}">#</a>
|
<a class="u-url" href="{{.Post.FullUrl}}">#</a>
|
||||||
</small>
|
</small>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
4
post.go
4
post.go
|
@ -99,6 +99,10 @@ func (post *Post) Id() string {
|
||||||
return post.id
|
return post.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (post *Post) User() *User {
|
||||||
|
return post.user
|
||||||
|
}
|
||||||
|
|
||||||
func (post *Post) Dir() string {
|
func (post *Post) Dir() string {
|
||||||
return path.Join(post.user.Dir(), "public", post.id)
|
return path.Join(post.user.Dir(), "public", post.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,19 +45,16 @@ func renderIntoBaseTemplate(user User, data PageContent) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
user_config, _ := user.Config()
|
|
||||||
full_data := struct {
|
full_data := struct {
|
||||||
Title string
|
Title string
|
||||||
Content template.HTML
|
Content template.HTML
|
||||||
User User
|
User User
|
||||||
UserConfig UserConfig
|
|
||||||
UserSubtitle string
|
UserSubtitle string
|
||||||
HeaderColor string
|
HeaderColor string
|
||||||
}{
|
}{
|
||||||
Title: data.Title,
|
Title: data.Title,
|
||||||
Content: data.Content,
|
Content: data.Content,
|
||||||
User: user,
|
User: user,
|
||||||
UserConfig: user_config,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var html bytes.Buffer
|
var html bytes.Buffer
|
||||||
|
|
|
@ -261,3 +261,19 @@ func TestAddAvatarIfExist(t *testing.T) {
|
||||||
t.Error("Avatar not rendered. Got: " + result)
|
t.Error("Avatar not rendered. Got: " + result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAuthorNameInPost(t *testing.T) {
|
||||||
|
user := getTestUser()
|
||||||
|
user.SetConfig(owl.UserConfig{
|
||||||
|
Title: "Test Title",
|
||||||
|
SubTitle: "Test SubTitle",
|
||||||
|
HeaderColor: "#ff1337",
|
||||||
|
AuthorName: "Test Author",
|
||||||
|
})
|
||||||
|
post, _ := user.CreateNewPost("testpost")
|
||||||
|
|
||||||
|
result, _ := owl.RenderPost(&post)
|
||||||
|
if !strings.Contains(result, "Test Author") {
|
||||||
|
t.Error("Author Name not included. Got: " + result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
user.go
1
user.go
|
@ -23,6 +23,7 @@ type UserConfig struct {
|
||||||
HeaderColor string `yaml:"header_color"`
|
HeaderColor string `yaml:"header_color"`
|
||||||
TwitterHandle string `yaml:"twitter_handle"`
|
TwitterHandle string `yaml:"twitter_handle"`
|
||||||
GitHubHandle string `yaml:"github_handle"`
|
GitHubHandle string `yaml:"github_handle"`
|
||||||
|
AuthorName string `yaml:"author_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user User) Dir() string {
|
func (user User) Dir() string {
|
||||||
|
|
Loading…
Reference in New Issue