2 Commits

Author SHA1 Message Date
2634c144a7 support a media/ dir under the instance dir
this is for miscellaneous files that should be served directly rather
than being a page route
2020-03-08 11:48:49 -05:00
16373d3e55 custom styling to links, lighten up text a bit 2020-03-08 11:32:34 -05:00
5 changed files with 42 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ import logging
import os import os
from logging.config import dictConfig from logging.config import dictConfig
from flask import Flask, request from flask import Flask, request, send_from_directory
from ._version import get_versions from ._version import get_versions
@@ -34,6 +34,11 @@ def create_app(instance_path=None, test_config=None):
def log_request(): def log_request():
logger.info("REQUEST: [ %s ]", request.path) logger.info("REQUEST: [ %s ]", request.path)
@app.route(f'/{app.config["MEDIA_DIR"]}/<path:filename>')
def media_files(filename):
return send_from_directory(os.path.join(app.instance_path, app.config['MEDIA_DIR']),
filename)
from . import pages from . import pages
app.register_blueprint(pages.bp) app.register_blueprint(pages.bp)

View File

@@ -33,3 +33,4 @@ class Config(object):
} }
TITLE_SUFFIX = 'incorporeal.org' TITLE_SUFFIX = 'incorporeal.org'
MEDIA_DIR = 'media'

View File

@@ -1,12 +1,41 @@
html { html {
font-family: sans-serif; font-family: sans-serif;
padding: 0 1em; padding: 0 1em;
color: #222;
} }
h1,h2,h3,h4,h5,h6 { h1,h2,h3,h4,h5,h6 {
color: #811610; color: #811610;
} }
a:link {
color: #222;
font-weight: bold;
text-decoration: none;
border-bottom: 1px dotted #222;
}
a:visited {
color: #222;
font-weight: bold;
text-decoration: none;
border-bottom: 1px dotted #222;
}
a:hover {
color: #811610;
font-weight: bold;
text-decoration: none;
border-bottom: 1px dotted #222;
}
a:active {
color: #811610;
font-weight: bold;
text-decoration: none;
border-bottom: 1px dotted #222;
}
footer { footer {
display: block; display: block;
font-size: 75%; font-size: 75%;

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -21,3 +21,9 @@ def test_title_override():
response = client.get('/no-title') response = client.get('/no-title')
assert response.status_code == 200 assert response.status_code == 200
assert b'<title>suou.net</title>' in response.data assert b'<title>suou.net</title>' in response.data
def test_media_file_access(client):
response = client.get('/media/favicon.png')
assert response.status_code == 200
assert response.headers['content-type'] == 'image/png'