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 }}">
<style>
header {
background-color: {{.HeaderColor}};
background-color: {{.UserConfig.HeaderColor}};
}
footer {
border-top: dashed 2px;
border-color: #ccc;
}
hgroup h2 a { color: inherit; }
</style>
</head>
@ -23,8 +29,8 @@
<ul>
<li>
<hgroup>
<h2><a href="{{ .User.UrlPath }}">{{ .UserTitle }}</a></h2>
<h3>{{ .UserSubtitle }}</h3>
<h2><a href="{{ .User.UrlPath }}">{{ .UserConfig.Title }}</a></h2>
<h3>{{ .UserConfig.SubTitle }}</h3>
</hgroup>
</li>
</ul>
@ -35,6 +41,13 @@
{{ .Content }}
</main>
<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>
</body>

View File

@ -50,16 +50,14 @@ func renderIntoBaseTemplate(user User, data PageContent) (string, error) {
Title string
Content template.HTML
User User
UserTitle string
UserConfig UserConfig
UserSubtitle string
HeaderColor string
}{
Title: data.Title,
Content: data.Content,
User: user,
UserTitle: user_config.Title,
UserSubtitle: user_config.SubTitle,
HeaderColor: user_config.HeaderColor,
UserConfig: user_config,
}
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) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost")

View File

@ -21,6 +21,7 @@ type UserConfig struct {
Title string `yaml:"title"`
SubTitle string `yaml:"subtitle"`
HeaderColor string `yaml:"header_color"`
TwitterHandle string `yaml:"twitter_handle"`
}
func (user User) Dir() string {