コード例 #1
0
/////////////////////////////////////////////////////////////////////////////////////////////
// Controller Actions
/////////////////////////////////////////////////////////////////////////////////////////////
func BattleAnswersIndex(r render.Render, db *mgo.Database, req *http.Request) {
	var recs []models.BattleAnswerRec

	recs = models.GetBattleAnswerRecs(db, nil)

	templateData := map[string]interface{}{"metatitle": "Battle Answers", "currentPath": req.URL.Path,
		"recs": helpers.GetBattleAnswerDisplays(db, recs)}
	r.HTML(200, "battle_answers/index", templateData)
}
コード例 #2
0
/////////////////////////////////////////////////////////////////////////////////////////////
// Controller Actions
/////////////////////////////////////////////////////////////////////////////////////////////
func SearchAnswersIndex(r render.Render, db *mgo.Database, gameId string, keywords string, req *http.Request) {
	var game models.GameRec
	var recs []models.BattleAnswerRec
	var tags []string

	models.FindGameById(db, gameId, &game)

	tags = strings.Split(keywords, " ")

	recs = models.GetBattleAnswerRecs(db, bson.M{"gameid": gameId, "tags": bson.M{"$all": tags}})

	templateData := map[string]interface{}{"metatitle": "Battle Answers", "currentPath": req.URL.Path, "game": game,
		"keywords": keywords,
		"recs":     helpers.GetBattleAnswerDisplays(db, recs)}
	r.HTML(200, "search_answers/index", templateData)
}