|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <%!
- from flask import g, request
- from copyvios.attribution import get_attribution_info
- from copyvios.checker import T_POSSIBLE, T_SUSPECT
- from copyvios.misc import cache
- %>\
- <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/>
- <%namespace module="copyvios.highlighter" import="highlight_delta"/>\
- <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\
- % if notice:
- <div id="notice-box" class="gray-box">
- ${notice}
- </div>
- % endif
- % if query.submitted:
- % if query.error:
- <div id="info-box" class="red-box"><p>
- % if query.error == "bad action":
- Unknown action: <b><span class="mono">${query.action | h}</span></b>.
- % elif query.error == "no search method":
- No copyvio search methods were selected. A check can only be made using the search engine, links present in the page, Turnitin, or some combination of these.
- % elif query.error == "no URL":
- 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.
- % elif query.error == "bad URI":
- Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.
- % elif query.error == "no data":
- Couldn't find any text in <a href="${query.url | h}">${query.url | h}</a>. <i>Note:</i> only HTML documents, plain text pages, and PDFs are supported, and content generated by JavaScript or found inside iframes is ignored.
- % elif query.error == "timeout":
- The URL <a href="${query.url | h}">${query.url | h}</a> timed out before any data could be retrieved.
- % elif query.error == "search error":
- An error occurred while using the search engine (${query.exception}). Try reloading the page. If the error persists, <a href="${request.url | httpsfix, h}&use_engine=0">repeat the check without using the search engine</a>.
- % else:
- An unknown error occurred.
- % endif
- </p></div>
- % elif not query.site:
- <div id="info-box" class="red-box">
- <p>The given site (project=<b><span class="mono">${query.project | h}</span></b>, language=<b><span class="mono">${query.lang | h}</span></b>) doesn't seem to exist. It may also be closed or private. <a href="//${query.lang | h}.${query.project | h}.org/">Confirm its URL.</a></p>
- </div>
- % elif query.oldid and not result:
- <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>
- </div>
- % elif query.title and not result:
- <div id="info-box" class="red-box">
- <p>The given page doesn't seem to exist: <a href="${query.page.url}">${query.page.title | h}</a>.</p>
- </div>
- % endif
- %endif
- <p>This tool attempts to detect <a href="//en.wikipedia.org/wiki/WP:COPYVIO">copyright violations</a> in articles. In <i>search mode</i>, it will check for similar content elsewhere on the web using <a href="https://developers.google.com/custom-search/">Google</a>, external links present in the text of the page, or <a href="//en.wikipedia.org/wiki/Wikipedia:Turnitin">Turnitin</a> (provided by <a href="//en.wikipedia.org/wiki/User:EranBot">EranBot</a>), depending on which options are selected. In <i>comparison mode</i>, the tool will compare the article to a specific webpage without making additional searches, like the <a href="//tools.wmflabs.org/dupdet/">Duplication Detector</a>.</p>
- <p>Running a full check can take up to a minute if other websites are slow or if the tool is under heavy use. Please be patient. If you get a timeout, wait a moment and refresh the page.</p>
- <p>Be aware that other websites can copy from Wikipedia, so check the results carefully, especially for older or well-developed articles. Specific websites can be skipped by being added to the <a href="//en.wikipedia.org/wiki/User:EarwigBot/Copyvios/Exclusions">excluded URL list</a>.</p>
- <form id="cv-form" action="${request.script_root}" method="get">
- <table id="cv-form-outer">
- <tr>
- <td>Site:</td>
- <td colspan="3">
- <span class="mono">https://</span>
- <select name="lang">
- <% selected_lang = query.orig_lang if query.orig_lang else g.cookies["CopyviosDefaultLang"].value if "CopyviosDefaultLang" in g.cookies else cache.bot.wiki.get_site().lang %>\
- % for code, name in cache.langs:
- % if code == selected_lang:
- <option value="${code | h}" selected="selected">${name}</option>
- % else:
- <option value="${code | h}">${name}</option>
- % endif
- % endfor
- </select>
- <span class="mono">.</span>
- <select name="project">
- <% selected_project = query.project if query.project else g.cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in g.cookies else cache.bot.wiki.get_site().project %>\
- % for code, name in cache.projects:
- % if code == selected_project:
- <option value="${code | h}" selected="selected">${name}</option>
- % else:
- <option value="${code | h}">${name}</option>
- % endif
- % endfor
- </select>
- <span class="mono">.org</span>
- </td>
- </tr>
- <tr>
- <td id="cv-col1">Page title:</td>
- <td id="cv-col2">
- % if query.title:
- <input class="cv-text" type="text" name="title" value="${query.page.title if query.page else query.title | h}" />
- % else:
- <input class="cv-text" type="text" name="title" />
- % endif
- </td>
- <td id="cv-col3">or revision ID:</td>
- <td id="cv-col4">
- % if query.oldid:
- <input class="cv-text" type="text" name="oldid" value="${query.oldid | h}" />
- % else:
- <input class="cv-text" type="text" name="oldid" />
- % endif
- </td>
- </tr>
- <tr>
- <td>Action:</td>
- <td colspan="3">
- <table id="cv-form-inner">
- <tr>
- <td id="cv-inner-col1">
- <input id="action-search" type="radio" name="action" value="search" ${'checked="checked"' if (query.action == "search" or not query.action) else ""} />
- </td>
- <td id="cv-inner-col2"><label for="action-search">Copyvio search:</label></td>
- <td id="cv-inner-col3">
- <input type="hidden" name="use_engine" value="0" />
- <input id="cv-cb-engine" class="cv-search" type="checkbox" name="use_engine" value="1" ${'checked="checked"' if query.use_engine not in ("0", "false") else ""} />
- <label for="cv-cb-engine">Use search engine</label>
-
- <input type="hidden" name="use_links" value="0" />
- <input id="cv-cb-links" class="cv-search" type="checkbox" name="use_links" value="1" ${'checked="checked"' if query.use_links not in ("0", "false") else ""} />
- <label for="cv-cb-links">Use links in page</label>
-
- <input type="hidden" name="turnitin" value="0" />
- <input id="cv-cb-turnitin" class="cv-search" type="checkbox" name="turnitin" value="1" ${'checked="checked"' if query.turnitin in ("1", "true") else ""}/>
- <label for="cv-cb-turnitin">Use Turnitin</label>
- </td>
- </tr>
- <tr>
- <td>
- <input id="action-compare" type="radio" name="action" value="compare" ${'checked="checked"' if query.action == "compare" else ""} />
- </td>
- <td><label for="action-compare">URL comparison:</label></td>
- <td>
- <input class="cv-compare cv-text" type="text" name="url"
- % if query.url:
- value="${query.url | h}"
- % endif
- />
- </td>
- </tr>
- </table>
- </td>
- </tr>
- % if query.nocache or (result and result.cached):
- <tr>
- <td><label for="cb-nocache">Bypass cache:</label></td>
- <td colspan="3">
- <input id="cb-nocache" type="checkbox" name="nocache" value="1" ${'checked="checked"' if query.nocache else ""} />
- </td>
- </tr>
- % endif
- <tr>
- <td colspan="4">
- <button type="submit">Submit</button>
- </td>
- </tr>
- </table>
- </form>
-
- % if result:
- <div id="generation-time">
- Results
- % if result.cached:
- <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 URLs of the checked sources, but neither their 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 <abbr title="${result.cache_time}">${result.cache_age} ago</abbr>. Originally
- % endif
- generated in <span class="mono">${round(result.time, 3)}</span>
- % if query.action == "search":
- seconds using <span class="mono">${result.queries}</span> quer${"y" if result.queries == 1 else "ies"}.
- % else:
- seconds.
- % endif
- <a href="${request.script_root | h}?lang=${query.lang | h}&project=${query.project | h}&oldid=${query.oldid or query.page.lastrevid | h}&action=${query.action | h}&${"use_engine={0}&use_links={1}".format(int(query.use_engine not in ("0", "false")), int(query.use_links not in ("0", "false"))) if query.action == "search" else "" | h}${"url=" if query.action == "compare" else ""}${query.url if query.action == "compare" else "" | u}">Permalink.</a>
- </div>
-
- <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
- <table id="cv-result-head-table">
- <colgroup>
- <col>
- <col>
- <col>
- </colgroup>
- <tr>
- <td>
- <a href="${query.page.url}">${query.page.title | h}</a>
- % if query.oldid:
- @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
- % endif
- % if query.redirected_from:
- <br />
- <span id="redirected-from">Redirected from <a href="//${query.site.domain | h}/w/index.php?title=${query.redirected_from.title | u}&redirect=no">${query.redirected_from.title | h}</a>. <a href="${request.url | httpsfix, h}&noredirect=1">Check original.</a></span>
- % endif
- </td>
- <td>
- <div>
- % if result.confidence >= T_SUSPECT:
- Violation Suspected
- % elif result.confidence >= T_POSSIBLE:
- Violation Possible
- % elif result.sources:
- Violation Unlikely
- % else:
- No Violation
- % endif
- </div>
- <div>${round(result.confidence * 100, 1)}%</div>
- <div>confidence</div>
- </td>
- <td>
- % if result.url:
- <a href="${result.url | h}">${result.url | urlstrip, h}</a>
- % else:
- <span id="result-head-no-sources">No matches found.</span>
- % endif
- </td>
- </tr>
- </table>
- </div>
-
- <% attrib = get_attribution_info(query.site, query.page) %>
- % if attrib:
- <div id="attribution-warning" class="yellow-box">
- This article contains an attribution template: <tt>{{<a href="${attrib[1]}">${attrib[0] | h}</a>}}</tt>. Please verify that any potential copyvios are not from properly attributed sources.
- </div>
- % endif
-
- % if query.turnitin_result:
- <div id="turnitin-container" class="${'red' if query.turnitin_result.reports else 'green'}-box">
- <div id="turnitin-title">Turnitin Results</div>
- % if query.turnitin_result.reports:
- <table id="turnitin-table"><tbody>
- % for report in turnitin_result.reports:
- <tr><td class="turnitin-table-cell"><a href="https://tools.wmflabs.org/eranbot/ithenticate.py?rid=${report.reportid}">Report ${report.reportid}</a> for text added at <a href="https://${query.lang}.wikipedia.org/w/index.php?title=${query.title}&diff=${report.diffid}"> ${report.time_posted.strftime("%H:%M, %d %B %Y (UTC)")}</a>:
- <ul>
- % for source in report.sources:
- <li>${source['percent']}% of revision text (${source['words']} words) found at <a href="${source['url'] | h}">${source['url'] | h}</a></li>
- % endfor
- </ul></td></tr>
- % endfor
- </tbody></table>
- % else:
- <div id="turnitin-summary">No matching sources found.</div>
- % endif
- </div>
- % endif
-
- % if query.action == "search":
- <% skips = False %>
- <div id="sources-container">
- <div id="sources-title">Checked Sources</div>
- % if result.sources:
- <table id="cv-result-sources">
- <colgroup>
- <col>
- <col>
- <col>
- </colgroup>
- <tr>
- <th>URL</th>
- <th>Confidence</th>
- <th>Compare</th>
- </tr>
- % for i, source in enumerate(result.sources):
- <tr ${'class="source-default-hidden"' if i >= 10 else 'id="source-row-selected"' if i == 0 else ""}>
- <td><a ${'id="source-selected"' if i == 0 else ""} class="source-url" href="${source.url | h}">${source.url | h}</a></td>
- <td>
- % if source.excluded:
- <span class="source-excluded">Excluded</span>
- % elif source.skipped:
- <% skips = True %>
- <span class="source-skipped">Skipped</span>
- % else:
- <span class="source-confidence ${"source-suspect" if source.confidence >= T_SUSPECT else "source-possible" if source.confidence >= T_POSSIBLE else "source-novio"}">${round(source.confidence * 100, 1)}%</span>
- % endif
- </td>
- <td>
- <a href="${request.script_root | h}?lang=${query.lang | h}&project=${query.project | h}&oldid=${query.oldid or query.page.lastrevid | h}&action=compare&url=${source.url | u}">Compare</a>
- </td>
- </tr>
- % endfor
- </table>
- % else:
- <div class="cv-source-footer">
- No sources checked.
- </div>
- % endif
- % if len(result.sources) > 10:
- <div id="cv-additional" class="cv-source-footer">
- ${len(result.sources) - 10} URL${"s" if len(result.sources) > 11 else ""} with lower confidence hidden. <a id="show-additional-sources" href="#">Show them.</a>
- </div>
- % endif
- % if skips or result.possible_miss:
- <div class="cv-source-footer">
- The search ended early because a match was found with high confidence. <a href="${request.url | httpsfix, h}&noskip=1">Do a complete check.</a>
- </div>
- % endif
- </div>
- % endif
- <div id="cv-chain-container">
- <table id="cv-chain-table">
- <tr>
- <td class="cv-chain-cell">Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.best.chains[1] if result.best else None)}</p></div></td>
- <td class="cv-chain-cell">Source: <div class="cv-chain-detail"><p>${highlight_delta(result.best.chains[0], result.best.chains[1]) if result.best else ""}</p></div></td>
- </tr>
- </table>
- </div>
- % endif
- <%include file="/support/footer.mako"/>
|