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