func Classify(rw http.ResponseWriter, jade *gojade.Engine, db *gorm.DB) { cls := []models.Classify{} db.Find(&cls) data := &struct { Data []models.Classify }{ Data: cls, } jade.RenderFileW(rw, "class", data) }
func Create(rw http.ResponseWriter, jade *gojade.Engine, db *gorm.DB) { cls := []models.Classify{} db.Find(&cls) datas := &struct { Cls []models.Classify }{ Cls: cls, } jade.RenderFileW(rw, "create", datas) }
func Home(ad *fun.Admins, req *http.Request, res http.ResponseWriter, jade *gojade.Engine, db *gorm.DB) { blogs := []models.Blog{} db.Find(&blogs) datas := &struct { Title string Is bool Data []models.Blog }{ Title: "首页", Is: IsLogin(ad.Account, req), Data: blogs, } jade.RenderFileW(res, "home", datas) }
func View(ad *fun.Admins, params martini.Params, res http.ResponseWriter, req *http.Request, jade *gojade.Engine, db *gorm.DB) { blog := &models.Blog{} db.First(blog, params["id"]) if blog.Title != "" { data := &struct { B models.Blog Is bool }{ B: *blog, Is: IsLogin(ad.Account, req), } jade.RenderFileW(res, "view", data) } else { jade.RenderFileW(res, "404", nil) } }
func Tag(ad *fun.Admins, req *http.Request, params martini.Params, res http.ResponseWriter, jade *gojade.Engine, db *gorm.DB) { cs := models.Classify{} tag := params["tag"] db.Where("url=?", tag).First(&cs) if cs.Title != "" { blogs := []models.Blog{} db.Where("cid=?", cs.ID).Find(&blogs) data := &struct { Cls models.Classify Is bool Data []models.Blog }{ Cls: cs, Is: IsLogin(ad.Account, req), Data: blogs, } jade.RenderFileW(res, "tag", data) } else { jade.RenderFileW(res, "404", nil) } }
func Edit(params martini.Params, res http.ResponseWriter, jade *gojade.Engine, db *gorm.DB) { blog := models.Blog{} db.First(&blog, params["id"]) jade.RenderFileW(res, "edit", blog) }
func Login(res http.ResponseWriter, jade *gojade.Engine) { jade.RenderFileW(res, "login", nil) }
func NotFound(rw http.ResponseWriter, jade *gojade.Engine) { jade.RenderFileW(rw, "404", nil) }