Ejemplo n.º 1
0
Archivo: site.go Proyecto: maruel/hugo
func (s *SiteInfo) createNodeMenuEntryURL(in string) string {

	if !strings.HasPrefix(in, "/") {
		return in
	}
	// make it match the nodes
	menuEntryURL := in
	menuEntryURL = helpers.URLizeAndPrep(menuEntryURL)
	if !s.canonifyURLs {
		menuEntryURL = helpers.AddContextRoot(string(s.BaseURL), menuEntryURL)
	}
	return menuEntryURL
}
Ejemplo n.º 2
0
func newPaginationURLFactory(pathElements ...string) paginationURLFactory {
	paginatePath := viper.GetString("paginatePath")

	return func(page int) string {
		var rel string
		if page == 1 {
			rel = fmt.Sprintf("/%s/", path.Join(pathElements...))
		} else {
			rel = fmt.Sprintf("/%s/%s/%d/", path.Join(pathElements...), paginatePath, page)
		}

		return helpers.URLizeAndPrep(rel)
	}
}
Ejemplo n.º 3
0
func (s *Site) getMenusFromConfig() Menus {

	ret := Menus{}

	if menus := viper.GetStringMap("menu"); menus != nil {
		for name, menu := range menus {
			m, err := cast.ToSliceE(menu)
			if err != nil {
				jww.ERROR.Printf("unable to process menus in site config\n")
				jww.ERROR.Println(err)
			} else {
				for _, entry := range m {
					jww.DEBUG.Printf("found menu: %q, in site config\n", name)

					menuEntry := MenuEntry{Menu: name}
					ime, err := cast.ToStringMapE(entry)
					if err != nil {
						jww.ERROR.Printf("unable to process menus in site config\n")
						jww.ERROR.Println(err)
					}

					menuEntry.MarshallMap(ime)

					if strings.HasPrefix(menuEntry.Url, "/") {
						// make it match the nodes
						menuEntryURL := menuEntry.Url
						menuEntryURL = helpers.URLizeAndPrep(menuEntryURL)
						if !s.Info.canonifyURLs {
							menuEntryURL = helpers.AddContextRoot(string(s.Info.BaseUrl), menuEntryURL)
						}
						menuEntry.Url = menuEntryURL
					}

					if ret[name] == nil {
						ret[name] = &Menu{}
					}
					*ret[name] = ret[name].Add(&menuEntry)
				}
			}
		}
		return ret
	}
	return ret
}
Ejemplo n.º 4
0
Archivo: site.go Proyecto: maruel/hugo
func (s *Site) permalinkStr(plink string) string {
	return helpers.MakePermalink(string(viper.GetString("BaseURL")), helpers.URLizeAndPrep(plink)).String()
}
Ejemplo n.º 5
0
Archivo: site.go Proyecto: maruel/hugo
func (s *Site) setURLs(n *Node, in string) {
	n.URL = helpers.URLizeAndPrep(in)
	n.Permalink = s.permalink(n.URL)
	n.RSSLink = template.HTML(s.permalink(in + ".xml"))
}
Ejemplo n.º 6
0
func (s *Site) setUrls(n *Node, in string) {
	n.Url = helpers.URLizeAndPrep(in)
	n.Permalink = s.permalink(n.Url)
	n.RSSLink = s.permalink(in + ".xml")
}