Pārlūkot izejas kodu

Catch empty method error; fix blank values in query.

pull/24/head
Ben Kurtovic pirms 10 gadiem
vecāks
revīzija
6cd194f971
3 mainītis faili ar 15 papildinājumiem un 6 dzēšanām
  1. +5
    -2
      copyvios/checker.py
  2. +4
    -2
      copyvios/misc.py
  3. +6
    -2
      templates/index.mako

+ 5
- 2
copyvios/checker.py Parādīt failu

@@ -56,8 +56,11 @@ def _get_results(query, follow=True):
query.action = "compare" if query.url else "search"
if query.action == "search":
conn = get_cache_db()
use_engine = 1 if query.use_engine else 0
use_links = 1 if query.use_links else 0
use_engine = 1 if query.use_engine != "" else 0
use_links = 1 if query.use_links != "" else 0
if not use_engine and not use_links:
query.error = "no search method"
return
mode = "{0}:{1}:".format(use_engine, use_links)
if not query.nocache:
query.result = _get_cached_results(page, conn, query, mode)


+ 4
- 2
copyvios/misc.py Parādīt failu

@@ -15,10 +15,12 @@ class Query(object):
def __init__(self, method="GET"):
self.query = {}
if method == "GET":
parsed = parse_qs(request.environ["QUERY_STRING"])
parsed = parse_qs(request.environ["QUERY_STRING"],
keep_blank_values=True)
elif method == "POST":
size = int(request.environ.get("CONTENT_LENGTH", 0))
parsed = parse_qs(request.environ["wsgi.input"].read(size))
parsed = parse_qs(request.environ["wsgi.input"].read(size),
keep_blank_values=True)
else:
parsed = {}
for key, value in parsed.iteritems():


+ 6
- 2
templates/index.mako Parādīt failu

@@ -10,6 +10,10 @@
<div id="info-box" class="red-box">
<p>Unknown action: <b><span class="mono">${query.action | h}</span></b>.</p>
</div>
% elif query.error == "no search method":
<div id="info-box" class="red-box">
<p>No copyvio search methods were selected. A check can only be made using a search engine, links present in the page, or both.</p>
</div>
% elif query.error == "no URL":
<div id="info-box" class="red-box">
<p>URL comparison mode requires a URL to be entered. Enter one in the text box below, or choose copyvio search mode to look for content similar to the article elsewhere on the web.</p>
@@ -101,9 +105,9 @@
</td>
<td id="cv-inner-col2"><label for="action-search">Copyvio&nbsp;search:</label></td>
<td id="cv-inner-col3">
<input id="cv-cb-engine" type="checkbox" name="use_engine" value="1" ${'checked="checked"' if (query.use_engine or not query.submitted) else ""} />
<input id="cv-cb-engine" type="checkbox" name="use_engine" value="1" ${'checked="checked"' if (query.use_engine != "") else ""} />
<label for"cv-cb-engine">Use&nbsp;search&nbsp;engine</label>
<input id="cv-cb-links" type="checkbox" name="use_links" value="1" ${'checked="checked"' if (query.use_links or not query.submitted) else ""} />
<input id="cv-cb-links" type="checkbox" name="use_links" value="1" ${'checked="checked"' if (query.use_links != "") else ""} />
<label for="cv-cb-links">Use&nbsp;links&nbsp;in&nbsp;page</label>
</td>
</tr>


Notiek ielāde…
Atcelt
Saglabāt