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

	pages := model.PagesFromTree(tree)

	render.JSON(200, pages)
}
示例#2
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])
	}
}
示例#3
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)
	}
}