Exemple #1
0
func (this *baseController) Prepare() {
	this.options = models.GetOptions()
	this.right = "right.html"
	this.Data["options"] = this.options
	this.Data["latestblog"] = models.GetLatestBlog()
	this.Data["hotblog"] = models.GetHotBlog()
	this.Data["links"] = models.GetLinks()
	this.Data["hidejs"] = `<!--[if lt IE 9]>
  <script src="/views/double/js/modernizr.js"></script>
  <![endif]-->`

	var (
		pagesize int
		err      error
		page     int
	)

	if page, err = strconv.Atoi(this.Ctx.Input.Param(":page")); err != nil || page < 1 {
		page = 1
	}

	if pagesize, err = strconv.Atoi(this.getOption("pagesize")); err != nil || pagesize < 1 {
		pagesize = 10
	}
	this.page = page
	this.pagesize = pagesize
}
Exemple #2
0
func (this *baseController) getTime() time.Time {
	options := models.GetOptions()
	timezone := float64(0)
	if v, ok := options["timezone"]; ok {
		timezone, _ = strconv.ParseFloat(v, 64)
	}
	add := timezone * float64(time.Hour)
	return time.Now().UTC().Add(time.Duration(add))
}