footer menu
This commit is contained in:
parent
8f2e2cd5f6
commit
a717164334
|
@ -108,6 +108,19 @@
|
|||
{{ .Content }}
|
||||
</main>
|
||||
<footer class="container">
|
||||
<nav>
|
||||
<ul>
|
||||
{{ range $link := .User.Config.FooterMenu }}
|
||||
{{ if $link.List }}
|
||||
<li><a href="{{ listUrl $.User $link.List }}">{{ $link.Title }}</a></li>
|
||||
{{ else if $link.Post }}
|
||||
<li><a href="{{ postUrl $.User $link.Post }}">{{ $link.Title }}</a></li>
|
||||
{{ else }}
|
||||
<li><a href="{{ $link.Url }}">{{ $link.Title }}</a></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</nav>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -448,3 +448,37 @@ func TestRenderHeaderMenuPost(t *testing.T) {
|
|||
assertions.AssertContains(t, result, "Test Entry")
|
||||
assertions.AssertContains(t, result, post.UrlPath())
|
||||
}
|
||||
|
||||
func TestRenderFooterMenuListItem(t *testing.T) {
|
||||
user := getTestUser()
|
||||
user.AddFooterMenuItem(owl.MenuItem{
|
||||
Title: "Test Entry",
|
||||
List: "test",
|
||||
})
|
||||
result, _ := owl.RenderIndexPage(user)
|
||||
assertions.AssertContains(t, result, "Test Entry")
|
||||
assertions.AssertContains(t, result, "/lists/test")
|
||||
}
|
||||
|
||||
func TestRenderFooterMenuUrlItem(t *testing.T) {
|
||||
user := getTestUser()
|
||||
user.AddFooterMenuItem(owl.MenuItem{
|
||||
Title: "Test Entry",
|
||||
Url: "https://example.com",
|
||||
})
|
||||
result, _ := owl.RenderIndexPage(user)
|
||||
assertions.AssertContains(t, result, "Test Entry")
|
||||
assertions.AssertContains(t, result, "https://example.com")
|
||||
}
|
||||
|
||||
func TestRenderFooterMenuPost(t *testing.T) {
|
||||
user := getTestUser()
|
||||
post, _ := user.CreateNewPost("testpost", false)
|
||||
user.AddFooterMenuItem(owl.MenuItem{
|
||||
Title: "Test Entry",
|
||||
Post: post.Id(),
|
||||
})
|
||||
result, _ := owl.RenderIndexPage(user)
|
||||
assertions.AssertContains(t, result, "Test Entry")
|
||||
assertions.AssertContains(t, result, post.UrlPath())
|
||||
}
|
||||
|
|
7
user.go
7
user.go
|
@ -29,6 +29,7 @@ type UserConfig struct {
|
|||
Lists []PostList `yaml:"lists"`
|
||||
PrimaryListInclude []string `yaml:"primary_list_include"`
|
||||
HeaderMenu []MenuItem `yaml:"header_menu"`
|
||||
FooterMenu []MenuItem `yaml:"footer_menu"`
|
||||
}
|
||||
|
||||
type PostList struct {
|
||||
|
@ -404,6 +405,12 @@ func (user User) AddHeaderMenuItem(link MenuItem) error {
|
|||
return user.SetConfig(config)
|
||||
}
|
||||
|
||||
func (user User) AddFooterMenuItem(link MenuItem) error {
|
||||
config := user.Config()
|
||||
config.FooterMenu = append(config.FooterMenu, link)
|
||||
return user.SetConfig(config)
|
||||
}
|
||||
|
||||
func (user User) ResetPassword(password string) error {
|
||||
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 10)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue