From: Ant Zucaro Date: Sun, 19 Jun 2011 18:20:03 +0000 (-0400) Subject: Remove styling for a lot of things. Add leaderboard and recent-games elements X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ab26088489d415518a1b3f46de65c706b2f42071;p=xonotic%2Fxonstat.git Remove styling for a lot of things. Add leaderboard and recent-games elements --- diff --git a/xonstat/static/css/normalize.css b/xonstat/static/css/normalize.css new file mode 100644 index 0000000..4b91b90 --- /dev/null +++ b/xonstat/static/css/normalize.css @@ -0,0 +1 @@ +article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}html{font-size:100%;overflow-y:scroll;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}body,button,input,select,textarea{font-family:sans-serif}img{border:0;-ms-interpolation-mode:bicubic}a{color:#00e}a:visited{color:#551a8b}a:focus{outline:thin dotted}a:hover,a:active{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}pre,code,kbd,samp{font-family:monospace,monospace;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:before,q:after{content:'';content:none}small{font-size:75%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}ul,ol{margin:1em 0;padding:0 0 0 40px}dd{margin:0 0 0 40px}nav ul,nav ol{list-style:none}figure{margin:0}form{margin:0}fieldset{margin:0 2px;padding:.35em .625em .75em}legend{*margin-left:-7px}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal;*overflow:visible}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="checkbox"],input[type="radio"]{box-sizing:border-box}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}th,td{padding:0;text-align:left;vertical-align:middle} \ No newline at end of file diff --git a/xonstat/static/css/style.css b/xonstat/static/css/style.css index bf7f555..c4052bc 100755 --- a/xonstat/static/css/style.css +++ b/xonstat/static/css/style.css @@ -1,37 +1,67 @@ -@font-face { - font-family: 'Xolonium'; - src: url('/static/css/xolonium-webfont.eot'); - src: url('/static/css/xolonium-webfont.eot?#iefix') format('embedded-opentype'), - url('/static/css/xolonium-webfont.woff') format('woff'), - url('/static/css/xolonium-webfont.ttf') format('truetype'), - url('/static/css/xolonium-webfont.svg#Xolonium') format('svg'); - font-weight: normal; - font-style: normal; -} - -body { - font-family: 'Xolonium', 'Arial', 'Helvetica'; - font-size: 12px; - text-align: center; -} - -.scoreboard{ - color: #FFFFFF; - text-align: center; -} - -.table-header, .header-cell{ - background-color: #E8E8E8; - font-size: 14px; - font-weight: bold; -} - - -.accuracy-table{ - text-align: center; -} - -.nick { - font-family: 'Xolonium', 'Arial', 'Helvetica'; - font-size: 14px; -} +body{ + margin-left: auto; + margin-right: auto; + padding: 10px 10px 10px 10px; + width: 960px; +} + +#header{ + height: 100px; + position: relative; +} + +#header h1{ + position: absolute; +} + +#header h3{ + position: absolute; + top: 45px; +} + +#nav{ + position: absolute; + right: 0; + top: 50px; +} + +#nav ul{ + list-style: none outside none; +} + +#nav li{ + background-color: #bbbbbb; + border-radius: 3px 3px 3px 3px; + display: inline; + padding: 3px 6px; +} + +#nav li:hover{ + background-color: #999999; +} + +#top-players, #top-servers, #top-maps{ + float: left; + margin-bottom: 10px; + width: 320px; +} + +#leaderboard{ + display: inline; + float: left; + width: 320px; +} + +#recent-games{ + float: right; + width: 610px; +} + +#recent-games-table{ + width: 610px; +} + +#footer{ + clear: both; + text-align: center; +} diff --git a/xonstat/templates/base.mako b/xonstat/templates/base.mako old mode 100755 new mode 100644 index ca01bef..5f96eb8 --- a/xonstat/templates/base.mako +++ b/xonstat/templates/base.mako @@ -1,25 +1,33 @@ - - <%block name="title">XonStat - The Xonotic Statistics Database</%block> - <%block name="css"> - - - <%block name="js"/> - - - - - ${self.body()} - - - + + <%block name="title">XonStat - Player Statistics for Xonotic</%block> + <%block name="css"> + + + + <%block name="js"> + + + + +
+ ${self.body()} +
+ + diff --git a/xonstat/templates/main_index.mako b/xonstat/templates/main_index.mako index 12d5323..bcd1aa9 100755 --- a/xonstat/templates/main_index.mako +++ b/xonstat/templates/main_index.mako @@ -4,62 +4,109 @@ Main Page - ${parent.title()} - - - - - -% for (player_id, nick, score) in top_players: - - - - -% endfor +
-% for i in range(10 - len(top_players)): -
- - - +##### TOP PLAYERS ##### +
NickScore
${nick}${score}
--
+ + + + + + + + +% for (player_id, nick, score) in top_players: + + % if player_id != '-': + + % else: + + % endif + + + % endfor
Top Players
#NickScore
${player_id}${player_id}${nick}${score}
- - - - - +##### TOP SERVERS ##### +
ServerGames
+ + + + + + + + % for (server_id, name, count) in top_servers: - - - - -% endfor - -% for i in range(10 - len(top_servers)): - - - - + + % if server_id != '-': + + % else: + + % endif + + + % endfor
Top Servers
#ServerGames
${name}${count}
--
${server_id}${server_id}${name}${count}
- - - - - +##### TOP MAPS ##### +
MapTimes Played
+ + + + + + + + % for (map_id, name, count) in top_maps: - - - - -% endfor - -% for i in range(10 - len(top_maps)): - - - - + + % if map_id != '-': + + % else: + + % endif + + + % endfor
Top Maps
#MapTimes Played
${name}${count}
--
${map_id}${map_id}${name}${count}
+ + +
+ +##### RECENT GAMES ##### + + + + + + + + + + + + % for (game, server, map) in recent_games: + % if game != '-': + + + + + + + + % else: + + + + + + + + % endif + % endfor + diff --git a/xonstat/views/main.py b/xonstat/views/main.py index 811a1a6..b3bb04a 100755 --- a/xonstat/views/main.py +++ b/xonstat/views/main.py @@ -1,37 +1,63 @@ import logging import sqlalchemy.sql.functions as func +import sqlalchemy.sql.expression as expr from pyramid.response import Response from xonstat.models import * +from xonstat.util import * log = logging.getLogger(__name__) def main_index(request): + leaderboard_count = 10 + recent_games_count = 30 + # top players by score top_players = DBSession.query(Player.player_id, Player.nick, func.sum(PlayerGameStat.score)).\ filter(Player.player_id == PlayerGameStat.player_id).\ filter(Player.player_id > 2).\ - order_by(func.sum(PlayerGameStat.score)).\ + order_by(expr.desc(func.sum(PlayerGameStat.score))).\ group_by(Player.nick).\ group_by(Player.player_id).all()[0:10] + top_players = [(player_id, html_colors(nick), score) \ + for (player_id, nick, score) in top_players] + + for i in range(leaderboard_count-len(top_players)): + top_players.append(('-', '-', '-')) + # top servers by number of total players played top_servers = DBSession.query(Server.server_id, Server.name, func.count()).\ filter(Game.server_id==Server.server_id).\ - order_by(func.count(Game.game_id)).\ + order_by(expr.desc(func.count(Game.game_id))).\ group_by(Server.server_id).\ group_by(Server.name).all()[0:10] + for i in range(leaderboard_count-len(top_servers)): + top_servers.append(('-', '-', '-')) + # top maps by total times played top_maps = DBSession.query(Map.map_id, Map.name, func.count(Game.game_id)).\ filter(Map.map_id==Game.game_id).\ - order_by(func.count(Game.game_id)).\ + order_by(expr.desc(func.count(Game.game_id))).\ group_by(Map.map_id).\ group_by(Map.name).all()[0:10] + for i in range(leaderboard_count-len(top_maps)): + top_maps.append(('-', '-', '-')) + + recent_games = DBSession.query(Game, Server, Map).\ + filter(Game.server_id==Server.server_id).\ + filter(Game.map_id==Map.map_id).\ + order_by(expr.desc(Game.start_dt)).all()[0:recent_games_count] + + for i in range(recent_games_count-len(recent_games)): + recent_games.append(('-', '-', '-')) + return {'top_players':top_players, 'top_servers':top_servers, 'top_maps':top_maps, + 'recent_games':recent_games, }
Recent Games
Game #ServerMapTimeWinner
${game.game_id}${server.name}${map.name}${game.start_dt}${game.winner}
-----