Sfoglia il codice sorgente

Refactor get_site() to copyvios.mako directly instead of the checker.

pull/24/head
Ben Kurtovic 12 anni fa
parent
commit
420a1708e0
2 ha cambiato i file con 10 aggiunte e 10 eliminazioni
  1. +7
    -4
      pages/copyvios.mako
  2. +3
    -6
      pages/support/copyvios/checker.py

+ 7
- 4
pages/copyvios.mako Vedi File

@@ -7,6 +7,9 @@
<%namespace module="support.misc" import="urlstrip"/>\
<%
lang = orig_lang = project = name = title = url = None
site = page = result = None

# Parse the query string.
query = parse_qs(environ["QUERY_STRING"])
if "lang" in query:
lang = orig_lang = query["lang"][0].decode("utf8").lower()
@@ -18,13 +21,13 @@
title = query["title"][0].decode("utf8")
if "url" in query:
url = query["url"][0].decode("utf8")

bot = Bot(".earwigbot")
all_langs, all_projects = get_sites(bot)
if lang and project and title:
site, page, result = get_results(bot, lang, project, name,
all_projects, title, url, query)
else:
site = page = result = None
site = get_site(bot, lang, project, name, all_projects)
if site:
page, result = get_results(bot, site, title, url, query)
%>\
<%include file="/support/header.mako" args="environ=environ, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>
<h1>Copyvio Detector</h1>


+ 3
- 6
pages/support/copyvios/checker.py Vedi File

@@ -8,15 +8,12 @@ from earwigbot import exceptions

from ..misc import open_sql_connection

def get_results(context, bot, lang, project, name, all_projects, title, url, query):
site = get_site(bot, lang, project, name, all_projects)
if not site:
return None, None, None
def get_results(context, bot, site, title, url, query):
page = site.get_page(title)
try:
page.get() # Make sure that the page exists before we check it!
except (exceptions.PageNotFoundError, exceptions.InvalidPageError):
return site, page, None
return page, None

# if url:
# result = get_url_specific_results(page, url)
@@ -35,7 +32,7 @@ def get_results(context, bot, lang, project, name, all_projects, title, url, que
result.cached = False
result.tdiff = time() - tstart
# END TEST BLOCK
return site, page, result
return page, result

def get_url_specific_results(page, url):
t_start = time()


Caricamento…
Annulla
Salva