@@ -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.api import format_api_error, handle_api_request | ||||
from copyvios.checker import do_check | from copyvios.checker import do_check | ||||
from copyvios.cookies import parse_cookies | 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.settings import process_settings | ||||
from copyvios.sites import update_sites | from copyvios.sites import update_sites | ||||
@@ -80,9 +80,11 @@ def close_databases(error): | |||||
@app.route("/") | @app.route("/") | ||||
@catch_errors | @catch_errors | ||||
def index(): | def index(): | ||||
notice = get_notice() | |||||
update_sites() | update_sites() | ||||
query = do_check() | 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"]) | @app.route("/settings", methods=["GET", "POST"]) | ||||
@catch_errors | @catch_errors | ||||
@@ -8,7 +8,7 @@ from sqlalchemy.pool import manage | |||||
oursql = manage(oursql) | oursql = manage(oursql) | ||||
__all__ = ["Query", "cache", "get_db", "httpsfix", "urlstrip"] | |||||
__all__ = ["Query", "cache", "get_db", "get_notice", "httpsfix", "urlstrip"] | |||||
class Query(object): | class Query(object): | ||||
def __init__(self, method="GET"): | def __init__(self, method="GET"): | ||||
@@ -49,6 +49,16 @@ def get_db(): | |||||
g._db = oursql.connect(**args) | g._db = oursql.connect(**args) | ||||
return g._db | 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] == "<!-- active -->": | |||||
return "\n".join(lines[1:]) | |||||
return None | |||||
except IOError: | |||||
return None | |||||
def httpsfix(context, url): | def httpsfix(context, url): | ||||
if url.startswith("http://"): | if url.startswith("http://"): | ||||
url = url[len("http:"):] | url = url[len("http:"):] | ||||
@@ -44,9 +44,23 @@ div#footer { | |||||
background: #DDDDDD; | 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 { | div#info-box { | ||||
padding: 0 10px 0 10px; | |||||
margin: 10px 5px 10px 5px; | |||||
padding: 0 10px; | |||||
margin: 10px 5px; | |||||
} | } | ||||
div#cv-result { | div#cv-result { | ||||
@@ -235,6 +249,11 @@ div.red-box { | |||||
border: 1px solid #F77; | border: 1px solid #F77; | ||||
} | } | ||||
div.gray-box { | |||||
background-color: #EEE; | |||||
border: 1px solid #AAA; | |||||
} | |||||
div.indentable { | div.indentable { | ||||
white-space: pre-wrap; | white-space: pre-wrap; | ||||
} | } | ||||
@@ -6,6 +6,11 @@ | |||||
<%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/> | <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/> | ||||
<%namespace module="copyvios.highlighter" import="highlight_delta"/>\ | <%namespace module="copyvios.highlighter" import="highlight_delta"/>\ | ||||
<%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\ | <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\ | ||||
% if notice: | |||||
<div id="notice-box" class="gray-box"> | |||||
${notice} | |||||
</div> | |||||
% endif | |||||
% if query.submitted: | % if query.submitted: | ||||
% if query.error: | % if query.error: | ||||
<div id="info-box" class="red-box"><p> | <div id="info-box" class="red-box"><p> | ||||