Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Armory Dashboard
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton Sarukhanov
Armory Dashboard
Commits
ae2a0f05
Commit
ae2a0f05
authored
7 years ago
by
Anton Sarukhanov
Browse files
Options
Downloads
Patches
Plain Diff
Make the Live Results URL user-configurable.
parent
60151f54
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
app.py
+16
-4
16 additions, 4 deletions
app.py
scrape.py
+1
-2
1 addition, 2 deletions
scrape.py
static/css/style.css
+27
-4
27 additions, 4 deletions
static/css/style.css
templates/index.html
+26
-27
26 additions, 27 deletions
templates/index.html
templates/live.html
+42
-0
42 additions, 0 deletions
templates/live.html
with
112 additions
and
37 deletions
app.py
+
16
−
4
View file @
ae2a0f05
from
urllib.parse
import
urlparse
,
urljoin
from
urllib.parse
import
urlparse
,
urljoin
import
re
import
re
from
flask
import
Flask
,
render_template
from
flask
import
Flask
,
render_template
,
redirect
,
request
,
url_for
from
flask_caching
import
Cache
from
flask_caching
import
Cache
from
lxml
import
html
from
lxml
import
html
import
requests
import
requests
...
@@ -9,16 +9,28 @@ from scrape import scrape
...
@@ -9,16 +9,28 @@ from scrape import scrape
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
cache
=
Cache
(
app
,
config
=
{
'
CACHE_TYPE
'
:
'
simple
'
})
cache
=
Cache
(
app
,
config
=
{
'
CACHE_TYPE
'
:
'
simple
'
})
def
make_cache_key
(
*
args
,
**
kwargs
):
path
=
request
.
path
args
=
str
(
hash
(
frozenset
(
request
.
args
.
items
())))
return
(
path
+
args
).
encode
(
'
utf-8
'
)
@app.after_request
@app.after_request
def
add_header
(
response
):
def
add_header
(
response
):
response
.
cache_control
.
max_age
=
300
response
.
cache_control
.
max_age
=
300
return
response
return
response
@app.route
(
"
/
"
)
@app.route
(
"
/
"
)
@cache.cached
(
timeout
=
300
)
def
index
():
def
index
():
tournament_name
,
tournament_details
,
events
=
scrape
()
return
render_template
(
'
index.html
'
)
return
render_template
(
'
index.html
'
,
@app.route
(
"
/live
"
)
@cache.cached
(
timeout
=
300
,
key_prefix
=
make_cache_key
)
def
live
(
results_url
=
None
):
results_url
=
request
.
args
.
get
(
'
results_url
'
)
if
not
results_url
:
return
redirect
(
url_for
(
'
index
'
))
tournament_name
,
tournament_details
,
events
=
scrape
(
results_url
)
return
render_template
(
'
live.html
'
,
tournament_name
=
tournament_name
,
tournament_name
=
tournament_name
,
tournament_details
=
tournament_details
,
tournament_details
=
tournament_details
,
events
=
events
)
events
=
events
)
...
...
This diff is collapsed.
Click to expand it.
scrape.py
+
1
−
2
View file @
ae2a0f05
...
@@ -5,8 +5,7 @@ from urllib.parse import urlparse, urljoin
...
@@ -5,8 +5,7 @@ from urllib.parse import urlparse, urljoin
from
itertools
import
repeat
from
itertools
import
repeat
def
scrape
():
def
scrape
(
results_url
):
results_url
=
"
https://fencingresults.ant.sr/cobra/
"
results
=
requests
.
get
(
results_url
)
results
=
requests
.
get
(
results_url
)
results_tree
=
html
.
fromstring
(
results
.
content
)
results_tree
=
html
.
fromstring
(
results
.
content
)
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
static/css/style.css
+
27
−
4
View file @
ae2a0f05
...
@@ -4,7 +4,12 @@ body {
...
@@ -4,7 +4,12 @@ body {
background-color
:
#000
;
background-color
:
#000
;
max-width
:
100%
;
max-width
:
100%
;
}
}
main
{
body
.page-live
header
span
.back-to-home
{
float
:
right
;
font-size
:
.8em
;
opacity
:
.6
;
}
body
.page-live
main
{
display
:
flex
;
display
:
flex
;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
align-items
:
flex-start
;
align-items
:
flex-start
;
...
@@ -12,6 +17,27 @@ main {
...
@@ -12,6 +17,27 @@ main {
max-width
:
100%
;
max-width
:
100%
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
}
}
body
.page-live
p
,
ul
{
margin
:
.25em
0
;
}
body
.page-home
form
{
display
:
flex
;
flex-wrap
:
wrap
;
}
body
.page-home
form
>
*
{
flex
:
auto
1
0
;
}
body
.page-home
label
{
display
:
flex
;
flex-wrap
:
wrap
;
}
body
.page-home
input
,
body
.page-home
select
{
flex
:
15em
1
0
;
}
body
.page-home
input
[
type
=
submit
]
{
flex
:
6em
0
0
;
}
h1
{
h1
{
font-size
:
1.2em
;
font-size
:
1.2em
;
}
}
...
@@ -41,9 +67,6 @@ section > :last-child {
...
@@ -41,9 +67,6 @@ section > :last-child {
h1
,
h2
,
h3
,
h4
,
h5
,
h6
{
h1
,
h2
,
h3
,
h4
,
h5
,
h6
{
margin
:
.35em
0
;
margin
:
.35em
0
;
}
}
p
,
ul
{
margin
:
.25em
0
;
}
a
:link
,
a
:link
,
a
:active
,
a
:active
,
a
:visited
{
a
:visited
{
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
26
−
27
View file @
ae2a0f05
...
@@ -4,38 +4,37 @@
...
@@ -4,38 +4,37 @@
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<title>
Armory Dashboard
</title>
<title>
Armory Dashboard
</title>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
http-equiv=
"refresh"
content=
"60; URL={{ url_for('index') }}"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='css/style.css') }}"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='css/style.css') }}"
>
</head>
</head>
<body>
<body
class=
"page-home"
>
<header>
<header>
<h1>
{{ tournament_name }} - {{ events | length }} events
</h1>
<h1>
Armory Dashboard
</h1>
</header>
</header>
<main>
<main>
{% for e in events %}
<p>
<section
class=
"status-{{ e['status'] }}"
>
Welcome! Please select a Live Results URL, or enter your own.
<
header
>
<
/p
>
<
div
class=
"status"
>
{{ e['status'] }}
</div
>
<
p
>
<div
class=
"name
"
>
<form
action=
"{{ url_for('live') }}"
method=
"get
"
>
<a
name=
"{{ e['name'] }}"
href=
"#{{ e['name'] }}"
>
{{ e['name'] }}
</a>
<label>
Live Results URL:
</div
>
<select
name=
"results_url"
>
<div
class=
"time"
>
{{ e['time'] }}
</div
>
<option
value=
""
selected
disabled
>
-- Select One --
</option
>
</header
>
<option
value=
"http://escrimeresults.com/cobra/"
>
Cobra
</option
>
<h4></h4
>
<option
value=
"http://escrimeresults.com/thrust/"
>
Thrust
</option
>
<p><span
class=
"number"
>
{{ e['fencers_checked_in'] | length }}
</span>
of
<span
class=
"number"
>
{{ e['fencers'] | length }}
</span>
fencer(s) checked in.
</p
>
<option
value=
"http://njfencingresults.org/liveresults/"
>
NJFencingResults.org
</option
>
{% if e['previously_fenced'] %}
</select>
<p><span
class=
"number"
>
{{ e['previous_total'] }}
</span>
fenced in prior events:
</p
>
</label
>
<ul
>
<input
type=
"submit"
value=
"Go!"
>
{% for pe in e['previously_fenced'] %}
</form>
<
li>
{{ pe }} - {{ e['previously_fenced'][pe] }}
</li
>
<
/p
>
{% endfor %}
<p>
</ul
>
<form
action=
"{{ url_for('live') }}"
method=
"get"
>
{% endif %}
<label>
Other URL:
{% if e['new_fencers_not_checked_in'] %}
<input
name=
"results_url"
placeholder=
"http://example.com/liveresults"
>
<p
class=
"hl"
>
{{ e['new_fencers_not_checked_in'] | length }} new and not checked in
</p
>
</label
>
{% endif %}
<input
type=
"submit"
value=
"Go!"
>
</section
>
</form
>
{% endfor %}
</p>
</main>
</main>
</body>
</body>
</html>
</html>
This diff is collapsed.
Click to expand it.
templates/live.html
0 → 100644
+
42
−
0
View file @
ae2a0f05
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<title>
Armory Dashboard
</title>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
http-equiv=
"refresh"
content=
"60; URL={{ url_for('index') }}"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='css/style.css') }}"
>
</head>
<body
class=
"page-live"
>
<header>
<span
class=
"back-to-home"
><a
href=
"{{ url_for('index') }}"
>
Back to Home
</a></span>
<h1>
{{ tournament_name }} - {{ events | length }} events
</h1>
</header>
<main>
{% for e in events %}
<section
class=
"status-{{ e['status'] }}"
>
<header>
<div
class=
"status"
>
{{ e['status'] }}
</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>
<ul>
{% for pe in e['previously_fenced'] %}
<li>
{{ pe }} - {{ e['previously_fenced'][pe] }}
</li>
{% endfor %}
</ul>
{% endif %}
{% if e['new_fencers_not_checked_in'] %}
<p
class=
"hl"
>
{{ e['new_fencers_not_checked_in'] | length }} new and not checked in
</p>
{% endif %}
</section>
{% endfor %}
</main>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment