Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2634c144a7 | |||
| 16373d3e55 | |||
| 337001a939 | |||
| ab009e4f59 |
@@ -3,7 +3,7 @@ import logging
|
||||
import os
|
||||
from logging.config import dictConfig
|
||||
|
||||
from flask import Flask, request
|
||||
from flask import Flask, request, send_from_directory
|
||||
|
||||
from ._version import get_versions
|
||||
|
||||
@@ -17,12 +17,11 @@ def create_app(instance_path=None, test_config=None):
|
||||
# if it doesn't already exist, create the instance folder
|
||||
os.makedirs(app.instance_path, exist_ok=True)
|
||||
|
||||
if test_config is None:
|
||||
# load defaults from config provided with the application
|
||||
app.config.from_object('incorporealcms.config.Config')
|
||||
# load specific instance configurations
|
||||
app.config.from_pyfile('config.py', silent=True)
|
||||
else:
|
||||
# load defaults from config provided with the application
|
||||
app.config.from_object('incorporealcms.config.Config')
|
||||
# load specific instance configurations
|
||||
app.config.from_pyfile('config.py', silent=True)
|
||||
if test_config:
|
||||
app.config.from_mapping(test_config)
|
||||
|
||||
dictConfig(app.config['LOGGING'])
|
||||
@@ -35,6 +34,11 @@ def create_app(instance_path=None, test_config=None):
|
||||
def log_request():
|
||||
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
|
||||
app.register_blueprint(pages.bp)
|
||||
|
||||
|
||||
@@ -31,3 +31,6 @@ class Config(object):
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
TITLE_SUFFIX = 'incorporeal.org'
|
||||
MEDIA_DIR = 'media'
|
||||
|
||||
@@ -1,12 +1,41 @@
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
padding: 0 1em;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
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 {
|
||||
display: block;
|
||||
font-size: 75%;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<title>{{ title }}{% if title %} - {% endif %}incorporeal.org</title>
|
||||
<title>{{ title }}{% if title %} - {% endif %}{{ config.TITLE_SUFFIX }}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
<link rel="icon" href="{{ url_for('static', filename='img/favicon.png') }}">
|
||||
<section class="content">
|
||||
|
||||
2
setup.py
2
setup.py
@@ -15,7 +15,7 @@ def extract_requires():
|
||||
|
||||
setup(
|
||||
name='incorporeal-cms',
|
||||
description='Flask project for running https://incorporeal.org.',
|
||||
description='Flask project for running https://suou.net (and eventually others).',
|
||||
url='https://git.incorporeal.org/bss/incorporeal-cms',
|
||||
license='GPL3',
|
||||
author='Brian S. Stephan',
|
||||
|
||||
BIN
tests/instance/media/favicon.png
Normal file
BIN
tests/instance/media/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
29
tests/test_factory.py
Normal file
29
tests/test_factory.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Test basic configuration stuff."""
|
||||
import os
|
||||
|
||||
from incorporealcms import create_app
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def test_config():
|
||||
"""Test create_app without passing test config."""
|
||||
instance_path = os.path.join(HERE, 'instance')
|
||||
assert not create_app(instance_path=instance_path).testing
|
||||
assert create_app(instance_path=instance_path, test_config={"TESTING": True}).testing
|
||||
|
||||
|
||||
def test_title_override():
|
||||
"""Test that a configuration with a specific title overrides the default."""
|
||||
instance_path = os.path.join(HERE, 'instance')
|
||||
app = create_app(instance_path=instance_path, test_config={'TITLE_SUFFIX': 'suou.net'})
|
||||
client = app.test_client()
|
||||
response = client.get('/no-title')
|
||||
assert response.status_code == 200
|
||||
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'
|
||||
Reference in New Issue
Block a user