From: spf13 Date: Sat, 10 Aug 2013 13:08:38 +0000 (+0100) Subject: Merge branch 'redirect' of https://github.com/rozza/hugo into rozza-redirect X-Git-Tag: v0.9~175 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=45ce6e2b309dc247315885db4de4d03192b93914;p=brevno-suite%2Fhugo Merge branch 'redirect' of https://github.com/rozza/hugo into rozza-redirect Conflicts: hugolib/page.go --- 45ce6e2b309dc247315885db4de4d03192b93914 diff --cc hugolib/page.go index 450f32a1,93f2f6db..a0134c50 --- a/hugolib/page.go +++ b/hugolib/page.go @@@ -46,6 -42,7 +46,7 @@@ type Page struct RenderedContent *bytes.Buffer contentType string Draft bool - Redirect bool ++ Aliases []string Tmpl *template.Template Markup string PageMeta @@@ -94,13 -92,18 +95,25 @@@ func initializePage(filename string) (p func (p *Page) setSection() { x := strings.Split(p.FileName, string(os.PathSeparator)) - section := x[len(x)-2] - - c := p.Site.Config - systemDirs := map[string] bool { - c.ContentDir: true, - c.StaticDir: true, - c.LayoutDir: true, + if len(x) <= 1 { + return } - if !systemDirs[section] && !p.Redirect { ++ //section := x[len(x)-2] + if section := x[len(x)-2]; section != "content" { p.Section = section } ++ ++ //c := p.Site.Config ++ //systemDirs := map[string]bool{ ++ //c.ContentDir: true, ++ //c.StaticDir: true, ++ //c.LayoutDir: true, ++ //} ++ ++ //if !systemDirs[section] && !p.Redirect { ++ //p.Section = section ++ //} } func (page *Page) Type() string { @@@ -151,8 -138,10 +164,9 @@@ func ReadFrom(buf io.Reader, name strin // TODO initalize separately... load from reader (file, or []byte) func NewPage(filename string) *Page { p := initializePage(filename) + if err := p.buildPageFromFile(); err != nil { fmt.Println(err) - os.Exit(1) } p.analyzePage() @@@ -264,6 -308,8 +278,13 @@@ func (page *Page) update(f interface{} page.layout = interfaceToString(v) case "markup": page.Markup = interfaceToString(v) - case "redirect": - page.Redirect = interfaceToBool(v) ++ case "aliases": ++ page.Aliases = interfaceArrayToStringArray(v) ++ for _, alias := range page.Aliases { ++ if strings.HasPrefix(alias, "http://") || strings.HasPrefix(alias, "https://") { ++ return fmt.Errorf("Only relative aliases are supported, %v provided", alias) ++ } ++ } case "status": page.Status = interfaceToString(v) default: