Example #1
0
File: blog.go Project: bishen/blog
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)
}
Example #2
0
File: blog.go Project: bishen/blog
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)
}
Example #3
0
File: blog.go Project: bishen/blog
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)
}
Example #4
0
File: blog.go Project: bishen/blog
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)
	}
}
Example #5
0
File: blog.go Project: bishen/blog
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)
	}
}
Example #6
0
File: blog.go Project: bishen/blog
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)
}
Example #7
0
File: blog.go Project: bishen/blog
func Login(res http.ResponseWriter, jade *gojade.Engine) {
	jade.RenderFileW(res, "login", nil)
}
Example #8
0
File: blog.go Project: bishen/blog
func NotFound(rw http.ResponseWriter, jade *gojade.Engine) {
	jade.RenderFileW(rw, "404", nil)
}