Example #1
0
func pagePreview(ctx *web.Context) string {
	if app.RequireAuthentication(ctx) {
		return ""
	}
	var page = new(Page)
	page.FromParams(ctx.Params)
	return template.RenderMarkdown(page.Content)
}
Example #2
0
// Instantiate a post object from POST parameters
func (p *Post) FromParams(params map[string]string) error {
	if len(params["id"]) > 0 {
		p.Id = bson.ObjectIdHex(params["id"])
	}
	p.Content = params["content"]
	p.Title = params["title"]
	p.Slug = params["slug"]
	if len(params["timestamp"]) > 0 {
		ts, err := strconv.ParseInt(params["timestamp"], 10, 0)
		if err != nil {
			return err
		}
		p.Timestamp = uint64(ts)
	} else {
		p.Timestamp = uint64(time.Now().Unix())
	}
	p.Published, _ = strconv.Atoi(params["published"])
	p.ContentRendered = template.RenderMarkdown(p.Content)
	return nil
}
Example #3
0
func (p *Post) PreSave() {
	p.ContentRendered = template.RenderMarkdown(p.Content)
}
Example #4
0
func (p *Page) PreSave() {
	p.ContentRendered = template.RenderMarkdown(p.Content)
	p.Url = strings.TrimLeft(p.Url, "/")
}