Exemplo n.º 1
0
// Page theme.
func Handler(req *f.Request, res *f.Response, next func()) {
	asset := assets.New(res.Locals)
	asset.AddCss("/public_theme/bootstrap/css/bootstrap.min.css")
	asset.AddCss("/public_theme/css/screen.css")
	asset.Render()
	res.Render("public_theme/main.html")
}
Exemplo n.º 2
0
// Shows a list of articles for the given category.
func list(req *f.Request, res *f.Response, next func()) {

	// Should this be in a config?
	asset := assets.New(res.Locals)
	asset.AddCss("/jux_article/css/screen.css")

	// First fetch all the params needed.
	batch := 5
	start, _ := strconv.Atoi(req.Query["start"])
	category := strings.ToLower(req.Query["category"])

	// If "category" is empty check the config.
	if len(category) == 0 {
		category = "general"
	}

	articles, _ := GetArticles(req, category, start, batch)

	// Calculate the previous/next links.
	less := start - batch
	more := start + batch

	// Render the Summary as HTML.
	for _, article := range articles {
		article.InflateSummary()
	}
	res.Render("jux_article/list.html", map[string][]*Article{
		"Articles": articles,
	}, map[string]string{
		"Title":    LookUpCategory(req, category, "Articles"),
		"Less":     strconv.Itoa(less),
		"More":     strconv.Itoa(more),
		"Category": category,
	}, map[string]bool{
		"Show_less": less >= 0,
		"Show_more": batch == len(articles),
	})
}