Exemple #1
0
func (this *TopicsController) Content() {
	this.Data["Categories"] = models.Blogger.GetValidCategory()
	this.Data["ClassOlder"] = "disabled"
	this.Data["UrlOlder"] = "#"
	this.Data["ClassNewer"] = "disabled"
	this.Data["UrlNewer"] = "#"
	cat := this.GetString("cat")
	this.Data["ChooseCat"] = cat
	page, err := this.GetInt("p")
	if err != nil {
		page = 1
	}
	var pageTopics []*models.Topic
	var remainpage int
	if cat == "" || cat == "all" {
		pageTopics, remainpage = models.TMgr.GetTopicsByPage(page)
	} else {
		pageTopics, remainpage = models.TMgr.GetTopicsByCatgory(cat, page)
	}
	log.Debug(remainpage, page)
	if page > 1 {
		this.Data["ClassNewer"] = ""
		this.Data["UrlNewer"] = fmt.Sprintf("/admin/topics?cat=%s&p=%d", cat, page-1)
	}
	if remainpage > 0 {
		this.Data["ClassOlder"] = ""
		this.Data["UrlOlder"] = fmt.Sprintf("/admin/topics?cat=%s&p=%d", cat, page+1)
	}
	this.Data["Topics"] = pageTopics
	var style string
	for _, t := range models.Blogger.Tags {
		style += t.TagStyle()
	}
	this.Data["TagStyle"] = style
}
Exemple #2
0
func init() {
	log.Debug("mongo Dial " + os.Getenv("MGO"))
	sess, err := mgo.Dial(os.Getenv("MGO"))
	if err != nil {
		panic(err)
	}
	sess.SetMode(mgo.Strong, true)
	sess.SetSocketTimeout(DEFAULY_MGO_TIMEOUT * time.Second)
	sess.SetCursorTimeout(0)
	globalMS = sess
}
Exemple #3
0
func (m *UserMgr) FoundPass(name, email string) int {
	if user, found := m.Users[name]; !found {
		return RS.RS_user_inexistence
	} else {
		log.Debug(user.UserName)
	}

	// 发送邮件
	// ....
	return RS.RS_success
}
Exemple #4
0
func (m *UserMgr) loadUsers() {
	var users []*User
	err := db.FindAll(DB, C_USER, nil, &users)
	if err != nil {
		panic(err)
	}
	log.Debug(len(users))
	for _, u := range users {
		m.Users[u.UserName] = u
	}
}