Quellcode durchsuchen

Support general/update notices.

pull/24/head
Ben Kurtovic vor 9 Jahren
Ursprung
Commit
b325ef84cd
4 geänderte Dateien mit 41 neuen und 5 gelöschten Zeilen
  1. +4
    -2
      app.py
  2. +11
    -1
      copyvios/misc.py
  3. +21
    -2
      static/style.css
  4. +5
    -0
      templates/index.mako

+ 4
- 2
app.py Datei anzeigen

@@ -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


+ 11
- 1
copyvios/misc.py Datei anzeigen

@@ -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] == "<!-- active -->":
return "\n".join(lines[1:])
return None
except IOError:
return None

def httpsfix(context, url):
if url.startswith("http://"):
url = url[len("http:"):]


+ 21
- 2
static/style.css Datei anzeigen

@@ -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;
}


+ 5
- 0
templates/index.mako Datei anzeigen

@@ -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:
<div id="notice-box" class="gray-box">
${notice}
</div>
% endif
% if query.submitted:
% if query.error:
<div id="info-box" class="red-box"><p>


Laden…
Abbrechen
Speichern