Merge branch 'redirect' of https://github.com/rozza/hugo into rozza-redirect
authorspf13 <steve.francia@gmail.com>
Sat, 10 Aug 2013 13:08:38 +0000 (14:08 +0100)
committerspf13 <steve.francia@gmail.com>
Sat, 10 Aug 2013 13:08:38 +0000 (14:08 +0100)
Conflicts:
hugolib/page.go

1  2 
hugolib/page.go

diff --cc hugolib/page.go
index 450f32a1f074e09bd43f00b6551de387c4ea334e,93f2f6dbeb9fa002b96fee25abeac4d5a530f07a..a0134c50d970e7cbdcfea17af0eeffdba80d9ff2
@@@ -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: