Skip to content

Commit

Permalink
Merge pull request #308 from beawitcht/development
Browse files Browse the repository at this point in the history
Trans informed redesign
  • Loading branch information
beawitcht authored Jun 25, 2024
2 parents 406f270 + 4aa24df commit 1313b0e
Show file tree
Hide file tree
Showing 71 changed files with 3,006 additions and 684 deletions.
9 changes: 6 additions & 3 deletions app/blueprints/blog_routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from flask import Blueprint, render_template, abort
from main import cache, entries
from main import cache
from utilities import prepare_blogs
import urllib.parse

# get blogs
entries = prepare_blogs("https://medium.com/feed/@transinformed")

blog_bp = Blueprint('blog', __name__)

Expand All @@ -17,11 +20,11 @@ def blog(title):
for rss_blog in entries:
if rss_blog.url_title == urllib.parse.quote_plus(title):
blog_number = entries.index(rss_blog)
# return 404 if failed to match blog
# return 404 if failed to match blog
try:
blog = entries[blog_number]
except NameError:
abort(404)

return render_template("blog.html", blog=blog)
return render_template(f"blogs/{blog.title}.html", blog=blog)

8 changes: 8 additions & 0 deletions app/compilescss.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
sass ./static/scss/base.scss:./static/css/base.css --style compressed
sass ./static/scss/blog.scss:./static/css/blog.css --style compressed
sass ./static/scss/blogs.scss:./static/css/blogs.css --style compressed
sass ./static/scss/sources.scss:./static/css/sources.css --style compressed
sass ./static/scss/resources.scss:./static/css/resources.css --style compressed
sass ./static/scss/about.scss:./static/css/about.css --style compressed
sass ./static/scss/index.scss:./static/css/index.css --style compressed
2 changes: 1 addition & 1 deletion app/forms/GICs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"GICs": [["Y-England", "National Referral Support Service - Wait time: 5 years"], ["Y-Wales", "National Referral Support Service - Wait time: 5 years"], ["Wales", "Welsh Gender Service - Cardiff - Wait time (months): 15"], ["Scotland", "Edinburgh Chalmers Centre - Wait time (months): 23"], ["England", "Nottingham Centre for Transgender Health - Wait time (months): 23"], ["Y-Northern Ireland", "Belfast KOI - Wait time (months): 24"], ["Scotland", "Grampian - Wait time (months): 24"], ["Scotland", "Inverness Highland Sexual Health - Wait time (months): 29"], ["Y-Scotland", "Glasgow Youth Sandyford - Wait time (months): 42"], ["England", "Northants Northamptonshire Healthcare Trust - Wait time (months): 53"], ["Scotland", "Glasgow Sandyford - Wait time (months): 55"], ["England", "Leeds and York Partnership Trust - Wait time (months): 57"], ["Northern Ireland", "Belfast Brackenburn Clinic - Wait time (months): 59"], ["England", "London Tavistock and Portman Trust - Wait time (months): 60"], ["England", "Sheffield Porterbrook Clinic - Wait time (months): 62"], ["England", "Exeter Devon Partnership Trust - Wait time (months): 87"]]}
{"GICs": [["Y-England", "National Referral Support Service - Wait time: 5 years"], ["Y-Wales", "National Referral Support Service - Wait time: 5 years"], ["Wales", "Welsh Gender Service - Cardiff - Wait time (months): 15"], ["Scotland", "Edinburgh Chalmers Centre - Wait time (months): 23"], ["Y-Northern Ireland", "Belfast KOI - Wait time (months): 24"], ["Scotland", "Grampian - Wait time (months): 24"], ["England", "Nottingham Centre for Transgender Health - Wait time (months): 27"], ["Scotland", "Inverness Highland Sexual Health - Wait time (months): 29"], ["England", "Northants Northamptonshire Healthcare Trust - Wait time (months): 53"], ["Y-Scotland", "Glasgow Youth Sandyford - Wait time (months): 58"], ["England", "Leeds and York Partnership Trust - Wait time (months): 58"], ["England", "London Tavistock and Portman Trust - Wait time (months): 61"], ["Scotland", "Glasgow Sandyford - Wait time (months): 65"], ["England", "Sheffield Porterbrook Clinic - Wait time (months): 65"], ["Northern Ireland", "Belfast Brackenburn Clinic - Wait time (months): 75"], ["England", "Exeter Devon Partnership Trust - Wait time (months): 88"]]}
5 changes: 0 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ def handle_error(error):
return make_response(render_template("error.html", name=error.name ,code=error.code, description=error.description), error.code)

# add header rows on blog posts before each heading and style images
@app.template_filter('stylish')
def stylish(text):
text = text.replace("<h3>", "\n<hr>\n<h3>")
text = text.replace("<img", "<img class=\"img-fluid rounded mx-auto d-block\"")
return text

if __name__ == '__main__':
app.run()
32 changes: 32 additions & 0 deletions app/scripts/generate_blogs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from pathlib import Path
from utilities import prepare_blogs

path = Path(__file__).parent.parent.resolve()
output = path / "templates" / "blogs"

# get blogs
entries = prepare_blogs("https://medium.com/feed/@transinformed")

for blog in entries:
# set as html
blog_content = blog.content[0].value

# modify with classes - should be done here as much as possible to minimise adjustments needed
blog_content = blog_content.replace("<h4>", " <h4 class=\"blog-description description-text\">", 1)
blog_content = blog_content.replace("<h3>", "<h3 class=\"blog-header\">")
blog_content = blog_content.replace("<img", "<img class=\"blog-image-container blog-image\"")
blog_content = blog_content.replace("<figcaption>", "<figcaption class=\"blog-image-caption\">")
blog_content = blog_content.replace("<p>", "<p class=\"blog-paragraph\">")
blog_content = blog_content.replace("<em>", "<em class=\"blog-disclaimer\">")
blog_content = blog_content.replace("<blockquote>", "<blockquote class=\"blog-quote\">")
blog_content = blog_content.replace("<h4>", " <h4 class=\"blog-subheading blog-subheading-layout\">")


blog_file_path = output / f"{blog.title}.html"
if not blog_file_path.is_file():
with open(blog_file_path, 'w+') as f:
# output to html file with inheritance of blog.html - allows for modifying HTML directly for formatting
# when articles are updated, they will need to be manually deleted and re-created
f.write("{% extends 'blog.html' %}\n{{ super() }}\n{% block blog_body %}\n" + blog_content + "\n{% endblock %}\n{% block ad %}\n{{ super() }}\n{% endblock %}")

print(f"{blog.title} added!")
1 change: 1 addition & 0 deletions app/static/css/about.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/static/css/about.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/static/css/base.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/static/css/base.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/static/css/blog.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1313b0e

Please sign in to comment.