Esempio n. 1
0
//Archive handles showing listing of presentations.
func Archive(c util.Context) (err error) {
	page, err := strconv.Atoi(c.Vars["page"])
	if err != nil {
		return
	}

	type tmplData struct {
		P *presentation.Presentation
		C int
	}
	ps, err := presentation.GetListing(page, 10, c)
	if err != nil {
		return
	}

	downloads := make([]tmplData, 0)
	for _, p := range ps {
		count, err := action.GetCountFor(action.Activated, p, c)
		if err != nil {
			c.Infof("Error when getting download count: %v", err)
			count = -1
		}
		downloads = append(downloads, tmplData{p, count})
	}

	maxPages, err := presentation.PageCount(10, c)
	if err != nil {
		return
	}

	util.RenderLayout("archive.html", "Archív prezentácií", struct {
		Data     []tmplData
		Page     int
		MaxPages int
		Tz       *time.Location
	}{downloads, page, maxPages, util.Tz}, c)
	return
}
Esempio n. 2
0
//Presentations shows listing of presentations in paginated form.
func Presentations(c util.Context) (err error) {
	page, err := strconv.Atoi(c.R.FormValue("p"))
	if err != nil {
		return
	}
	ps, err := presentation.GetListing(page, perPage, c)
	if err != nil {
		return
	}

	type templateData struct {
		P presentation.Presentation
		D template.HTML
	}

	data := make([]templateData, len(ps), len(ps))

	for _, p := range ps {
		data = append(data, templateData{P: *p, D: template.HTML(blackfriday.MarkdownCommon(p.Description))})
	}

	maxPages, err := presentation.PageCount(perPage, c)
	if err != nil {
		return
	}

	c.Infof("Hostname: %v", appengine.DefaultVersionHostname(c))

	util.RenderLayout("index.html", "Zoznam vysielaní", struct {
		Page     int
		MaxPages int
		Data     []templateData
		Domain   string
	}{Page: page, MaxPages: maxPages, Data: data, Domain: appengine.DefaultVersionHostname(c)}, c, "/static/js/index.js")
	return
}