Skip to content
Snippets Groups Projects
Commit cfdc8867 authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

Add tournament & event links and "Last Updated" indicator.

parent 310f4eeb
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,7 @@ def live(results_url=None): ...@@ -33,7 +33,7 @@ def live(results_url=None):
scraper = Scraper(results_url) scraper = Scraper(results_url)
tournament = scraper.scrape() tournament = scraper.scrape()
return render_template('live.html', return render_template('live.html',
tournament_name=tournament.name, tournament=tournament,
events=tournament.events) events=tournament.events)
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
class Tournament: class Tournament:
def __init__(self, name, url, events=None): def __init__(self, name, url, updated='', events=None):
self.name = name self.name = name
self.url = url self.url = url
self.updated = updated
self.events = events or [] self.events = events or []
def add_event(self, event): def add_event(self, event):
...@@ -29,10 +30,11 @@ class Event: ...@@ -29,10 +30,11 @@ class Event:
STATUS_STARTED = EventStatus("Started") STATUS_STARTED = EventStatus("Started")
STATUS_FINISHED = EventStatus("Finished") STATUS_FINISHED = EventStatus("Finished")
def __init__(self, name, time, status, fencers, tournament=None): def __init__(self, name, time, status, url, fencers, tournament=None):
self.name = name self.name = name
self.time = time self.time = time
self.status = status self.status = status
self.url = url
self.fencers = fencers self.fencers = fencers
self.tournament = tournament self.tournament = tournament
......
...@@ -22,10 +22,13 @@ class Scraper: ...@@ -22,10 +22,13 @@ class Scraper:
try: try:
tournament_name = results_tree.xpath( tournament_name = results_tree.xpath(
'//span[@class="tournName"]/text()')[0] '//span[@class="tournName"]/text()')[0]
updated = (results_tree.xpath(
'//span[@class="lastUpdate"]/text()')[0]
.replace('Last Updated:', '').strip())
except IndexError: except IndexError:
raise ScrapeError("Tournament info not found.") raise ScrapeError("Tournament info not found.")
self.tournament = Tournament(tournament_name, results.url) self.tournament = Tournament(tournament_name, results.url, updated)
# Get tournament events # Get tournament events
try: try:
...@@ -94,7 +97,7 @@ class Scraper: ...@@ -94,7 +97,7 @@ class Scraper:
fencers = [Fencer(f, ci) fencers = [Fencer(f, ci)
for (f, ci) in zip(fencers, fencers_checked_in)] for (f, ci) in zip(fencers, fencers_checked_in)]
return Event(event_name, event_time, event_status, fencers) return Event(event_name, event_time, event_status, event.url, fencers)
class ScrapeError(Exception): class ScrapeError(Exception):
......
...@@ -73,6 +73,19 @@ a:hover { ...@@ -73,6 +73,19 @@ a:hover {
background-color: #f22; background-color: #f22;
} }
/* Event link */
.event-actions {
float: right;
clear: both;
}
.event-actions img.ext-link {
margin: .2em 0 .2em .2em;
}
img.ext-link {
width: 1em;
vertical-align: baseline;
}
/* Numbers */ /* Numbers */
span.number { span.number {
font-weight: bold; font-weight: bold;
...@@ -115,3 +128,16 @@ body.page-index select { ...@@ -115,3 +128,16 @@ body.page-index select {
body.page-index input[type=submit] { body.page-index input[type=submit] {
flex: 6em 0 0; flex: 6em 0 0;
} }
/* Footer */
div.updated {
text-align: center;
margin: .5em 0;
font-size: .9em;
color: #999;
}
div.updated span.date {
color: #aaa;
font-weight: bold;
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
viewBox="0 0 576 512"
version="1.1"
id="svg4"
sodipodi:docname="external-link-alt.svg"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1760"
inkscape:window-height="1145"
id="namedview6"
showgrid="false"
inkscape:zoom="0.921875"
inkscape:cx="328.33008"
inkscape:cy="338.18949"
inkscape:window-x="757"
inkscape:window-y="202"
inkscape:window-maximized="0"
inkscape:current-layer="svg4" />
<path
d="M448 241.823V464c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h339.976c10.691 0 16.045 12.926 8.485 20.485l-24 24a12.002 12.002 0 0 1-8.485 3.515H54a6 6 0 0 0-6 6v340a6 6 0 0 0 6 6h340a6 6 0 0 0 6-6V265.823c0-3.183 1.264-6.235 3.515-8.485l24-24c7.559-7.56 20.485-2.206 20.485 8.485zM564 0H428.015c-10.658 0-16.039 12.93-8.485 20.485l48.187 48.201-272.202 272.202c-4.686 4.686-4.686 12.284 0 16.971l22.627 22.627c4.687 4.686 12.285 4.686 16.971 0l272.201-272.201 48.201 48.192c7.513 7.513 20.485 2.235 20.485-8.485V12c0-6.627-5.373-12-12-12z"
id="path2"
style="opacity:1;fill:#ffffff;fill-opacity:1" />
</svg>
<link rel="apple-touch-icon" sizes="180x180" href="/static/images/icons/apple-touch-icon.png?v=20180325">
<link rel="icon" type="image/png" sizes="32x32" href="/static/images/icons/favicon-32x32.png?v=20180325">
<link rel="icon" type="image/png" sizes="16x16" href="/static/images/icons/favicon-16x16.png?v=20180325">
<link rel="manifest" href="/static/images/icons/site.webmanifest?v=20180325">
<link rel="mask-icon" href="/static/images/icons/safari-pinned-tab.svg?v=20180325" color="#5bbad5">
<link rel="shortcut icon" href="/static/images/icons/favicon.ico?v=20180325">
<meta name="apple-mobile-web-app-title" content="Armory">
<meta name="application-name" content="Armory">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/static/images/icons/browserconfig.xml?v=20180325">
<meta name="theme-color" content="#ffffff">
\ No newline at end of file
...@@ -5,19 +5,24 @@ ...@@ -5,19 +5,24 @@
{% block content %} {% block content %}
<header> <header>
<span class="back-to-home"><a href="{{ url_for('index') }}">Back to Home</a></span> <span class="back-to-home"><a href="{{ url_for('index') }}">Back to Home</a></span>
<h1>{{ tournament_name }} - {{ events | length }} events</h1> <h1>{{ tournament.name }} - {{ events | length }} events
<a href="{{ tournament.url }}" target="_blank">
<img class="ext-link" src="{{ url_for('static', filename='images/font-awesome/external-link-alt.svg') }}?t=20180415"></a></h1>
</header> </header>
<main> <main>
{% for e in events %} {% for e in events %}
<section class="status-{{ e['status']|lower }}"> <section class="status-{{ e['status']|lower }}">
<header> <header>
<div class="status">{{ e['status']|lower }}</div> <div class="status">{{ e['status']|lower }}</div>
<div class="event-actions">
<a href="{{ e.url }}" target="_blank">
<img class="ext-link" src="{{ url_for('static', filename='images/font-awesome/external-link-alt.svg') }}?t=20180415"></a>
</div>
<div class="name"> <div class="name">
<a name="{{ e['name'] }}" href="#{{ e['name'] }}">{{ e['name'] }}</a> <a name="{{ e['name'] }}" href="#{{ e['name'] }}">{{ e['name'] }}</a>
</div> </div>
<div class="time">{{ e['time'] }}</div> <div class="time">{{ e['time'] }}</div>
</header> </header>
<h4></h4>
<p><span class="number">{{ e['fencers_checked_in'] | length }}</span> of <span class="number">{{ e['fencers'] | length }}</span> fencer(s) checked in.</p> <p><span class="number">{{ e['fencers_checked_in'] | length }}</span> of <span class="number">{{ e['fencers'] | length }}</span> fencer(s) checked in.</p>
{% if e['previously_fenced'] %} {% if e['previously_fenced'] %}
<p><span class="number">{{ e['previous_total'] }}</span> fenced in prior events:</p> <p><span class="number">{{ e['previous_total'] }}</span> fenced in prior events:</p>
...@@ -33,4 +38,9 @@ ...@@ -33,4 +38,9 @@
</section> </section>
{% endfor %} {% endfor %}
</main> </main>
<footer>
{% if tournament.updated %}
<div class="updated">Last updated: <span class="date">{{ tournament.updated }}</span></div>
{% endif %}
</footer>
{% endblock content %} {% endblock content %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment