示例#1
0
文件: admin.go 项目: jseaidou/monet
func pagePreview(ctx *web.Context) string {
	if app.RequireAuthentication(ctx) {
		return ""
	}
	var page = new(Page)
	page.FromParams(ctx.Params)
	return template.RenderMarkdown(page.Content)
}
示例#2
0
文件: models.go 项目: inhies/monet
// 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
}
示例#3
0
文件: models.go 项目: inhies/monet
func (p *Post) PreSave() {
	p.ContentRendered = template.RenderMarkdown(p.Content)
}
示例#4
0
文件: models.go 项目: inhies/monet
func (p *Page) PreSave() {
	p.ContentRendered = template.RenderMarkdown(p.Content)
	p.Url = strings.TrimLeft(p.Url, "/")
}