A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.mako 18 KiB

10 år sedan
7 år sedan
10 år sedan
10 år sedan
10 år sedan
7 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <%!
  2. from flask import g, request
  3. from copyvios.attribution import get_attribution_info
  4. from copyvios.checker import T_POSSIBLE, T_SUSPECT
  5. from copyvios.misc import cache
  6. %>\
  7. <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/>
  8. <%namespace module="copyvios.highlighter" import="highlight_delta"/>\
  9. <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\
  10. % if notice:
  11. <div id="notice-box" class="gray-box">
  12. ${notice}
  13. </div>
  14. % endif
  15. % if query.submitted:
  16. % if query.error:
  17. <div id="info-box" class="red-box"><p>
  18. % if query.error == "bad action":
  19. Unknown action: <b><span class="mono">${query.action | h}</span></b>.
  20. % elif query.error == "no search method":
  21. 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.
  22. % elif query.error == "no URL":
  23. 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.
  24. % elif query.error == "bad URI":
  25. Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.
  26. % elif query.error == "no data":
  27. 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.
  28. % elif query.error == "timeout":
  29. The URL <a href="${query.url | h}">${query.url | h}</a> timed out before any data could be retrieved.
  30. % elif query.error == "search error":
  31. An error occurred while using the search engine (${query.exception}). Try reloading the page. If the error persists, <a href="${request.url | httpsfix, h}&amp;use_engine=0">repeat the check without using the search engine</a>.
  32. % else:
  33. An unknown error occurred.
  34. % endif
  35. </p></div>
  36. % elif not query.site:
  37. <div id="info-box" class="red-box">
  38. <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>
  39. </div>
  40. % elif query.oldid and not result:
  41. <div id="info-box" class="red-box">
  42. <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>
  43. </div>
  44. % elif query.title and not result:
  45. <div id="info-box" class="red-box">
  46. <p>The given page doesn't seem to exist: <a href="${query.page.url}">${query.page.title | h}</a>.</p>
  47. </div>
  48. % endif
  49. %endif
  50. <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 skip the searching step and display a report comparing the article to the given webpage, like the <a href="//tools.wmflabs.org/dupdet/">Duplication Detector</a>.</p>
  51. <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>
  52. <p>Specific websites can be skipped (for example, if they copy from Wikipedia) by being added to the <a href="//en.wikipedia.org/wiki/User:EarwigBot/Copyvios/Exclusions">excluded URL list</a>.</p>
  53. <form id="cv-form" action="${request.script_root}" method="get">
  54. <table id="cv-form-outer">
  55. <tr>
  56. <td>Site:</td>
  57. <td colspan="3">
  58. <span class="mono">https://</span>
  59. <select name="lang">
  60. <% 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 %>\
  61. % for code, name in cache.langs:
  62. % if code == selected_lang:
  63. <option value="${code | h}" selected="selected">${name}</option>
  64. % else:
  65. <option value="${code | h}">${name}</option>
  66. % endif
  67. % endfor
  68. </select>
  69. <span class="mono">.</span>
  70. <select name="project">
  71. <% selected_project = query.project if query.project else g.cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in g.cookies else cache.bot.wiki.get_site().project %>\
  72. % for code, name in cache.projects:
  73. % if code == selected_project:
  74. <option value="${code | h}" selected="selected">${name}</option>
  75. % else:
  76. <option value="${code | h}">${name}</option>
  77. % endif
  78. % endfor
  79. </select>
  80. <span class="mono">.org</span>
  81. </td>
  82. </tr>
  83. <tr>
  84. <td id="cv-col1">Page&nbsp;title:</td>
  85. <td id="cv-col2">
  86. % if query.title:
  87. <input class="cv-text" type="text" name="title" value="${query.page.title if query.page else query.title | h}" />
  88. % else:
  89. <input class="cv-text" type="text" name="title" />
  90. % endif
  91. </td>
  92. <td id="cv-col3">or&nbsp;revision&nbsp;ID:</td>
  93. <td id="cv-col4">
  94. % if query.oldid:
  95. <input class="cv-text" type="text" name="oldid" value="${query.oldid | h}" />
  96. % else:
  97. <input class="cv-text" type="text" name="oldid" />
  98. % endif
  99. </td>
  100. </tr>
  101. <tr>
  102. <td>Action:</td>
  103. <td colspan="3">
  104. <table id="cv-form-inner">
  105. <tr>
  106. <td id="cv-inner-col1">
  107. <input id="action-search" type="radio" name="action" value="search" ${'checked="checked"' if (query.action == "search" or not query.action) else ""} />
  108. </td>
  109. <td id="cv-inner-col2"><label for="action-search">Copyvio&nbsp;search:</label></td>
  110. <td id="cv-inner-col3">
  111. <input type="hidden" name="use_engine" value="0" />
  112. <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 ""} />
  113. <label for="cv-cb-engine">Use&nbsp;search&nbsp;engine</label>
  114. <input type="hidden" name="use_links" value="0" />
  115. <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 ""} />
  116. <label for="cv-cb-links">Use&nbsp;links&nbsp;in&nbsp;page</label>
  117. <input type="hidden" name="turnitin" value="0" />
  118. <input id="cv-cb-turnitin" class="cv-search" type="checkbox" name="turnitin" value="1" ${'checked="checked"' if query.turnitin in ("1", "true") else ""}/>
  119. <label for="cv-cb-turnitin">Use&nbsp;Turnitin</label>
  120. </td>
  121. </tr>
  122. <tr>
  123. <td>
  124. <input id="action-compare" type="radio" name="action" value="compare" ${'checked="checked"' if query.action == "compare" else ""} />
  125. </td>
  126. <td><label for="action-compare">URL&nbsp;comparison:</label></td>
  127. <td>
  128. <input class="cv-compare cv-text" type="text" name="url"
  129. % if query.url:
  130. value="${query.url | h}"
  131. % endif
  132. />
  133. </td>
  134. </tr>
  135. </table>
  136. </td>
  137. </tr>
  138. % if query.nocache or (result and result.cached):
  139. <tr>
  140. <td><label for="cb-nocache">Bypass&nbsp;cache:</label></td>
  141. <td colspan="3">
  142. <input id="cb-nocache" type="checkbox" name="nocache" value="1" ${'checked="checked"' if query.nocache else ""} />
  143. </td>
  144. </tr>
  145. % endif
  146. <tr>
  147. <td colspan="4">
  148. <button type="submit">Submit</button>
  149. </td>
  150. </tr>
  151. </table>
  152. </form>
  153. % if result:
  154. <div id="generation-time">
  155. Results
  156. % if result.cached:
  157. <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
  158. % endif
  159. generated in <span class="mono">${round(result.time, 3)}</span>
  160. % if query.action == "search":
  161. seconds using <span class="mono">${result.queries}</span> quer${"y" if result.queries == 1 else "ies"}.
  162. % else:
  163. seconds.
  164. % endif
  165. <a href="${request.script_root | h}?lang=${query.lang | h}&amp;project=${query.project | h}&amp;oldid=${query.oldid or query.page.lastrevid | h}&amp;action=${query.action | h}&amp;${"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>
  166. </div>
  167. <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
  168. <table id="cv-result-head-table">
  169. <colgroup>
  170. <col>
  171. <col>
  172. <col>
  173. </colgroup>
  174. <tr>
  175. <td>
  176. <a href="${query.page.url}">${query.page.title | h}</a>
  177. % if query.oldid:
  178. @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  179. % endif
  180. % if query.redirected_from:
  181. <br />
  182. <span id="redirected-from">Redirected from <a href="//${query.site.domain | h}/w/index.php?title=${query.redirected_from.title | u}&amp;redirect=no">${query.redirected_from.title | h}</a>. <a href="${request.url | httpsfix, h}&amp;noredirect=1">Check original.</a></span>
  183. % endif
  184. </td>
  185. <td>
  186. <div>
  187. % if result.confidence >= T_SUSPECT:
  188. Violation&nbsp;Suspected
  189. % elif result.confidence >= T_POSSIBLE:
  190. Violation&nbsp;Possible
  191. % elif result.sources:
  192. Violation&nbsp;Unlikely
  193. % else:
  194. No&nbsp;Violation
  195. % endif
  196. </div>
  197. <div>${round(result.confidence * 100, 1)}%</div>
  198. <div>confidence</div>
  199. </td>
  200. <td>
  201. % if result.url:
  202. <a href="${result.url | h}">${result.url | urlstrip, h}</a>
  203. % else:
  204. <span id="result-head-no-sources">No matches found.</span>
  205. % endif
  206. </td>
  207. </tr>
  208. </table>
  209. </div>
  210. <% attrib = get_attribution_info(query.site, query.page) %>
  211. % if attrib:
  212. <% attrib_page = query.site.get_page(unicode(attrib.name)) %>
  213. <div id="attribution-warning" class="yellow-box">
  214. This article contains an attribution template: <tt>{{<a href="attrib_page.url">${attrib_page.title | h}</a>}}</tt>. Please verify that any potential copyvios are not from properly attributed sources.
  215. </div>
  216. % endif
  217. % if query.turnitin_result:
  218. <div id="turnitin-container" class="${'red' if query.turnitin_result.reports else 'green'}-box">
  219. <div id="turnitin-title">Turnitin Results</div>
  220. % if query.turnitin_result.reports:
  221. <table id="turnitin-table"><tbody>
  222. % for report in turnitin_result.reports:
  223. <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}&amp;diff=${report.diffid}"> ${report.time_posted.strftime("%H:%M, %d %B %Y (UTC)")}</a>:
  224. <ul>
  225. % for source in report.sources:
  226. <li>${source['percent']}% of revision text (${source['words']} words) found at <a href="${source['url'] | h}">${source['url'] | h}</a></li>
  227. % endfor
  228. </ul></td></tr>
  229. % endfor
  230. </tbody></table>
  231. % else:
  232. <div id="turnitin-summary">No matching sources found.</div>
  233. % endif
  234. </div>
  235. % endif
  236. % if query.action == "search":
  237. <% skips = False %>
  238. <div id="sources-container">
  239. <div id="sources-title">Checked Sources</div>
  240. % if result.sources:
  241. <table id="cv-result-sources">
  242. <colgroup>
  243. <col>
  244. <col>
  245. <col>
  246. </colgroup>
  247. <tr>
  248. <th>URL</th>
  249. <th>Confidence</th>
  250. <th>Compare</th>
  251. </tr>
  252. % for i, source in enumerate(result.sources):
  253. <tr ${'class="source-default-hidden"' if i >= 10 else 'id="source-row-selected"' if i == 0 else ""}>
  254. <td><a ${'id="source-selected"' if i == 0 else ""} class="source-url" href="${source.url | h}">${source.url | h}</a></td>
  255. <td>
  256. % if source.excluded:
  257. <span class="source-excluded">Excluded</span>
  258. % elif source.skipped:
  259. <% skips = True %>
  260. <span class="source-skipped">Skipped</span>
  261. % else:
  262. <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>
  263. % endif
  264. </td>
  265. <td>
  266. <a href="${request.script_root | h}?lang=${query.lang | h}&amp;project=${query.project | h}&amp;oldid=${query.oldid or query.page.lastrevid | h}&amp;action=compare&amp;url=${source.url | u}">Compare</a>
  267. </td>
  268. </tr>
  269. % endfor
  270. </table>
  271. % else:
  272. <div class="cv-source-footer">
  273. No sources checked.
  274. </div>
  275. % endif
  276. % if len(result.sources) > 10:
  277. <div id="cv-additional" class="cv-source-footer">
  278. ${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>
  279. </div>
  280. % endif
  281. % if skips or result.possible_miss:
  282. <div class="cv-source-footer">
  283. The search ended early because a match was found with high confidence. <a href="${request.url | httpsfix, h}&amp;noskip=1">Do a complete check.</a>
  284. </div>
  285. % endif
  286. </div>
  287. % endif
  288. <div id="cv-chain-container">
  289. <table id="cv-chain-table">
  290. <tr>
  291. <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>
  292. <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>
  293. </tr>
  294. </table>
  295. </div>
  296. % endif
  297. <%include file="/support/footer.mako"/>