--- /dev/null
+body {
+ color: #ccc;
+ font-family: monospace;
+ font-size: 12px;
+}
+#badge {
+ background: url('../img/dark_wall.png');
+ height: 60px;
+ padding: 5px;
+ position: fixed;
+ width: 550px;
+}
+#nick {
+ font-size: 22px;
+ font-weight: bold;
+ height: 28px;
+ left: 10px;
+ overflow: hidden;
+ position: absolute;
+ width: 285px;
+}
+#games_played {
+ left: 10px;
+ position: absolute;
+ top: 45px;
+}
+#win_percentage, #kill_ratio, #elo {
+ left: 300px;
+ position: absolute;
+}
+#win_percentage {
+ top: 5px;
+}
+#kill_ratio {
+ top: 25px;
+}
+#elo {
+ top: 45px;
+}
--- /dev/null
+from mako.template import Template
+from os import system
+from pyramid.paster import bootstrap
+from xonstat.models import *
+from xonstat.views.player import player_info_data
+
+# converter params
+CONVERTER = "/home/ant/xonotic/xonstat/xonstat/batch/badges/wkhtmltoimage-amd64 --crop-x 10 --crop-y 10 --width 560 --height 70 -f png"
+
+# environment setup
+env = bootstrap('../../../development.ini.home')
+req = env['request']
+req.matchdict = {'id':3}
+
+# template setup
+t = Template(filename = 'templates/badge.mako')
+
+players = DBSession.query(Player).filter(Player.player_id < 50).\
+ filter(Player.player_id == PlayerElo.player_id).\
+ filter(Player.nick != None).\
+ filter(Player.player_id > 2).\
+ filter(Player.active_ind == True).all()
+
+for player in players:
+ req.matchdict['id'] = player.player_id
+ data = player_info_data(req)
+ rt = t.render(player=data['player'], elos_display=data['elos_display'],
+ total_stats=data['total_stats'], total_games=data['total_games'],
+ games_breakdown=data['games_breakdown'])
+ f = open("output/%s.html" % player.player_id, 'w')
+ f.write(rt)
+ f.close()
+
+ cmd = "%s %s %s" % (CONVERTER, "output/%s.html" % player.player_id,
+ "output/%s.png" % player.player_id)
+ system(cmd)
--- /dev/null
+<html>
+ <head>
+ <link href="../css/style.css" rel="stylesheet">
+ </head>
+ <body>
+ <div id="badge">
+ <div id="nick">
+ <b>
+ <span style="color:rgb(0,255,0)">print('<span style="color:rgb(255,0,0)">Anti<span style="color:rgb(127,127,127)">body<span style="color:rgb(0,255,0)">')<span style='color:rgb(255,255,255)'></span></span></span></span></span>
+ </b>
+ </div>
+
+ <div id="games_played">
+ 218 games (144 duel, 41 ctf, 31 dm, 2 tdm)
+ </div>
+
+ <div id="win_percentage">
+ 111 wins, 107 losses (50.92%)
+ </div>
+
+ <div id="kill_ratio">
+ 3084 kills, 2519 deaths (1.224)
+ </div>
+
+ <div id="elo">
+ Elo: 375.091 (ctf), 358.604 (dm)
+ </div>
+ </div>
+
+ </body>
+</html>
--- /dev/null
+<html>
+ <head>
+ <link href="../css/style.css" rel="stylesheet">
+ </head>
+ <body>
+ <div id="badge">
+ <div id="nick">
+ <b>
+ ${player.nick_html_colors()|n}
+ </b>
+ </div>
+
+ <div id="games_played">
+ <% games_breakdown_str = ', '.join(["{0} {1}".format(ng, gt) for (gt, ng) in games_breakdown]) %>
+ ${total_games} (${games_breakdown_str})
+ </div>
+
+ <div id="win_percentage">
+ % if total_games > 0 and total_stats['wins'] is not None:
+ ${total_stats['wins']} wins, ${total_games - total_stats['wins']} losses (${round(float(total_stats['wins'])/total_games * 100, 2)}%)
+ % endif
+ </div>
+
+ <div id="kill_ratio">
+ % if total_stats['kills'] > 0 and total_stats['deaths'] > 0:
+ ${total_stats['kills']} kills, ${total_stats['deaths']} deaths (${round(float(total_stats['kills'])/total_stats['deaths'], 3)})
+ % endif
+ </div>
+
+ <div id="elo">
+ % if elos_display is not None and len(elos_display) > 0:
+ Elo: ${', '.join(elos_display[0:2])}
+ % endif
+ </div>
+
+ </div>
+
+ </body>
+</html>