Exemple #1
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)
	}
}
Exemple #2
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
}
Exemple #3
0
func (s *Site) permalinkStr(plink string) string {
	return helpers.MakePermalink(string(viper.GetString("BaseUrl")), helpers.UrlizeAndPrep(plink)).String()
}
Exemple #4
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")
}