コード例 #1
0
ファイル: admin.go プロジェクト: relvinhas/ironzebra
func (c Admin) SaveNew(title, subtitle, category, body string) revel.Result {
	slugString := slug.Make(title)
	validatePost(c, title, body, slugString, category)
	collection := c.Database.C("posts")
	result := addPost(c.Database, collection, title, subtitle, slugString, category, body)
	return c.Redirect(routes.Blog.Show(result.Category, result.ShortID, result.Slug))
}
コード例 #2
0
ファイル: admin.go プロジェクト: relvinhas/ironzebra
func (c Admin) Save(id int, title, subtitle, slugString, category, body, publish string) revel.Result {
	validatePost(c, title, body, slugString, category)
	collection := c.Database.C("posts")
	if slugString == "" {
		slugString = slug.Make(title)
	}
	result := savePost(collection, id, title, subtitle, slugString, category, body)
	return c.Redirect(routes.Blog.Show(result.Category, result.ShortID, result.Slug))
}
コード例 #3
0
ファイル: admin.go プロジェクト: netsharec/ironzebra
func (c Admin) SaveNew(title, subtitle, category, body, image string) revel.Result {
	slugString := slug.Make(title)
	validatePost(c, title, body, slugString, category)
	if c.Validation.HasErrors() {
		// Store the validation errors in the flash context and redirect.
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.Admin.New())
	}
	collection := c.Database.C("posts")
	result := addPost(c.Database, collection, title, subtitle, slugString, category, body, image)
	return c.Redirect(routes.Blog.Show(result.Category, result.ShortID, result.Slug))
}
コード例 #4
0
ファイル: admin.go プロジェクト: netsharec/ironzebra
func (c Admin) Save(id int, title, subtitle, slugString, category, body, publish, image string) revel.Result {
	validatePost(c, title, body, slugString, category)
	if c.Validation.HasErrors() {
		// Store the validation errors in the flash context and redirect.
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.Admin.Edit(id, slugString))
	}
	collection := c.Database.C("posts")
	if slugString == "" {
		slugString = slug.Make(title)
	}
	result := savePost(collection, id, title, subtitle, slugString, category, body, image)
	return c.Redirect(routes.Blog.Show(result.Category, result.ShortID, result.Slug))
}