Ejemplo n.º 1
0
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))
}
Ejemplo n.º 2
0
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))
}
Ejemplo n.º 3
0
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))
}
Ejemplo n.º 4
0
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))
}