diff --git a/app.py b/app.py index e0c52dc..0cfe64c 100755 --- a/app.py +++ b/app.py @@ -16,7 +16,7 @@ from flask.ext.mako import MakoTemplates, render_template, TemplateError from copyvios.api import format_api_error, handle_api_request from copyvios.checker import do_check from copyvios.cookies import parse_cookies -from copyvios.misc import cache +from copyvios.misc import cache, get_notice from copyvios.settings import process_settings from copyvios.sites import update_sites @@ -80,9 +80,11 @@ def close_databases(error): @app.route("/") @catch_errors def index(): + notice = get_notice() update_sites() query = do_check() - return render_template("index.mako", query=query, result=query.result) + return render_template( + "index.mako", notice=notice, query=query, result=query.result) @app.route("/settings", methods=["GET", "POST"]) @catch_errors diff --git a/copyvios/misc.py b/copyvios/misc.py index b40f6f4..045386a 100644 --- a/copyvios/misc.py +++ b/copyvios/misc.py @@ -8,7 +8,7 @@ from sqlalchemy.pool import manage oursql = manage(oursql) -__all__ = ["Query", "cache", "get_db", "httpsfix", "urlstrip"] +__all__ = ["Query", "cache", "get_db", "get_notice", "httpsfix", "urlstrip"] class Query(object): def __init__(self, method="GET"): @@ -49,6 +49,16 @@ def get_db(): g._db = oursql.connect(**args) return g._db +def get_notice(): + try: + with open(expanduser("~/copyvios_notice.html")) as fp: + lines = fp.read().decode("utf8").strip().splitlines() + if lines[0] == "": + return "\n".join(lines[1:]) + return None + except IOError: + return None + def httpsfix(context, url): if url.startswith("http://"): url = url[len("http:"):] diff --git a/static/style.css b/static/style.css index 8c8d42e..3acdc99 100644 --- a/static/style.css +++ b/static/style.css @@ -44,9 +44,23 @@ div#footer { background: #DDDDDD; } +div#notice-box { + padding: 10px; + margin: 10px 5px; +} + +div#notice-box p { + margin: 0.25em 0; +} + +div#notice-box ul { + padding-left: 1.5em; + margin: 0; +} + div#info-box { - padding: 0 10px 0 10px; - margin: 10px 5px 10px 5px; + padding: 0 10px; + margin: 10px 5px; } div#cv-result { @@ -235,6 +249,11 @@ div.red-box { border: 1px solid #F77; } +div.gray-box { + background-color: #EEE; + border: 1px solid #AAA; +} + div.indentable { white-space: pre-wrap; } diff --git a/templates/index.mako b/templates/index.mako index 8187ccb..a61e173 100644 --- a/templates/index.mako +++ b/templates/index.mako @@ -6,6 +6,11 @@ <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/> <%namespace module="copyvios.highlighter" import="highlight_delta"/>\ <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\ +% if notice: +