func PageIndex(render render.Render) { tree := gorg.TreeFromFile(OrgFilePath) pages := model.PagesFromTree(tree) render.JSON(200, pages) }
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 }
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]) } }
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) } }