Sending Webmentions #10

Merged
h4kor merged 18 commits from webmention into master 2022-09-06 19:49:00 +00:00
4 changed files with 44 additions and 13 deletions
Showing only changes of commit 63f89491f3 - Show all commits

View File

@ -10,9 +10,15 @@
<link rel="webmention" href="{{ .User.WebmentionUrl }}"> <link rel="webmention" href="{{ .User.WebmentionUrl }}">
<style> <style>
header { header {
background-color: {{.HeaderColor}}; background-color: {{.UserConfig.HeaderColor}};
} }
footer {
border-top: dashed 2px;
border-color: #ccc;
}
hgroup h2 a { color: inherit; } hgroup h2 a { color: inherit; }
</style> </style>
</head> </head>
@ -23,8 +29,8 @@
<ul> <ul>
<li> <li>
<hgroup> <hgroup>
<h2><a href="{{ .User.UrlPath }}">{{ .UserTitle }}</a></h2> <h2><a href="{{ .User.UrlPath }}">{{ .UserConfig.Title }}</a></h2>
<h3>{{ .UserSubtitle }}</h3> <h3>{{ .UserConfig.SubTitle }}</h3>
</hgroup> </hgroup>
</li> </li>
</ul> </ul>
@ -35,6 +41,13 @@
{{ .Content }} {{ .Content }}
</main> </main>
<footer class="container"> <footer class="container">
<nav>
<ul>
{{ if .UserConfig.TwitterHandle}}
<li><a href="https://twitter.com/{{.UserConfig.TwitterHandle}}" rel="me">@{{.UserConfig.TwitterHandle}} on Twitter</a></li>
{{ end }}
</ul>
</nav>
</footer> </footer>
</body> </body>

View File

@ -50,16 +50,14 @@ func renderIntoBaseTemplate(user User, data PageContent) (string, error) {
Title string Title string
Content template.HTML Content template.HTML
User User User User
UserTitle string 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,
UserTitle: user_config.Title, UserConfig: user_config,
UserSubtitle: user_config.SubTitle,
HeaderColor: user_config.HeaderColor,
} }
var html bytes.Buffer var html bytes.Buffer

View File

@ -25,6 +25,25 @@ func TestCanRenderPost(t *testing.T) {
} }
func TestRenderTwitterHandle(t *testing.T) {
user := getTestUser()
config, _ := user.Config()
config.TwitterHandle = "testhandle"
user.SetConfig(config)
post, _ := user.CreateNewPost("testpost")
result, err := owl.RenderPost(&post)
if err != nil {
t.Error("Error rendering post: " + err.Error())
return
}
if !strings.Contains(result, "href=\"https://twitter.com/testhandle\" rel=\"me\"") {
t.Error("Twitter handle not rendered. Got: " + result)
}
}
func TestRenderPostHEntry(t *testing.T) { func TestRenderPostHEntry(t *testing.T) {
user := getTestUser() user := getTestUser()
post, _ := user.CreateNewPost("testpost") post, _ := user.CreateNewPost("testpost")

View File

@ -18,9 +18,10 @@ type User struct {
} }
type UserConfig struct { 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"`
} }
func (user User) Dir() string { func (user User) Dir() string {