accept="text/json")
config.add_route("server_top_maps", "/server/{id:\d+}/topmaps")
+ config.add_view(view=ServerTopMaps, route_name="server_top_maps", attr="html",
+ renderer="server_top_maps.mako", accept="text/html")
config.add_view(view=ServerTopMaps, route_name="server_top_maps", attr="json", renderer="json",
accept="text/json")
- config.add_route("server_top_players", "/server/{id:\d+}/topplayers")
+ config.add_route("server_top_players", "/server/{id:\d+}/topactive")
+ config.add_view(view=ServerTopPlayers, route_name="server_top_players", attr="html",
+ renderer="server_top_players_index.mako", accept="text/html")
config.add_view(view=ServerTopPlayers, route_name="server_top_players", attr="json",
renderer="json", accept="text/json")
config.add_route("server_top_scorers", "/server/{id:\d+}/topscorers")
+ config.add_view(view=ServerTopScorers, route_name="server_top_scorers", attr="html",
+ renderer="server_top_scorers.mako", accept="text/html")
config.add_view(view=ServerTopScorers, route_name="server_top_scorers", attr="json",
renderer="json", accept="text/json")
--- /dev/null
+<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+
+<%block name="navigation">
+ ${nav.nav('servers')}
+</%block>
+
+<%block name="title">
+ Server Top Map Index
+</%block>
+
+% if not top_maps and last is not None:
+ <h2 class="text-center">Sorry, no more maps!</h2>
+
+% elif not top_maps and last is None:
+ <h2 class="text-center">No maps found. Yikes, get playing!</h2>
+
+% else:
+ <div class="row">
+ <div class="small-12 large-6 large-offset-3 columns">
+ <table class="table-hover table-condensed">
+ <thead>
+ <tr>
+ <th class="small-2">#</th>
+ <th class="small-7">Map</th>
+ <th class="small-3">Times Played</th>
+ </tr>
+ </thead>
+ <tbody>
+ % for tm in top_maps:
+ <tr>
+ <td>${tm.rank}</td>
+ <td class="no-stretch"><a href="${request.route_url('map_info', id=tm.map_id)}" title="Go to the map info page for this map">${tm.name|n}</a></td>
+ <td>${tm.times_played}</td>
+ </tr>
+ % endfor
+ </tbody>
+ </table>
+ <p class="text-center"><small>Note: these figures are from the past 7 days</small>
+ </div>
+ </div>
+
+ % if len(top_maps) == 20:
+ <div class="row">
+ <div class="small-12 large-6 large-offset-3 columns">
+ <ul class="pagination">
+ <li>
+ <a href="${request.route_url('server_top_maps', id=server_id, _query=query)}" name="Next Page">Next <i class="fa fa-arrow-right"></i></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ % endif
+
+% endif
--- /dev/null
+<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+
+<%block name="navigation">
+ ${nav.nav('servers')}
+</%block>
+
+<%block name="title">
+ Server Active Players Index
+</%block>
+
+% if not top_players and start is not None:
+ <h2 class="text-center">Sorry, no more active players!</h2>
+
+% elif not top_players and start is None:
+ <h2 class="text-center">No active players found. Yikes, get playing!</h2>
+
+% else:
+ ##### ACTIVE PLAYERS #####
+ <div class="row">
+ <div class="small-12 large-6 large-offset-3 columns">
+ <table class="table-hover table-condensed">
+ <thead>
+ <tr>
+ <th class="small-2">#</th>
+ <th class="small-7">Nick</th>
+ <th class="small-3">Play Time</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ % for tp in top_players:
+ <tr>
+ <td>${tp.rank}</td>
+ <td class="no-stretch"><a href="${request.route_url('player_info', id=tp.player_id)}" title="Go to the player info page for this player">${tp.nick|n}</a></td>
+ <td>${tp.alivetime}</td>
+ </tr>
+ % endfor
+ </tbody>
+ </table>
+ <p class="text-center"><small>Note: these figures are from the past 7 days</small>
+ </div>
+ </div>
+
+ % if len(top_players) == 20:
+ <div class="row">
+ <div class="small-12 large-6 large-offset-3 columns">
+ <ul class="pagination">
+ <li>
+ <a href="${request.route_url('server_top_players', id=server_id, _query=query)}" name="Next Page">Next <i class="fa fa-arrow-right"></i></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ % endif
+
+% endif
--- /dev/null
+<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+
+<%block name="navigation">
+ ${nav.nav('servers')}
+</%block>
+
+<%block name="title">
+ Server Top Scorer Index
+</%block>
+
+% if not top_scorers and last is not None:
+ <h2 class="text-center">Sorry, no more players!</h2>
+
+% elif not top_scorers and last is None:
+ <h2 class="text-center">No players found. Yikes, get playing!</h2>
+
+% else:
+ <div class="row">
+ <div class="small-12 large-6 large-offset-3 columns">
+ <table class="table-hover table-condensed">
+ <thead>
+ <tr>
+ <th class="small-2">#</th>
+ <th class="small-7">Nick</th>
+ <th class="small-3">Score</th>
+ </tr>
+ </thead>
+ <tbody>
+ % for ts in top_scorers:
+ <tr>
+ <td>${ts.rank}</td>
+ <td class="no-stretch"><a href="${request.route_url('player_info', id=ts.player_id)}" title="Go to the player info page for this player">${ts.nick|n}</a></td>
+ <td>${ts.total_score}</td>
+ </tr>
+ % endfor
+ </tbody>
+ </table>
+ <p class="text-center"><small>Note: these figures are from the past 7 days</small>
+ </div>
+ </div>
+
+ % if len(top_scorers) == 20:
+ <div class="row">
+ <div class="small-12 large-6 large-offset-3 columns">
+ <ul class="pagination">
+ <li>
+ <a href="${request.route_url('server_top_scorers', id=server_id, _query=query)}" name="Next Page">Next <i class="fa fa-arrow-right"></i></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ % endif
+
+% endif
# Defaults
LEADERBOARD_LIFETIME = 30
LEADERBOARD_COUNT = 10
+INDEX_COUNT = 20
RECENT_GAMES_COUNT = 20
class ServerTopMaps(ServerInfoBase):
"""Returns the top maps played on a given server."""
- def __init__(self, request, limit=LEADERBOARD_COUNT, last=None):
+ def __init__(self, request, limit=INDEX_COUNT, last=None):
"""Common parameter parsing."""
super(ServerTopMaps, self).__init__(request, limit, last)
def html(self):
"""Returns the HTML-ready representation."""
- return self.top_maps
+
+ # build the query string
+ query = {}
+ if len(self.top_maps) > 1:
+ query['last'] = self.top_maps[-1].rank
+
+ return {
+ "server_id": self.server_id,
+ "top_maps": self.top_maps,
+ "query": query,
+ }
def json(self):
"""For rendering this data using JSON."""
class ServerTopScorers(ServerInfoBase):
"""Returns the top scorers on a given server."""
- def __init__(self, request, limit=LEADERBOARD_COUNT, last=None):
+ def __init__(self, request, limit=INDEX_COUNT, last=None):
"""Common parameter parsing."""
super(ServerTopScorers, self).__init__(request, limit, last)
self.top_scorers = self.raw()
top_scorers = [TopScorer(ts.rank, ts.player_id, html_colors(ts.nick), ts.total_score)
for ts in self.top_scorers]
- return top_scorers
+
+ # build the query string
+ query = {}
+ if len(top_scorers) > 1:
+ query['last'] = top_scorers[-1].rank
+
+ return {
+ "server_id": self.server_id,
+ "top_scorers": top_scorers,
+ "query": query,
+ }
def json(self):
"""For rendering this data using JSON."""
class ServerTopPlayers(ServerInfoBase):
"""Returns the top players by playing time on a given server."""
- def __init__(self, request, limit=LEADERBOARD_COUNT, last=None):
+ def __init__(self, request, limit=INDEX_COUNT, last=None):
"""Common parameter parsing."""
super(ServerTopPlayers, self).__init__(request, limit, last)
self.top_players = self.raw()
top_players = [TopPlayer(tp.rank, tp.player_id, html_colors(tp.nick), tp.alivetime)
for tp in self.top_players]
- return top_players
+ # build the query string
+ query = {}
+ if len(top_players) > 1:
+ query['last'] = top_players[-1].rank
+
+ return {
+ "server_id": self.server_id,
+ "top_players": top_players,
+ "query": query,
+ }
def json(self):
"""For rendering this data using JSON."""
"""For rendering this data using something HTML-based."""
return {
'server': self.server,
- 'top_players': self.top_players_v.html(),
- 'top_scorers': self.top_scorers_v.html(),
- 'top_maps': self.top_maps_v.html(),
+ 'top_players': self.top_players_v.html()["top_players"],
+ 'top_scorers': self.top_scorers_v.html()["top_scorers"],
+ 'top_maps': self.top_maps_v.html()["top_maps"],
'recent_games': self.recent_games,
'lifetime': self.lifetime,
}