aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2023-05-18 16:11:27 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2023-05-18 16:11:27 +0100
commit669ab74f61e19b4a7f72dba303ffb2e09aa376f4 (patch)
treef724751ed3a71142dd9232ab96070cefd0876c9d /src
parent4513fe78fad87558bb3d660ec5f0163ccb892075 (diff)
downloadUKGenderPayGap-669ab74f61e19b4a7f72dba303ffb2e09aa376f4.tar.gz
UKGenderPayGap-669ab74f61e19b4a7f72dba303ffb2e09aa376f4.zip
Added page about datasets
Diffstat (limited to 'src')
-rw-r--r--src/app.py29
-rw-r--r--src/static/style.css4
-rw-r--r--src/templates/datasets.html.j24
-rw-r--r--src/templates/template.html.j21
4 files changed, 38 insertions, 0 deletions
diff --git a/src/app.py b/src/app.py
index bd58cfc..25ea52f 100644
--- a/src/app.py
+++ b/src/app.py
@@ -2,6 +2,8 @@ from paste.translogger import TransLogger
from waitress import serve
import database
import urllib.parse
+import mistune
+import houdini
import flask
import sys
import json
@@ -27,6 +29,33 @@ def serve_index():
charts = get_charts()["index"]
)
+class MDRenderer(mistune.HTMLRenderer):
+ def blockcode(self, text, lang):
+ return '\n<pre><code>{}</code></pre>\n'.format(houdini.escape_html(text.strip()))
+
+ def heading(self, text, level):
+ if level == 1:
+ return ""
+ else:
+ return "<h%d>%s</h%d>" % (level + 1, text, level + 1)
+
+@app.route("/datasets")
+def serve_datasets():
+ md = mistune.create_markdown(
+ renderer = MDRenderer(),
+ plugins = ["url"]
+ )
+
+ with open(os.path.join(os.path.dirname(__file__), "..", "README.md"), "r") as f:
+ markdown_txt = f.read()
+ md_html = md(markdown_txt)
+
+ return flask.render_template(
+ "datasets.html.j2",
+ title = "Notes on Datasets",
+ md_html = md_html
+ )
+
def get_charts():
with open(os.path.join(os.path.dirname(__file__), "charts.json"), "r") as f:
return json.load(f)
diff --git a/src/static/style.css b/src/static/style.css
index d3235c7..3c2b4f3 100644
--- a/src/static/style.css
+++ b/src/static/style.css
@@ -183,6 +183,10 @@ aside dl dt {
overflow: auto;
}
+#datasetnotes {
+ font-size: x-small;
+}
+
footer {
padding-left: 10%;
padding-right: 10%;
diff --git a/src/templates/datasets.html.j2 b/src/templates/datasets.html.j2
new file mode 100644
index 0000000..4cf2e30
--- /dev/null
+++ b/src/templates/datasets.html.j2
@@ -0,0 +1,4 @@
+{% extends "template.html.j2" %}
+{% block content %}
+ <p id="datasetnotes">{{ md_html|safe }}</p>
+{% endblock %} \ No newline at end of file
diff --git a/src/templates/template.html.j2 b/src/templates/template.html.j2
index be51c12..48c5da9 100644
--- a/src/templates/template.html.j2
+++ b/src/templates/template.html.j2
@@ -91,6 +91,7 @@
</div>
<footer>
+ <p><a href="/datasets">Notes on datasets used</a></p>
<p><a href="https://github.com/jwansek/UKGenderPayGap">Source code</a> released under GPLv3 - <a href="https://git.eda.gay/UKGenderPayGap">Non-Github mirror</a></p>
</footer>
</body> \ No newline at end of file