예제 #1
0
func RenderHome(ctx *webapp.Context) error {
	vars := make(map[string]interface{})
	data := MakeData(ctx, vars)
	data.Flags.Home = true
	err := ctx.Execute(mainTPL, &data)
	return err
}
예제 #2
0
func RenderWriterSettings(ctx *webapp.Context, msg string) error {
	vars := make(map[string]interface{})
	vars["Message"] = msg
	data := MakeData(ctx, vars)
	data.Flags.WriterSettings = true
	err := ctx.Execute(writerTPL, &data)
	return err
}
예제 #3
0
func RenderWriterEditor(ctx *webapp.Context, article *Article) error {
	vars := make(map[string]interface{})
	vars["Article"] = article
	data := MakeData(ctx, vars)
	data.Flags.WriterEditor = true
	err := ctx.Execute(editorTPL, &data)
	return err
}
예제 #4
0
func RenderFeedAtom(ctx *webapp.Context) error {
	vars := make(map[string]interface{})
	vars["Declaration"] = template.HTML("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
	data := MakeData(ctx, vars)
	data.Flags.Feed = true
	ctx.SetHeader("Content-Type", "application/atom+xml")
	err := ctx.Execute(feedTPL, &data)
	return err
}
예제 #5
0
func RenderGuard(ctx *webapp.Context, hint string) error {
	vars := make(map[string]interface{})
	vars["Error"] = ""
	if len(hint) != 0 {
		vars["Error"] = hint
	}
	data := MakeData(ctx, vars)
	err := ctx.Execute(guardTPL, &data)
	return err
}
예제 #6
0
func Render404page(ctx *webapp.Context, msg string) error {
	if notFoundTPL != nil {
		vars := make(map[string]interface{})
		vars["Message"] = msg
		vars["URL"] = ctx.Request.RequestURI
		vars["Referer"] = ctx.Request.Referer()
		data := MakeData(ctx, vars)
		err := ctx.Execute(notFoundTPL, &data)
		return err
	} else {
		ctx.Error(fmt.Sprintf("%s: %s", webapp.ErrNotFound, msg),
			http.StatusNotFound)
		return nil
	}
	return nil
}
예제 #7
0
func RenderSinglePage(ctx *webapp.Context, name string, lastMeta *CommentMetadata) error {
	vars := make(map[string]interface{})
	vars["Name"] = name
	vars["LastCommentMeta"] = lastMeta
	data := MakeData(ctx, vars)
	meta, err := TattooDB.GetMeta(name)
	if err != nil {
		return err
	}
	if meta.IsPage {
		data.Flags.Page = true
	} else {
		data.Flags.Single = true
	}
	err = ctx.Execute(mainTPL, &data)
	return err
}
예제 #8
0
func RenderWriterComments(ctx *webapp.Context, offset int) error {
	vars := make(map[string]interface{})
	vars["Offset"] = offset

	vars["AtBegin"] = false
	vars["AtEnd"] = false
	vars["Offset"] = offset
	if TattooDB.GetCommentCount()-1-offset < 20 {
		vars["AtEnd"] = true
	}
	if offset < 20 {
		vars["AtBegin"] = true
	}
	data := MakeData(ctx, vars)
	data.Flags.WriterComments = true
	err := ctx.Execute(writerTPL, &data)
	return err
}
예제 #9
0
func RenderArticles(ctx *webapp.Context, offset int) error {
	vars := make(map[string]interface{})
	vars["Offset"] = offset

	vars["AtBegin"] = false
	vars["AtEnd"] = false
	vars["Offset"] = offset
	if TattooDB.GetArticleCount()-1-offset < GetConfig().TimelineCount {
		vars["AtEnd"] = true
	}
	if offset < GetConfig().TimelineCount {
		vars["AtBegin"] = true
	}
	data := MakeData(ctx, vars)
	data.Flags.Articles = true
	err := ctx.Execute(mainTPL, &data)
	return err
}
예제 #10
0
func RenderTagPage(ctx *webapp.Context, offset int, tag string) error {
	vars := make(map[string]interface{})
	tag = strings.Trim(tag, " ")
	if !TattooDB.HasTag(tag) {
		return errors.New(webapp.ErrNotFound)
	}

	vars["Offset"] = offset
	vars["Tag"] = tag
	vars["AtBegin"] = false
	vars["AtEnd"] = false
	if TattooDB.GetTagArticleCount(tag)-1-offset < GetConfig().TimelineCount {
		vars["AtEnd"] = true
	}
	if offset < GetConfig().TimelineCount {
		vars["AtBegin"] = true
	}
	data := MakeData(ctx, vars)
	data.Flags.Tag = true
	err := ctx.Execute(mainTPL, &data)
	return err
}