Browse Source

Fix some URL stuff.

pull/24/head
Ben Kurtovic 10 years ago
parent
commit
cea99098ce
4 changed files with 17 additions and 9 deletions
  1. +5
    -2
      copyvios/checker.py
  2. +5
    -0
      copyvios/misc.py
  3. +4
    -4
      templates/index.mako
  4. +3
    -3
      templates/settings.mako

+ 5
- 2
copyvios/checker.py View File

@@ -20,10 +20,13 @@ def do_check():


query.bot = get_bot() query.bot = get_bot()
query.all_langs, query.all_projects = get_sites(query.bot) query.all_langs, query.all_projects = get_sites(query.bot)
if query.project and query.lang and query.title: # TODO: and (query.title or query.oldid): ...
if query.project and query.lang and (query.title or query.oldid):
query.site = get_site(query) query.site = get_site(query)
if query.site: if query.site:
_get_results(query)
if query.title:
_get_results(query)
elif query.oldid:
pass
return query return query


def _get_results(query): def _get_results(query):


+ 5
- 0
copyvios/misc.py View File

@@ -59,6 +59,11 @@ def open_sql_connection(bot, dbname):
_connections[dbname] = conn _connections[dbname] = conn
return conn return conn


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

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


+ 4
- 4
templates/index.mako View File

@@ -1,7 +1,7 @@
<%! 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.highlighter" import="highlight_delta"/>\ <%namespace module="copyvios.highlighter" import="highlight_delta"/>\
<%namespace module="copyvios.misc" import="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):
% if query.error == "bad URI": % if query.error == "bad URI":
<div id="info-box" class="red-box"> <div id="info-box" class="red-box">
@@ -17,13 +17,13 @@
</div> </div>
% elif query.oldid and not result: % elif query.oldid and not result:
<div id="info-box" class="red-box"> <div id="info-box" class="red-box">
<p>The given revision ID doesn't seem to exist: <a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>.</p>
<p>The given revision ID doesn't seem to exist: <a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>. <i>Note:</i> searching by revision IDs isn't supported just yet, but it will be soon. Sorry for the inconvenience!</p>
</div> </div>
% endif % endif
%endif %endif
<p>This tool attempts to detect <a href="//en.wikipedia.org/wiki/WP:COPYVIO">copyright violations</a> in articles. Simply give the title of the page or ID of the revision you want to check and hit Submit. The tool will search for similar content elsewhere on the web using <a href="//info.yahoo.com/legal/us/yahoo/boss/pricing/">Yahoo! BOSS</a> and then display a report if a match is found. If you give a URL, it will skip the search engine step and directly display a report comparing the article to that particular webpage, like the <a href="//toolserver.org/~dcoetzee/duplicationdetector/">Duplication Detector</a>.</p> <p>This tool attempts to detect <a href="//en.wikipedia.org/wiki/WP:COPYVIO">copyright violations</a> in articles. Simply give the title of the page or ID of the revision you want to check and hit Submit. The tool will search for similar content elsewhere on the web using <a href="//info.yahoo.com/legal/us/yahoo/boss/pricing/">Yahoo! BOSS</a> and then display a report if a match is found. If you give a URL, it will skip the search engine step and directly display a report comparing the article to that particular webpage, like the <a href="//toolserver.org/~dcoetzee/duplicationdetector/">Duplication Detector</a>.</p>
<p>Specific websites can be excluded from the check (for example, if their content is in the public domain) by being added to the <a href="//en.wikipedia.org/wiki/User:EarwigBot/Copyvios/Exclusions">excluded URL list</a>.</p> <p>Specific websites can be excluded from the check (for example, if their content is in the public domain) by being added to the <a href="//en.wikipedia.org/wiki/User:EarwigBot/Copyvios/Exclusions">excluded URL list</a>.</p>
<form action="${request.base_url}" method="get">
<form action="${request.script_root}" method="get">
<table id="cv-form"> <table id="cv-form">
<tr> <tr>
<td>Site:</td> <td>Site:</td>
@@ -123,7 +123,7 @@
% if result.cached: % if result.cached:
<li>Results are <a id="cv-cached" href="#">cached <li>Results are <a id="cv-cached" href="#">cached
<span>To save time (and money), this tool will retain the results of checks for up to 72 hours. This includes the URL of the "violated" source, but neither its content nor the content of the article. Future checks on the same page (assuming it remains unchanged) will not involve additional search queries, but a fresh comparison against the source URL will be made. If the page is modified, a new check will be run.</span> <span>To save time (and money), this tool will retain the results of checks for up to 72 hours. This includes the URL of the "violated" source, but neither its content nor the content of the article. Future checks on the same page (assuming it remains unchanged) will not involve additional search queries, but a fresh comparison against the source URL will be made. If the page is modified, a new check will be run.</span>
</a> from ${result.cache_time} (${result.cache_age} ago). <a href="${request.url | h}&amp;nocache=1">Bypass the cache.</a></li>
</a> from ${result.cache_time} (${result.cache_age} ago). <a href="${request.url | httpsfix, h}&amp;nocache=1">Bypass the cache.</a></li>
% else: % else:
<li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li> <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
% endif % endif


+ 3
- 3
templates/settings.mako View File

@@ -9,7 +9,7 @@
</div> </div>
% endif % endif
<p>This page contains some configurable options for the copyvio detector. Settings are saved as cookies. You can view and delete all cookies generated by this site at the bottom of this page.</p> <p>This page contains some configurable options for the copyvio detector. Settings are saved as cookies. You can view and delete all cookies generated by this site at the bottom of this page.</p>
<form action="${request.base_url}" method="post">
<form action="${request.script_root}/settings" method="post">
<table> <table>
<tr> <tr>
<td>Default site:</td> <td>Default site:</td>
@@ -86,7 +86,7 @@
<td><span class="mono">${cookie.value | h}</span></td> <td><span class="mono">${cookie.value | h}</span></td>
% endtry % endtry
<td> <td>
<form action="${request.base_url}" method="post">
<form action="${request.script_root}/settings" method="post">
<input type="hidden" name="action" value="delete"> <input type="hidden" name="action" value="delete">
<input type="hidden" name="cookie" value="${key | h}"> <input type="hidden" name="cookie" value="${key | h}">
<button type="submit">Delete</button> <button type="submit">Delete</button>
@@ -96,7 +96,7 @@
% endfor % endfor
<tr> <tr>
<td> <td>
<form action="${request.base_url}" method="post">
<form action="${request.script_root}/settings" method="post">
<input type="hidden" name="action" value="delete"> <input type="hidden" name="action" value="delete">
<input type="hidden" name="all" value="1"> <input type="hidden" name="all" value="1">
<button type="submit">Delete all</button> <button type="submit">Delete all</button>


Loading…
Cancel
Save