A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

313 regels
18 KiB

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