diff options
-rw-r--r-- | db/queries.py | 21 | ||||
-rw-r--r-- | web/api.py | 6 | ||||
-rw-r--r-- | web/static/css/base.ccss | 39 | ||||
-rw-r--r-- | web/static/css/home.ccss | 8 | ||||
-rw-r--r-- | web/static/js/home.js | 17 | ||||
-rw-r--r-- | web/templates/base.html | 15 | ||||
-rw-r--r-- | web/templates/home.html | 15 |
7 files changed, 104 insertions, 17 deletions
diff --git a/db/queries.py b/db/queries.py index 1e10629..a4605e8 100644 --- a/db/queries.py +++ b/db/queries.py @@ -23,7 +23,7 @@ def kill_list(entity_type, entity_id): with db.cursor() as c: kills = db.query(c, ''' SELECT DISTINCT(kills.kill_id), kill_time, cost, - solarSystemName as system_name, security, regionName as region + solarSystemName AS system_name, security, regionName AS region FROM kills JOIN characters ON characters.kill_id = kills.kill_id JOIN kill_costs ON kill_costs.kill_id = kills.kill_id @@ -154,5 +154,24 @@ def kill(kill_id): 'slots': slots, } +def top_cost(): + with db.cursor() as c: + kills = db.query(c, ''' + SELECT kills.kill_id, cost, + ship_type_id, typeName as ship_name, + solarSystemName AS system_name, security + FROM kills + JOIN kill_costs ON kill_costs.kill_id = kills.kill_id + JOIN characters ON characters.kill_id = kills.kill_id + JOIN eve.invTypes ON typeID = ship_type_id + JOIN eve.mapSolarSystems ON solar_system_id = solarSystemID + WHERE victim = 1 + ORDER BY cost DESC + LIMIT 25 + ''') + #for kill in kills: + # kill['kill_time'] = _format_kill_time(kill['kill_time']) + return kills + def _format_kill_time(kill_time): return kill_time.strftime('%Y-%m-%d %H:%m') @@ -39,12 +39,18 @@ class KillHandler(APIHandler): kill = db.queries.kill(kill_id) self.respond_json(kill) +class TopCostHandler(APIHandler): + def get(self): + kills = db.queries.top_cost() + self.respond_json(kills) + def start(): tornado.web.Application( handlers=[ (r'/search', SearchHandler), (r'/(alliance|corporation|character)/(.+)', KillListHandler), (r'/kill/(.+)', KillHandler), + (r'/top/cost', TopCostHandler), ], debug=config.debug, ).listen(config.api_port) diff --git a/web/static/css/base.ccss b/web/static/css/base.ccss index 1142021..a7e130b 100644 --- a/web/static/css/base.ccss +++ b/web/static/css/base.ccss @@ -16,11 +16,14 @@ a: text-decoration: none color: #38c -form: - input: - background: #fff - border: 1px solid #cdd - padding: 5px 10px +form input: + background: #111 + border: 1px solid #444 + padding: 3px 10px + color: #ccc + height: 2em + vertical-align: middle + margin: 0 table: border-collapse: collapse @@ -33,7 +36,31 @@ table: .clear: clear: both +#topbar: + width: 900px + margin: 50px auto 2px + + h1: + display: inline-block + margin: 0 40px 0 10px + + #nav: + display: inline-block + + a: + display: inline-block + background-color: #111 + margin: 0 2px + padding: 4px + + form: + display: inline-block + float: right + + input[type="search"]: + margin-right: 5px + #wrapper: width: 900px - margin: 50px auto + margin: 0 auto 50px background: #111 diff --git a/web/static/css/home.ccss b/web/static/css/home.ccss new file mode 100644 index 0000000..ecb8d24 --- /dev/null +++ b/web/static/css/home.ccss @@ -0,0 +1,8 @@ +#wrapper: + padding: 20px + +#expensive: + margin: 0 auto + + caption, tr:nth-child(odd): + background-color: #181818 diff --git a/web/static/js/home.js b/web/static/js/home.js new file mode 100644 index 0000000..8bbe943 --- /dev/null +++ b/web/static/js/home.js @@ -0,0 +1,17 @@ +window.addEvent('domready', function() { + var table = $('expensive'); + ykill.api('/top/cost', function(kills) { + kills.each(function(kill) { + table.grab(new Element('tr').adopt( + new Element('td').grab(ykill.portrait(kill['ship_type_id'], kill['ship_name'], 'type', '_32.png')), + new Element('td', {'html': kill['ship_name']}), + new Element('td').grab( + new Element('a', { + 'href': '/kill/' + kill['kill_id'], + 'html': ykill.format_isk(kill['cost'] / (100 * 1000 * 1000 * 1000)) + }) + ) + )); + }); + }); +}); diff --git a/web/templates/base.html b/web/templates/base.html index 5573839..9f3e0de 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -15,13 +15,16 @@ {% block js %}{% end %} </head> <body> - <div id="wrapper"> - <div id="topbar"> - <div id="title"></div> - <div id="nav"> - </div> + <div id="topbar"> + <h1><a href="/">u r ded</a></h1> + <div id="nav"> </div> - + <form method="get" action="/search"> + <input type="search" name="q"> + <input type="submit" value="search"> + </form> + </div> + <div id="wrapper"> {% block main %}{% end %} </div> </body> diff --git a/web/templates/home.html b/web/templates/home.html index 34fe371..07ec4f2 100644 --- a/web/templates/home.html +++ b/web/templates/home.html @@ -1,8 +1,15 @@ {% extends "base.html" %} +{% block js %} + <script src="/static/js/home.js"></script> +{% end %} + +{% block css %} + <link rel="stylesheet" type="text/css" href="/css/home.css" /> +{% end %} + {% block main %} -<form method="get" action="/search"> - <input type="text" name="q"> - <input type="submit"> -</form> +<table id="expensive"> + <caption>most expensive kills</caption> +</table> {% end %} |