Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Added frameset with slippymap preview #579

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions openaddr/ci/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
</form>
{% endif %}
{% endif %}
<a href="http://openaddresses.io"> <img id="icon" src="{{ url_for('static', filename='17.png') }}">Home</a>
<a href="{{ url_for('webhooks.app_index') }}">Download Data</a>
<a href="{{ url_for('webhooks.app_get_sets') }}">All Batch Sets</a>
<a href="{{ url_for('webhooks.app_get_jobs') }}">All CI Jobs</a>
<a href="{{ url_for('webhooks.app_get_dashboard') }}">Dashboard</a>
<a target="_top" href="http://openaddresses.io"> <img id="icon" src="{{ url_for('static', filename='17.png') }}">Home</a>
<a target="_top" href="{{ url_for('webhooks.app_index') }}">Download Data</a>
<a target="_top" href="{{ url_for('webhooks.app_get_sets') }}">All Batch Sets</a>
<a target="_top" href="{{ url_for('webhooks.app_get_jobs') }}">All CI Jobs</a>
<a target="_top" href="{{ url_for('webhooks.app_get_dashboard') }}">Dashboard</a>
</nav>
<main>
{% if error_org_membership %}
Expand All @@ -126,8 +126,8 @@
{% block info %}
<p>
I am the OpenAddresses data service.
<a href="https://github.com/openaddresses/machine">Find me on Github</a> or
<a href="http://mike.teczno.com/notes/openaddresses-ci.html">read this blog post</a>
<a target="_top" href="https://github.com/openaddresses/machine">Find me on Github</a> or
<a target="_top" href="http://mike.teczno.com/notes/openaddresses-ci.html">read this blog post</a>
to learn more.
</p>
{% endblock %}
Expand Down
19 changes: 19 additions & 0 deletions openaddr/ci/templates/job-slippymap-frameset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>OpenAddresses — Run {{ run.id }} Map Preview</title>
</head>
{% if job %}
<frameset rows="100,*" border="0">
<frame src="{{ url_for('webhooks.app_get_run_slippymap', frame='header', job_id=job.id, run_id=run.id) }}" scrolling="no">
<frame scrolling="no" src="{{ run.state|slippymap_preview_url }}">
</frameset>
{% else %}
<frameset rows="60,*" border="0">
<frame src="{{ url_for('webhooks.app_get_run_slippymap', frame='header', run_id=run.id) }}" scrolling="no">
<frame scrolling="no" src="{{ run.state|slippymap_preview_url }}">
</frameset>
{% endif %}
</html>
8 changes: 8 additions & 0 deletions openaddr/ci/templates/job-slippymap-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block title %}Job {{ job.id }}{% endblock %}
{% block main %}
{% if job %}
<a href="{{ url_for('webhooks.app_get_job', job_id=job.id) }}" target="_top">← Return to CI job page</a>
{% endif %}
{% endblock main %}
{% block info %}{% endblock %}
6 changes: 5 additions & 1 deletion openaddr/ci/templates/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@
{% if dotmaps_base_url %}
<td>
{% if file_runstate and file_runstate.slippymap %}
<a href="{{ file_runstate|slippymap_preview_url }}">slippy map preview</a>
{% if file_runstate.run_id %}
<a href="{{ url_for('webhooks.app_get_run_slippymap', frame='top', job_id=job.id, run_id=file_runstate.run_id) }}">slippy map preview</a>
{% else %}
<a href="{{ file_runstate|slippymap_preview_url }}">slippy map preview</a>
{% endif %}
{% endif %}
</td>
{% endif %}
Expand Down
25 changes: 24 additions & 1 deletion openaddr/ci/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,35 @@ def app_get_job(job_id):

ordered_files = OrderedDict(sorted(file_tuples, key=key_func))

job = dict(status=job.status, task_files=ordered_files, file_states=job.states,
job = dict(id=job_id, status=job.status, task_files=ordered_files, file_states=job.states,
file_results=job.file_results, github_status_url=job.github_status_url)

return render_template('job.html', job=job,
dotmaps_base_url=current_app.config['DOTMAPS_BASE_URL'])

@webhooks.route('/slippymaps/<run_id>/', methods=['GET'])
@webhooks.route('/slippymaps/<run_id>/<frame>/', methods=['GET'])
@webhooks.route('/slippymaps/<run_id>/<frame>/<job_id>/', methods=['GET'])
@log_application_errors
def app_get_run_slippymap(run_id, frame='top', job_id=None):
'''
'''
if not current_app.config['DOTMAPS_BASE_URL']:
return Response('No slippy maps for you', 404)

with db_connect(current_app.config['DATABASE_URL']) as conn:
with db_cursor(conn) as db:
run = read_run(db, run_id)
try:
job = read_job(db, job_id)
except TypeError:
job = None

if frame == 'header':
return render_template('job-slippymap-header.html', job=job, run=run)

return render_template('job-slippymap-frameset.html', job=job, run=run)

@webhooks.route('/sets/', methods=['GET'])
@log_application_errors
def app_get_sets():
Expand Down
4 changes: 2 additions & 2 deletions openaddr/tests/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2298,13 +2298,13 @@ def test_get_job(self):
self.assertIn('http://example.com/998/sample.json', body2)
self.assertIn('http://example.com/998/stuff.zip', body2)
self.assertIn('http://example.com/998/preview.png', body2)
self.assertIn('https://dotmaps.example.com/yo/998', body2)
self.assertIn('https://dotmaps.example.com/yo/998', body2, 'Should see the external URL for slippy map')

self.assertIn('http://example.com/999/log.txt', body2)
self.assertIn('http://example.com/999/sample.json', body2)
self.assertIn('http://example.com/999/stuff.zip', body2)
self.assertIn('http://example.com/999/preview.png', body2)
self.assertIn('https://dotmaps.example.com/yo/999', body2)
self.assertIn('/slippymaps/999/top/abc', body2, 'Should see the internal frameset URL for slippy map')

class TestRuns (unittest.TestCase):

Expand Down