Support index.html indexes in content directory

If a file named index.html exists in a directory, or root, it will be
rendered as if ugly urls are turned on.  This allows for top level
content to not need a supporting layout file and content in content.
This change should not affect anyone who is using the perscribed way.

I also cleaned up a bunch of one off functions in site.go.
This commit is contained in:
Noah Campbell
2013-09-24 21:24:49 -07:00
parent 4250bf8e30
commit db50154e75
4 changed files with 49 additions and 28 deletions

View File

@@ -30,6 +30,7 @@ import (
"sort"
"strings"
"time"
"net/url"
)
type Page struct {
@@ -191,7 +192,7 @@ func (p *Page) analyzePage() {
p.FuzzyWordCount = int((p.WordCount+100)/100) * 100
}
func (p *Page) Permalink() template.HTML {
func (p *Page) Permalink() (string, error) {
baseUrl := string(p.Site.BaseUrl)
section := strings.TrimSpace(p.Section)
pSlug := strings.TrimSpace(p.Slug)
@@ -215,7 +216,18 @@ func (p *Page) Permalink() template.HTML {
permalink = section + "/" + file
}
}
return template.HTML(MakePermalink(baseUrl, permalink))
base, err := url.Parse(baseUrl)
if err != nil {
return "", err
}
path, err := url.Parse(permalink)
if err != nil {
return "", err
}
return MakePermalink(base, path).String(), nil
}
func (page *Page) handleTomlMetaData(datum []byte) (interface{}, error) {