func removeScriptAction(r render.Render, repo script.ScriptRepository, params martini.Params) { id, _ := strconv.ParseInt(params["id"], 0, 64) repo.Delete(int(id)) r.JSON(200, nil) }
func editScriptAction(s *stickHandler, repo script.ScriptRepository, params martini.Params) { id, _ := strconv.ParseInt(params["id"], 0, 64) script := repo.Fetch(int(id)) s.HTML(200, "script/edit.html.twig", map[string]stick.Value{"script": script}) }
func createScriptAction(r render.Render, repo script.ScriptRepository, request *http.Request) { sType := request.FormValue("type") title := request.FormValue("title") body := request.FormValue("body") repo.Save(script.Script{0, script.ScriptType(sType), title, body, true}) r.Redirect("/script", 302) }
func updateScriptAction(r render.Render, repo script.ScriptRepository, params martini.Params, request *http.Request) { id, _ := strconv.ParseInt(params["id"], 0, 64) sType := request.FormValue("type") title := request.FormValue("title") body := request.FormValue("body") repo.Save(script.Script{int(id), script.ScriptType(sType), title, body, true}) r.Redirect("/script", 302) }
func scriptAction(s *stickHandler, repo script.ScriptRepository) { scripts := repo.FetchAll() s.HTML(200, "script/index.html.twig", map[string]stick.Value{"scripts": scripts}) }