瀏覽代碼

Use a yellow 'possible' box for confidence between 0.3 and 0.6 (closes #5).

pull/24/head
Ben Kurtovic 9 年之前
父節點
當前提交
ce96f0f8a6
共有 3 個文件被更改,包括 19 次插入8 次删除
  1. +7
    -3
      copyvios/checker.py
  2. +5
    -0
      static/style.css
  3. +7
    -5
      templates/index.mako

+ 7
- 3
copyvios/checker.py 查看文件

@@ -9,7 +9,10 @@ from earwigbot import exceptions
from .misc import Query, get_cache_db
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():
query = Query()
@@ -60,7 +63,8 @@ def _get_results(query, follow=True):
if not query.nocache:
query.result = _get_cached_results(page, conn, query)
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
_cache_result(page, query.result, conn)

@@ -108,7 +112,7 @@ def _get_cached_results(page, conn, query):
return result

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:
return result
query.error = "timeout" if result.time > 30 else "no data"


+ 5
- 0
static/style.css 查看文件

@@ -126,6 +126,11 @@ div.green-box {
border: 1px solid #7F7;
}

div.yellow-box {
background-color: #FFE;
border: 1px solid #FF7;
}

div.red-box {
background-color: #FEE;
border: 1px solid #F77;


+ 7
- 5
templates/index.mako 查看文件

@@ -1,5 +1,6 @@
<%! from flask import g, request %>\
<%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.misc" import="httpsfix, urlstrip"/>\
% if query.project and query.lang and (query.title or query.oldid):
@@ -111,12 +112,13 @@
% if result:
<% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %>
<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:
<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:
<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
% else:
% if query.oldid:
@@ -126,7 +128,7 @@
% endif
% endif
<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:
<li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li>
% else:


Loading…
取消
儲存