added author name. Resolves #21
This commit is contained in:
parent
1179263818
commit
4cc69ff257
|
@ -5,12 +5,12 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<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="webmention" href="{{ .User.WebmentionUrl }}">
|
||||
<style>
|
||||
header {
|
||||
background-color: {{.UserConfig.HeaderColor}};
|
||||
background-color: {{.User.Config.HeaderColor}};
|
||||
}
|
||||
|
||||
footer {
|
||||
|
@ -47,21 +47,21 @@
|
|||
<header>
|
||||
<div class="container header h-card">
|
||||
<hgroup class="header-title">
|
||||
<h2><a class="p-name u-url" href="{{ .User.UrlPath }}">{{ .UserConfig.Title }}</a></h2>
|
||||
<h3 class="p-note">{{ .UserConfig.SubTitle }}</h3>
|
||||
<h2><a class="p-name u-url" href="{{ .User.UrlPath }}">{{ .User.Config.Title }}</a></h2>
|
||||
<h3 class="p-note">{{ .User.Config.SubTitle }}</h3>
|
||||
</hgroup>
|
||||
|
||||
<div class="header-profile">
|
||||
{{ 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 }}
|
||||
<div style="float: right; list-style: none;">
|
||||
{{ if .UserConfig.TwitterHandle}}
|
||||
<li><a href="https://twitter.com/{{.UserConfig.TwitterHandle}}" rel="me">@{{.UserConfig.TwitterHandle}} on Twitter</a>
|
||||
{{ if .User.Config.TwitterHandle}}
|
||||
<li><a href="https://twitter.com/{{.User.Config.TwitterHandle}}" rel="me">@{{.User.Config.TwitterHandle}} on Twitter</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .UserConfig.GitHubHandle}}
|
||||
<li><a href="https://github.com/{{.UserConfig.GitHubHandle}}" rel="me">@{{.UserConfig.GitHubHandle}} on GitHub</a>
|
||||
{{ if .User.Config.GitHubHandle}}
|
||||
<li><a href="https://github.com/{{.User.Config.GitHubHandle}}" rel="me">@{{.User.Config.GitHubHandle}} on GitHub</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
<time class="dt-published" datetime="{{.Post.Meta.Date}}">
|
||||
{{.Post.Meta.FormattedDate}}
|
||||
</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>
|
||||
</small>
|
||||
</hgroup>
|
||||
|
|
4
post.go
4
post.go
|
@ -99,6 +99,10 @@ func (post *Post) Id() string {
|
|||
return post.id
|
||||
}
|
||||
|
||||
func (post *Post) User() *User {
|
||||
return post.user
|
||||
}
|
||||
|
||||
func (post *Post) Dir() string {
|
||||
return path.Join(post.user.Dir(), "public", post.id)
|
||||
}
|
||||
|
|
|
@ -45,19 +45,16 @@ func renderIntoBaseTemplate(user User, data PageContent) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
|
||||
user_config, _ := user.Config()
|
||||
full_data := struct {
|
||||
Title string
|
||||
Content template.HTML
|
||||
User User
|
||||
UserConfig UserConfig
|
||||
UserSubtitle string
|
||||
HeaderColor string
|
||||
}{
|
||||
Title: data.Title,
|
||||
Content: data.Content,
|
||||
User: user,
|
||||
UserConfig: user_config,
|
||||
Title: data.Title,
|
||||
Content: data.Content,
|
||||
User: user,
|
||||
}
|
||||
|
||||
var html bytes.Buffer
|
||||
|
|
|
@ -261,3 +261,19 @@ func TestAddAvatarIfExist(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue