Skip to content

Commit

Permalink
add ethical ads
Browse files Browse the repository at this point in the history
  • Loading branch information
drkane committed Jun 19, 2023
1 parent 5bfa4b2 commit 00e7c5d
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 141 deletions.
5 changes: 3 additions & 2 deletions findthatpostcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import re

from flask import Flask, make_response, render_template, render_template_string, request
from flask import Flask, make_response, render_template, request
from flask_cors import CORS
from ua_parser import user_agent_parser

Expand All @@ -12,7 +12,6 @@


def get_es_url(default):

potential_env_vars = ["ELASTICSEARCH_URL", "ES_URL", "BONSAI_URL"]
for e_v in potential_env_vars:
if os.environ.get(e_v):
Expand All @@ -34,6 +33,7 @@ def create_app(test_config=None):
S3_ACCESS_ID=os.environ.get("S3_ACCESS_ID"),
S3_SECRET_KEY=os.environ.get("S3_SECRET_KEY"),
S3_BUCKET=os.environ.get("S3_BUCKET", "geo-boundaries"),
ETHICAL_ADS_PUBLISHER=os.environ.get("ETHICAL_ADS_PUBLISHER"),
)

if test_config is None:
Expand Down Expand Up @@ -61,6 +61,7 @@ def inject_now():
key_area_types=KEY_AREA_TYPES,
other_codes=OTHER_CODES,
area_types=AREA_TYPES,
ethical_ads_publisher=app.config.get("ETHICAL_ADS_PUBLISHER"),
)

