renderer='server_info.mako')
# MAP ROUTES
+ config.add_route(name="map_index_paged",
+ pattern="/maps/page/{page:\d+}", view=map_index,
+ renderer='map_index.mako')
+
+ config.add_route(name="map_index", pattern="/maps", view=map_index,
+ renderer='map_index.mako')
+
config.add_route(name="map_info", pattern="/map/{id:\d+}", view=map_info,
renderer='map_info.mako')
<ul id="nav">
<li><a href="/players" title="Player Index">players</a></li>
<li><a href="/games" title="Game Index">games</a></li>
- <li><a href="" title="Map Index">maps</a></li>
+ <li><a href="/maps" title="Map Index">maps</a></li>
<li><a href="" title="Server Index">servers</a></li>
</ul>
</div> <!-- END HEADER -->
--- /dev/null
+<%inherit file="base.mako"/>\r
+\r
+<%block name="title">\r
+Map Index - ${parent.title()}\r
+</%block>\r
+\r
+% if not maps:\r
+<h2>Sorry, no maps yet. Get playing!</h2>\r
+\r
+% else:\r
+<h2>Map Index</h2>\r
+<table border="1">\r
+ <tr>\r
+ <th>#</th>\r
+ <th>Name</th>\r
+ </tr>\r
+% for map in maps:\r
+ <tr>\r
+ <td>${map.map_id}</th>\r
+ <td><a href="${request.route_url("map_info", id=map.map_id)}" title="Go to this map's info page">${map.name}</a></th>\r
+ </tr>\r
+% endfor\r
+</table>\r
+% endif\r
+\r
+% if maps.previous_page:\r
+<a href="${request.route_url("map_index_paged", page=maps.previous_page)}" name="Previous Page">Previous</a>\r
+% endif\r
+% if maps.next_page:\r
+<a href="${request.route_url("map_index_paged", page=maps.next_page)}" name="Next Page">Next</a>\r
+% endif\r
from xonstat.views.submission import stats_submit\r
from xonstat.views.player import player_index, player_info, player_game_index\r
from xonstat.views.game import game_index, game_info\r
-from xonstat.views.map import map_info\r
+from xonstat.views.map import map_info, map_index\r
from xonstat.views.server import server_info, server_game_index\r
from xonstat.views.main import main_index\r
\r
log = logging.getLogger(__name__)\r
\r
+def map_index(request):\r
+ """\r
+ Provides a list of all the current maps. \r
+ """\r
+ if 'page' in request.matchdict:\r
+ current_page = request.matchdict['page']\r
+ else:\r
+ current_page = 1\r
+\r
+ try:\r
+ map_q = DBSession.query(Map).\\r
+ order_by(Map.name)\r
+\r
+ maps = Page(map_q, current_page, url=page_url)\r
+\r
+ \r
+ except Exception as e:\r
+ maps = None\r
+\r
+ return {'maps':maps, }\r
+\r
\r
def map_info(request):\r
"""\r