@@ -9,7 +9,10 @@ from earwigbot import exceptions | |||||
from .misc import Query, get_cache_db | from .misc import Query, get_cache_db | ||||
from .sites import get_site, get_sites | from .sites import get_site, get_sites | ||||
__all__ = ["do_check"] | |||||
__all__ = ["do_check", "T_POSSIBLE", "T_SUSPECT"] | |||||
T_POSSIBLE = 0.3 | |||||
T_SUSPECT = 0.6 | |||||
def do_check(): | def do_check(): | ||||
query = Query() | query = Query() | ||||
@@ -60,7 +63,8 @@ def _get_results(query, follow=True): | |||||
if not query.nocache: | if not query.nocache: | ||||
query.result = _get_cached_results(page, conn, query) | query.result = _get_cached_results(page, conn, query) | ||||
if not query.result: | if not query.result: | ||||
query.result = page.copyvio_check(max_queries=10, max_time=45) | |||||
query.result = page.copyvio_check( | |||||
min_confidence=T_SUSPECT, max_queries=10, max_time=45) | |||||
query.result.cached = False | query.result.cached = False | ||||
_cache_result(page, query.result, conn) | _cache_result(page, query.result, conn) | ||||
@@ -108,7 +112,7 @@ def _get_cached_results(page, conn, query): | |||||
return result | return result | ||||
def _do_copyvio_compare(query, page, url): | def _do_copyvio_compare(query, page, url): | ||||
result = page.copyvio_compare(url, max_time=30) | |||||
result = page.copyvio_compare(url, min_confidence=T_SUSPECT, max_time=30) | |||||
if result.source_chain is not page.EMPTY: | if result.source_chain is not page.EMPTY: | ||||
return result | return result | ||||
query.error = "timeout" if result.time > 30 else "no data" | query.error = "timeout" if result.time > 30 else "no data" | ||||
@@ -126,6 +126,11 @@ div.green-box { | |||||
border: 1px solid #7F7; | border: 1px solid #7F7; | ||||
} | } | ||||
div.yellow-box { | |||||
background-color: #FFE; | |||||
border: 1px solid #FF7; | |||||
} | |||||
div.red-box { | div.red-box { | ||||
background-color: #FEE; | background-color: #FEE; | ||||
border: 1px solid #F77; | border: 1px solid #F77; | ||||
@@ -1,5 +1,6 @@ | |||||
<%! from flask import g, request %>\ | <%! from flask import g, request %>\ | ||||
<%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.checker" import="T_POSSIBLE, T_SUSPECT"/>\ | |||||
<%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 query.project and query.lang and (query.title or query.oldid): | % if query.project and query.lang and (query.title or query.oldid): | ||||
@@ -111,12 +112,13 @@ | |||||
% if result: | % if result: | ||||
<% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %> | <% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %> | ||||
<div class="divider"></div> | <div class="divider"></div> | ||||
<div id="cv-result" class="${'red' if result.violation else 'green'}-box"> | |||||
% if result.violation: | |||||
<div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box"> | |||||
% if result.confidence >= T_POSSIBLE: | |||||
<% vio_type = "suspected" if result.confidence >= T_SUSPECT else "possible" %> | |||||
% if query.oldid: | % if query.oldid: | ||||
<h2 id="cv-result-header"><a href="${query.page.url}">${query.page.title | h}</a> @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a> is a suspected violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2> | |||||
<h2 id="cv-result-header"><a href="${query.page.url}">${query.page.title | h}</a> @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a> is a ${vio_type} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2> | |||||
% else: | % else: | ||||
<h2 id="cv-result-header"><a href="${query.page.url}">${query.page.title | h}</a> is a suspected violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2> | |||||
<h2 id="cv-result-header"><a href="${query.page.url}">${query.page.title | h}</a> is a ${vio_type} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2> | |||||
% endif | % endif | ||||
% else: | % else: | ||||
% if query.oldid: | % if query.oldid: | ||||
@@ -126,7 +128,7 @@ | |||||
% endif | % endif | ||||
% endif | % endif | ||||
<ul id="cv-result-list"> | <ul id="cv-result-list"> | ||||
% if not result.violation and not query.url: | |||||
% if result.confidence < T_POSSIBLE and not query.url: | |||||
% if result.url: | % if result.url: | ||||
<li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li> | <li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li> | ||||
% else: | % else: | ||||