@app.template_filter()
Expand Down
193 changes: 108 additions & 85 deletions findthatpostcode/templates/base.html.j2
Original file line number Diff line number Diff line change
@@ -1,93 +1,116 @@
{% set default_title = 'Find that Postcode' %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/tachyons.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Archivo:400,700|Raleway:400,700">
<link rel="stylesheet" href="https://dkane.net/theme/css/style.css" />
<link rel="stylesheet" href="https://dkane.net/theme/css/pygment.css" />
{% block headscripts %}

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/tachyons.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Archivo:400,700|Raleway:400,700">
<link rel="stylesheet" href="https://dkane.net/theme/css/style.css" />
<link rel="stylesheet" href="https://dkane.net/theme/css/pygment.css" />
{% if ethical_ads_publisher %}
<script async src="https://media.ethicalads.io/media/client/ethicalads.min.js"></script>
{% endif %}
{% block headscripts %}
{% endblock %}
<title>{{ (title or default_title)|striptags }}</title>
<style>
body {
overflow-wrap: break-word;
}
</style>
</head>

<body class="home w-100 sans-serif near-black base-font bg-wavy">
<header class="body header-font normal ph3 ph5-ns pt3 {% if frontpage %}pt5-ns pb5{% else %}pb4{% endif %} moon-gray">
<div class="fr f3-ns mt1 mr2 w-100 w-auto-ns tr pb3">
<a href="{{ url_for('about') }}" class="white logo underline double underline-yellow">About</a>
| <a href="{{ url_for('about') }}#data-sources" class="white logo underline double underline-yellow">Data
sources</a>
| <a href="{{ url_for('search.search_index') }}" class="white logo underline double underline-yellow">Search</a>
| <a href="{{ url_for('index') }}#api" class="white logo underline double underline-yellow">API</a>
</div>
<h1 class="{% if frontpage %}f-subheadline-ns{% endif %} tracked-tight f1 lh-title mv0 logo normal">
<a href="{{ url_for('index') }}" class="link moon-gray underline-yellow underline">
{{ default_title }}
</a>
</h1>
</header>
<main class="ph0 bg-white cf">
{% block header %}
<header class="fl w-100 ph3 ph5-ns entry-content lh-copy f4">
{% if (heading or title) not in [None, default_title] and (heading or title) %}
<h2 class="f2-ns mt4 mb0 f3 lh-title normal">
{{ (heading or title)|safe }}
</h2>
{% if subtitle %}
<h3 class="f3-ns f4 lh-solid mv0 normal gray">
{{ subtitle|safe }}
</h3>
{% endif %}
{% endif %}
</header>
{% endblock %}
<title>{{ (title or default_title)|striptags }}</title>
<style>
body {
overflow-wrap: break-word;
}
</style>
</head>
<body class="home w-100 sans-serif near-black base-font bg-wavy">
<header class="body header-font normal ph3 ph5-ns pt3 {% if frontpage %}pt5-ns pb5{% else %}pb4{% endif %} moon-gray">
<div class="fr f3-ns mt1 mr2 w-100 w-auto-ns tr pb3">
<a href="{{ url_for('about') }}" class="white logo underline double underline-yellow">About</a>
| <a href="{{ url_for('about') }}#data-sources" class="white logo underline double underline-yellow">Data sources</a>
| <a href="{{ url_for('search.search_index') }}" class="white logo underline double underline-yellow">Search</a>
| <a href="{{ url_for('index') }}#api" class="white logo underline double underline-yellow">API</a>
<section id="content" class="{% block sectionstyles %}fl w-100 ph3 pv5 ph5-ns lh-copy f4{% endblock %}">
{% block content %}{% endblock %}
</section>
</main>

{% if ethical_ads_publisher %}
<aside class="bg-near-white w-100 ph3 ph5-ns db pv4 flex">
<div class="center">
<div class="horizontal" id="footer-ad-1" data-ea-publisher="{{ ethical_ads_publisher }}" data-ea-type="image">
</div>
<h1 class="{% if frontpage %}f-subheadline-ns{% endif %} tracked-tight f1 lh-title mv0 logo normal">
<a href="{{ url_for('index') }}" class="link moon-gray underline-yellow underline">
{{ default_title }}
</a>
</h1>
</header>
<main class="ph0 bg-white cf">
{% block header %}
<header class="fl w-100 ph3 ph5-ns entry-content lh-copy f4">
{% if (heading or title) not in [None, default_title] and (heading or title) %}
<h2 class="f2-ns mt4 mb0 f3 lh-title normal">
{{ (heading or title)|safe }}
</h2>
{% if subtitle %}
<h3 class="f3-ns f4 lh-solid mv0 normal gray">
{{ subtitle|safe }}
</h3>
{% endif %}
{% endif %}
</header>
{% endblock %}
<section id="content" class="{% block sectionstyles %}fl w-100 ph3 pv5 ph5-ns lh-copy f4{% endblock %}">
{% block content %}{% endblock %}
</section>
</main>
</div>
</aside>
{% endif %}


<footer id="contentinfo" class="body ph3 ph5-ns db pv5 moon-gray bg-near-black cf">
<div class="w-100 w-third-l fr-l">
<p class="f7">
<a href="https://www.ons.gov.uk/methodology/geography/licences" class="link yellow">Postcode data from ONS used under Open Government License</a><br>
Contains OS data © Crown copyright and database right {{now.year}} <br>
Contains Royal Mail data © Royal Mail copyright and database right {{now.year}} <br>
Contains National Statistics data © Crown copyright and database right {{now.year}}
</p>
<footer id="contentinfo" class="body ph3 ph5-ns db pv5 moon-gray bg-near-black cf">
<div class="w-100 w-third-l fr-l">
<p class="f7 lh-headline">
<a href="https://www.ons.gov.uk/methodology/geography/licences" class="link yellow">Postcode data from ONS used
under Open Government License</a><br>
Contains OS data © Crown copyright and database right {{now.year}} <br>
Contains Royal Mail data © Royal Mail copyright and database right {{now.year}} <br>
Contains National Statistics data © Crown copyright and database right {{now.year}}
</p>
<p class="f7 lh-headline">
Locations are approximate and intended for statistical analysis, not navigation.
</p>
</div>
<div class="w-100 w-two-thirds-l">
<p class="mv2 pa0">
<strong>Find that Postcode</strong>
| <a href="/about" class="link yellow underline-hover">About</a>
| <a href="/about#data-sources" class="link yellow underline-hover">Data sources</a>
| <a href="/about#privacy" class="link yellow underline-hover">Privacy</a>
| <a href="mailto:[email protected]" class="link yellow underline-hover">Contact</a>
| <a href="https://findthatcharity.uk/" target="_blank" class="link yellow underline-hover">Find that
Charity</a>
</p>
<div class="mv2 pa0">
<a href="https://github.com/kanedata/find-that-postcode" target="_blank" class="link yellow underline-hover"
title="View code on Github">Code</a> [<a
href="https://github.com/kanedata/find-that-postcode/blob/main/LICENSE" target="_blank"
class="link yellow underline-hover">MIT License</a>] |
<a href="https://m.do.co/c/395b3c814647" target="_blank" class="link yellow underline-hover"
title="DigitalOcean referral link">Powered by DigitalOcean</a>
</div>
<div class="w-100 w-two-thirds-l">
<p class="mv2 pa0">
<strong>Find that Postcode</strong>
| <a href="/about" class="link yellow underline-hover">About</a>
| <a href="/about#data-sources" class="link yellow underline-hover">Data sources</a>
| <a href="/about#privacy" class="link yellow underline-hover">Privacy</a>
| <a href="mailto:[email protected]" class="link yellow underline-hover">Contact</a>
| <a href="https://findthatcharity.uk/" target="_blank" class="link yellow underline-hover">Find that Charity</a>
</p>
<div class="mv2 pa0">
<a href="https://github.com/kanedata/find-that-postcode" target="_blank" class="link yellow underline-hover"
title="View code on Github">Code</a> [<a href="https://github.com/kanedata/find-that-postcode/blob/main/LICENSE"
target="_blank" class="link yellow underline-hover">MIT License</a>] |
<a href="https://m.do.co/c/395b3c814647" target="_blank" class="link yellow underline-hover"
title="DigitalOcean referral link">Powered by DigitalOcean</a>
</div>
<p class="ma0 pa0">© 2017 - {{now.year}} <a href="https://dkane.net/" class="link yellow underline-hover">Kane Data
<p class="ma0 pa0">© 2017 - {{now.year}} <a href="https://dkane.net/" class="link yellow underline-hover">Kane
Data
Limited</a></p>
<p class="mv2 pa0 f7">
Kane Data Limited is registered as a company in England (company number <a
href="https://find-and-update.company-information.service.gov.uk/company/14015213" target="_blank"
class="link yellow">14015213</a>)
</p>
</div>
</footer>
{% block bodyscripts %}
{% endblock %}
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
</body>
</html>
<p class="mv2 pa0 f7">
Kane Data Limited is registered as a company in England (company number <a
href="https://find-and-update.company-information.service.gov.uk/company/14015213" target="_blank"
class="link yellow">14015213</a>)
</p>
</div>
</footer>
{% block bodyscripts %}
{% endblock %}
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt=""
referrerpolicy="no-referrer-when-downgrade" /></noscript>
</body>

</html>
Loading

0 comments on commit 00e7c5d

Please sign in to comment.