General rel=me support. Resolves #13
This commit is contained in:
parent
94918b5b62
commit
8c1d7fd8c7
|
@ -75,12 +75,8 @@
|
||||||
<img class="u-photo u-logo avatar" src="{{ .User.AvatarUrl }}" alt="{{ .User.Config.Title }}" width="100" height="100" />
|
<img class="u-photo 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 .User.Config.TwitterHandle}}
|
{{ range $me := .User.Config.Me }}
|
||||||
<li><a href="https://twitter.com/{{.User.Config.TwitterHandle}}" rel="me">@{{.User.Config.TwitterHandle}} on Twitter</a>
|
<li><a href="{{$me.Url}}" rel="me">{{$me.Name}}</a>
|
||||||
</li>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .User.Config.GitHubHandle}}
|
|
||||||
<li><a href="https://github.com/{{.User.Config.GitHubHandle}}" rel="me">@{{.User.Config.GitHubHandle}} on GitHub</a>
|
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,10 +25,14 @@ func TestCanRenderPost(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRenderTwitterHandle(t *testing.T) {
|
func TestRenderOneMe(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
config, _ := user.Config()
|
config, _ := user.Config()
|
||||||
config.TwitterHandle = "testhandle"
|
config.Me = append(config.Me, owl.UserMe{
|
||||||
|
Name: "Twitter",
|
||||||
|
Url: "https://twitter.com/testhandle",
|
||||||
|
})
|
||||||
|
|
||||||
user.SetConfig(config)
|
user.SetConfig(config)
|
||||||
post, _ := user.CreateNewPost("testpost", false)
|
post, _ := user.CreateNewPost("testpost", false)
|
||||||
result, err := owl.RenderPost(post)
|
result, err := owl.RenderPost(post)
|
||||||
|
@ -44,10 +48,18 @@ func TestRenderTwitterHandle(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRenderGitHubHandle(t *testing.T) {
|
func TestRenderTwoMe(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
config, _ := user.Config()
|
config, _ := user.Config()
|
||||||
config.GitHubHandle = "testhandle"
|
config.Me = append(config.Me, owl.UserMe{
|
||||||
|
Name: "Twitter",
|
||||||
|
Url: "https://twitter.com/testhandle",
|
||||||
|
})
|
||||||
|
config.Me = append(config.Me, owl.UserMe{
|
||||||
|
Name: "Github",
|
||||||
|
Url: "https://github.com/testhandle",
|
||||||
|
})
|
||||||
|
|
||||||
user.SetConfig(config)
|
user.SetConfig(config)
|
||||||
post, _ := user.CreateNewPost("testpost", false)
|
post, _ := user.CreateNewPost("testpost", false)
|
||||||
result, err := owl.RenderPost(post)
|
result, err := owl.RenderPost(post)
|
||||||
|
@ -57,8 +69,11 @@ func TestRenderGitHubHandle(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result, "href=\"https://twitter.com/testhandle\" rel=\"me\"") {
|
||||||
|
t.Error("Twitter handle not rendered. Got: " + result)
|
||||||
|
}
|
||||||
if !strings.Contains(result, "href=\"https://github.com/testhandle\" rel=\"me\"") {
|
if !strings.Contains(result, "href=\"https://github.com/testhandle\" rel=\"me\"") {
|
||||||
t.Error("GitHub handle not rendered. Got: " + result)
|
t.Error("Github handle not rendered. Got: " + result)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
8
user.go
8
user.go
|
@ -20,9 +20,13 @@ type UserConfig struct {
|
||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
SubTitle string `yaml:"subtitle"`
|
SubTitle string `yaml:"subtitle"`
|
||||||
HeaderColor string `yaml:"header_color"`
|
HeaderColor string `yaml:"header_color"`
|
||||||
TwitterHandle string `yaml:"twitter_handle"`
|
|
||||||
GitHubHandle string `yaml:"github_handle"`
|
|
||||||
AuthorName string `yaml:"author_name"`
|
AuthorName string `yaml:"author_name"`
|
||||||
|
Me []UserMe `yaml:"me"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserMe struct {
|
||||||
|
Name string `yaml:"name"`
|
||||||
|
Url string `yaml:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user User) Dir() string {
|
func (user User) Dir() string {
|
||||||
|
|
Loading…
Reference in New Issue