diff --git a/app.py b/app.py index 4ec13b2e436f3af757189e567bce9eade6393820..8abfdc8a3ebcdb30b1ae36926268eacc457742f8 100644 --- a/app.py +++ b/app.py @@ -33,7 +33,7 @@ def live(results_url=None): scraper = Scraper(results_url) tournament = scraper.scrape() return render_template('live.html', - tournament_name=tournament.name, + tournament=tournament, events=tournament.events) diff --git a/models.py b/models.py index de9651e7401c9678515c5c6d08ad8cb1402279a3..9cd181c062d73d60add72c35454946a0da300d7f 100644 --- a/models.py +++ b/models.py @@ -2,9 +2,10 @@ class Tournament: - def __init__(self, name, url, events=None): + def __init__(self, name, url, updated='', events=None): self.name = name self.url = url + self.updated = updated self.events = events or [] def add_event(self, event): @@ -29,10 +30,11 @@ class Event: STATUS_STARTED = EventStatus("Started") 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.time = time self.status = status + self.url = url self.fencers = fencers self.tournament = tournament diff --git a/scraper.py b/scraper.py index 025064eeef26fd309c6f0b82dc767b79ea619ebe..653d982ba4fa86f3e08fef1978093777441e0d4d 100644 --- a/scraper.py +++ b/scraper.py @@ -22,10 +22,13 @@ class Scraper: try: tournament_name = results_tree.xpath( '//span[@class="tournName"]/text()')[0] + updated = (results_tree.xpath( + '//span[@class="lastUpdate"]/text()')[0] + .replace('Last Updated:', '').strip()) except IndexError: raise ScrapeError("Tournament info not found.") - self.tournament = Tournament(tournament_name, results.url) + self.tournament = Tournament(tournament_name, results.url, updated) # Get tournament events try: @@ -94,7 +97,7 @@ class Scraper: fencers = [Fencer(f, ci) 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): diff --git a/static/css/style.css b/static/css/style.css index 0e3c75cec9b544b9f84593f4cf321c41e55f177a..06e52dbebfb6eb38f04dc0eb4eca6cbdd4c57d90 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -73,6 +73,19 @@ a:hover { 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 */ span.number { font-weight: bold; @@ -115,3 +128,16 @@ body.page-index select { body.page-index input[type=submit] { 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; +} diff --git a/static/images/font-awesome/external-link-alt.svg b/static/images/font-awesome/external-link-alt.svg new file mode 100644 index 0000000000000000000000000000000000000000..2e34043fc39c5e3d6b5d7c13ccfc4dc9796d4eae --- /dev/null +++ b/static/images/font-awesome/external-link-alt.svg @@ -0,0 +1,53 @@ +<?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> diff --git a/static/images/html_code.html b/static/images/html_code.html deleted file mode 100644 index f6e288883daa5405a025d55ae357e73d9306687e..0000000000000000000000000000000000000000 --- a/static/images/html_code.html +++ /dev/null @@ -1,11 +0,0 @@ -<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 diff --git a/templates/live.html b/templates/live.html index ae427f391590f3370b19960066cd258dcddc8748..dab56a5b50d7df7b0368379c85d20b20918cd2fc 100644 --- a/templates/live.html +++ b/templates/live.html @@ -5,19 +5,24 @@ {% block content %} <header> <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> <main> {% for e in events %} <section class="status-{{ e['status']|lower }}"> <header> <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"> <a name="{{ e['name'] }}" href="#{{ e['name'] }}">{{ e['name'] }}</a> </div> <div class="time">{{ e['time'] }}</div> </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> {% if e['previously_fenced'] %} <p><span class="number">{{ e['previous_total'] }}</span> fenced in prior events:</p> @@ -33,4 +38,9 @@ </section> {% endfor %} </main> + <footer> + {% if tournament.updated %} + <div class="updated">Last updated: <span class="date">{{ tournament.updated }}</span></div> + {% endif %} + </footer> {% endblock content %}