Game Index
</%block>
-% if len(recent_games) > 0:
-
##### ROW OF GAME TYPE ICONS #####
<div class="row">
<div class="span12 tabbable">
<ul class="nav nav-tabs">
- % for gt in ('overall','duel','ctf','dm','tdm','ca','kh','ft','lms','as','dom','nb','cts','rc'):
- <li
- % if game_type_cd == gt or (game_type_cd is None and gt == 'overall'):
- class="active"
- % endif
+ % for gt, url in game_type_links:
+ <li
+ % if game_type_cd == gt or (game_type_cd is None and gt == 'overall'):
+ class="active"
+ % endif
>
-
- % if gt == 'overall':
- <a href="${request.route_url("game_index")}" alt="${gt}" title="" data-toggle="none">
- % else:
- <a href="${request.route_url("game_index", _query={'type':gt})}" alt="${gt}" title="" data-toggle="none">
- % endif
- <span class="sprite sprite-${gt}"> </span><br />
- ${gt} <br />
- </a>
+ <a href="${url}" alt="${gt}" title="Show only ${gt} games" data-toggle="none">
+ <span class="sprite sprite-${gt}"> </span><br />
+ ${gt} <br />
+ </a>
</li>
% endfor
</ul>
##### RECENT GAMES TABLE #####
<div class="row">
<div class="span12">
+ % if len(recent_games) > 0:
<table class="table table-hover table-condensed">
<thead>
<tr>
% endfor
</tbody>
</table>
+ % else:
+ <h2>No more games to show!</h2>
+ % endif
</div> <!-- /span12 -->
</div> <!-- /row -->
+% if len(recent_games) == 20:
<div class="row">
<div class="span12 text-center">
<ul class="pagination">
</ul>
</div>
</div>
-
% endif
recent_games = [RecentGame(row) for row in rgs_q.limit(20).all()]
- query['start_game_id'] = recent_games[-1].game_id + 1
+ if len(recent_games) > 0:
+ query['start_game_id'] = recent_games[-1].game_id + 1
+
+ # build the list of links for the stripe across the top
+ game_type_links = []
+
+ # clear out the game_id window
+ gt_query = query.copy()
+ if 'start_game_id' in gt_query:
+ del gt_query['start_game_id']
+ if 'end_game_id' in gt_query:
+ del gt_query['end_game_id']
+
+ for gt in ('overall','duel','ctf','dm','tdm','ca','kh','ft',
+ 'lms','as','dom','nb','cts','rc'):
+ gt_query['type'] = gt
+ url = request.route_url("game_index", _query=gt_query)
+ game_type_links.append((gt, url))
return {
'recent_games':recent_games,
'query':query,
'game_type_cd':game_type_cd,
+ 'game_type_links':game_type_links,
}
def game_finder(request):