renderer='game_info.mako')
# SERVER ROUTES
+ config.add_route(name="server_index_paged",
+ pattern="/servers/page/{page:\d+}", view=server_index,
+ renderer='server_index.mako')
+
+ config.add_route(name="server_index", pattern="/servers", view=server_index,
+ renderer='server_index.mako')
+
config.add_route(name="server_game_index",
pattern="/server/{server_id:\d+}/games/page/{page:\d+}",
view=server_game_index, renderer='server_game_index.mako')
<h3>Player Statistics for Xonotic</h3>
</%block>
<ul id="nav">
+ <li><a href="/" title="Leaderboard">leaderboard</a></li>
<li><a href="/players" title="Player Index">players</a></li>
<li><a href="/games" title="Game Index">games</a></li>
<li><a href="/maps" title="Map Index">maps</a></li>
- <li><a href="" title="Server Index">servers</a></li>
+ <li><a href="/servers" title="Server Index">servers</a></li>
</ul>
</div> <!-- END HEADER -->
<div id="main">
% for player in players:\r
<tr>\r
<td>${player.player_id}</th>\r
- <td>${player.nick_html_colors()}</th>\r
+ <td><a href="${request.route_url("player_info", id=player.player_id)}" title="Go to this player's info page">${player.nick_html_colors()}</a></th>\r
<td>${player.create_dt.strftime('%m/%d/%Y at %H:%M')}</th>\r
</tr>\r
% endfor\r
--- /dev/null
+<%inherit file="base.mako"/>\r
+\r
+<%block name="title">\r
+Map Index - ${parent.title()}\r
+</%block>\r
+\r
+% if not servers:\r
+<h2>Sorry, no servers yet. Get playing!</h2>\r
+\r
+% else:\r
+<h2>Server Index</h2>\r
+<table border="1">\r
+ <tr>\r
+ <th>#</th>\r
+ <th>Name</th>\r
+ <th>IP Address</th>\r
+ </tr>\r
+% for server in servers:\r
+ <tr>\r
+ <td>${server.server_id}</th>\r
+ <td><a href="${request.route_url("server_info", id=server.server_id)}" title="Go to this server's info page">${server.name}</a></th>\r
+ </tr>\r
+% endfor\r
+</table>\r
+% endif\r
+\r
+% if servers.previous_page:\r
+<a href="${request.route_url("server_index_paged", page=servers.previous_page)}" name="Previous Page">Previous</a>\r
+% endif\r
+% if servers.next_page:\r
+<a href="${request.route_url("server_index_paged", page=servers.next_page)}" name="Next Page">Next</a>\r
+% endif\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, map_index\r
-from xonstat.views.server import server_info, server_game_index\r
+from xonstat.views.server import server_info, server_game_index, server_index\r
from xonstat.views.main import main_index\r
weapon_stats = None\r
game_stats = None\r
recent_games = None\r
- raise e\r
+\r
return {'player':player, \r
'recent_games':recent_games,\r
'weapon_stats':weapon_stats,\r
\r
log = logging.getLogger(__name__)\r
\r
+def server_index(request):\r
+ """\r
+ Provides a list of all the current servers. \r
+ """\r
+ if 'page' in request.matchdict:\r
+ current_page = request.matchdict['page']\r
+ else:\r
+ current_page = 1\r
+\r
+ try:\r
+ server_q = DBSession.query(Server).\\r
+ order_by(Server.name)\r
+\r
+ servers = Page(server_q, current_page, url=page_url)\r
+\r
+ \r
+ except Exception as e:\r
+ servers = None\r
+\r
+ return {'servers':servers, }\r
+\r
\r
def server_info(request):\r
"""\r