Exemple #1
0
func PageIndex(render render.Render) {
	tree := gorg.TreeFromFile(OrgFilePath)

	pages := model.PagesFromTree(tree)

	render.JSON(200, pages)
}
Exemple #2
0
func sectionTitles() []string {
	inPath, _ := filepath.Abs(api.OrgFilePath)
	tree := gorg.TreeFromFile(inPath)
	var sectionTitles []string

	for _, subtree := range tree.Subtrees {
		sectionTitles = append(sectionTitles, subtree.Nodes[0].Headline)
	}

	return sectionTitles
}
Exemple #3
0
func PageShow(args martini.Params, render render.Render) {
	tree := gorg.TreeFromFile(OrgFilePath)

	pages := model.PagesFromTree(tree)

	i, err := strconv.Atoi(args["id"])

	if i <= 0 || i > len(pages) || err != nil {
		render.JSON(404, "404 nothing here")
	} else {
		render.JSON(200, pages[i-1])
	}
}
Exemple #4
0
func PostIndex(args martini.Params, render render.Render) {
	inPath, _ := filepath.Abs(OrgFilePath)

	tree := gorg.TreeFromFile(inPath)

	pages := model.PagesFromTree(tree)

	i, err := strconv.Atoi(args["pageId"])

	if i <= 0 || i > len(pages) || err != nil {
		render.JSON(404, "404 nothing here")
	} else {
		render.JSON(200, pages[i-1].Posts)
	}
}