diff --git a/openaddr/ci/templates/base.html b/openaddr/ci/templates/base.html index 7d274749..3fd9bdd7 100644 --- a/openaddr/ci/templates/base.html +++ b/openaddr/ci/templates/base.html @@ -102,11 +102,11 @@ {% endif %} {% endif %} - Home - Download Data - All Batch Sets - All CI Jobs - Dashboard + Home + Download Data + All Batch Sets + All CI Jobs + Dashboard
{% if error_org_membership %} @@ -126,8 +126,8 @@ {% block info %}

I am the OpenAddresses data service. - Find me on Github or - read this blog post + Find me on Github or + read this blog post to learn more.

{% endblock %} diff --git a/openaddr/ci/templates/job-slippymap-frameset.html b/openaddr/ci/templates/job-slippymap-frameset.html new file mode 100644 index 00000000..8673fe63 --- /dev/null +++ b/openaddr/ci/templates/job-slippymap-frameset.html @@ -0,0 +1,19 @@ + + + + + OpenAddresses — Run {{ run.id }} Map Preview + +{% if job %} + + + + +{% else %} + + + + +{% endif %} + diff --git a/openaddr/ci/templates/job-slippymap-header.html b/openaddr/ci/templates/job-slippymap-header.html new file mode 100644 index 00000000..3ce2d836 --- /dev/null +++ b/openaddr/ci/templates/job-slippymap-header.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} +{% block title %}Job {{ job.id }}{% endblock %} +{% block main %} + {% if job %} + ← Return to CI job page + {% endif %} +{% endblock main %} +{% block info %}{% endblock %} diff --git a/openaddr/ci/templates/job.html b/openaddr/ci/templates/job.html index c8f9306e..276a8d6d 100644 --- a/openaddr/ci/templates/job.html +++ b/openaddr/ci/templates/job.html @@ -57,7 +57,11 @@ {% if dotmaps_base_url %} {% if file_runstate and file_runstate.slippymap %} - slippy map preview + {% if file_runstate.run_id %} + slippy map preview + {% else %} + slippy map preview + {% endif %} {% endif %} {% endif %} diff --git a/openaddr/ci/webhooks.py b/openaddr/ci/webhooks.py index 147c4dad..17c7a052 100644 --- a/openaddr/ci/webhooks.py +++ b/openaddr/ci/webhooks.py @@ -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//', methods=['GET']) +@webhooks.route('/slippymaps///', methods=['GET']) +@webhooks.route('/slippymaps////', 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(): diff --git a/openaddr/tests/ci.py b/openaddr/tests/ci.py index 11abde19..64d3cc9f 100644 --- a/openaddr/tests/ci.py +++ b/openaddr/tests/ci.py @@ -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):