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.
 
 
 
 
 

324 rivejä
21 KiB

  1. <%!
  2. from flask import request
  3. from copyvios.attribution import get_attribution_info
  4. from copyvios.checker import T_POSSIBLE, T_SUSPECT
  5. from copyvios.cookies import get_cookies
  6. from copyvios.misc import cache
  7. %>\
  8. <%
  9. titleparts = []
  10. if query.page:
  11. titleparts.append(query.page.title)
  12. titleparts.append("Earwig's Copyvio Detector")
  13. title = " | ".join(titleparts)
  14. cookies = get_cookies()
  15. %>\
  16. <%include file="/support/header.mako" args="title=title, splash=not result"/>
  17. <%namespace module="copyvios.highlighter" import="highlight_delta"/>\
  18. <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\
  19. % if notice:
  20. <div id="notice-box" class="gray-box">
  21. ${notice}
  22. </div>
  23. % endif
  24. % if query.submitted:
  25. % if query.error:
  26. <div id="info-box" class="red-box"><p>
  27. % if query.error == "bad action":
  28. Unknown action: <b><span class="mono">${query.action | h}</span></b>.
  29. % elif query.error == "no search method":
  30. 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.
  31. % elif query.error == "bad oldid":
  32. The revision ID <code>${query.oldid | h}</code> is invalid. It should be an integer.
  33. % elif query.error == "no URL":
  34. Compare 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.
  35. % elif query.error == "bad URI":
  36. Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.
  37. % elif query.error == "no data":
  38. 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.
  39. % elif query.error == "timeout":
  40. The URL <a href="${query.url | h}">${query.url | h}</a> timed out before any data could be retrieved.
  41. % elif query.error == "search error":
  42. An error occurred while using the search engine (${query.error.__cause__}). <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>.
  43. % else:
  44. An unknown error occurred.
  45. % endif
  46. </p></div>
  47. % elif not query.site:
  48. <div id="info-box" class="red-box">
  49. <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>
  50. </div>
  51. % elif query.oldid and not result:
  52. <div id="info-box" class="red-box">
  53. <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>
  54. </div>
  55. % elif query.title and not result:
  56. <div id="info-box" class="red-box">
  57. <p>The page couldn't be found: <a href="${query.page.url}">${query.page.title | h}</a>.</p>
  58. </div>
  59. % endif
  60. %endif
  61. <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>compare 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>
  62. <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>
  63. <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>
  64. <form id="cv-form" action="${request.script_root}/" method="get">
  65. <div class="oo-ui-layout oo-ui-horizontalLayout">
  66. <label class="site oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Site</label>
  67. <div class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-dropdownInputWidget oo-ui-dropdownInputWidget-php">
  68. <select name="lang" required="" class="oo-ui-inputWidget-input oo-ui-indicator-down" title="Language">
  69. <% selected_lang = query.orig_lang if query.orig_lang else cookies["CopyviosDefaultLang"].value if "CopyviosDefaultLang" in 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. </div>
  79. <div class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-dropdownInputWidget oo-ui-dropdownInputWidget-php">
  80. <select name="project" required="" class="oo-ui-inputWidget-input oo-ui-indicator-down" title="Project">
  81. <% selected_project = query.project if query.project else cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in cookies else cache.bot.wiki.get_site().project %>\
  82. % for code, name in cache.projects:
  83. % if code == selected_project:
  84. <option value="${code | h}" selected="selected">${name}</option>
  85. % else:
  86. <option value="${code | h}">${name}</option>
  87. % endif
  88. % endfor
  89. </select>
  90. </div>
  91. </div>
  92. <div class="oo-ui-layout oo-ui-horizontalLayout">
  93. <label for="cv-title" class="page oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Page</label>
  94. <div class="page-title oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-textInputWidget oo-ui-textInputWidget-type-text oo-ui-textInputWidget-php">
  95. <input id="cv-title" type="text" class="oo-ui-inputWidget-input" name="title" placeholder="Title" title="Page title"
  96. % if query.title:
  97. value="${query.page.title if query.page else query.title | h}"
  98. % endif
  99. >
  100. </div>
  101. <label class="oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">or</label>
  102. <div class="page-oldid oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-textInputWidget oo-ui-textInputWidget-type-text oo-ui-textInputWidget-php">
  103. <input id="cv-oldid" type="text" class="oo-ui-inputWidget-input" name="oldid" placeholder="Revision ID" title="Revision ID"
  104. % if query.oldid:
  105. value="${query.oldid | h}"
  106. % endif
  107. >
  108. </div>
  109. </div>
  110. <div class="oo-ui-layout oo-ui-horizontalLayout">
  111. <span class="oo-ui-widget oo-ui-widget-enabled">
  112. <span class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-radioInputWidget">
  113. <input id="action-search" class="oo-ui-inputWidget-input" type="radio" name="action" value="search" ${'checked="checked"' if (query.action == "search" or not query.action) else ""}><span></span>
  114. </span>
  115. <label for="action-search" class="action oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Copyvio search</label>
  116. </span>
  117. <input type="hidden" name="use_engine" value="0">
  118. <span class="oo-ui-widget oo-ui-widget-enabled">
  119. <span class="cv-search-oo-ui oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-checkboxInputWidget">
  120. <input id="cv-cb-engine" class="cv-search oo-ui-inputWidget-input" type="checkbox" name="use_engine" value="1" ${'checked="checked"' if query.use_engine not in ("0", "false") else ""}>
  121. <span class="oo-ui-checkboxInputWidget-checkIcon oo-ui-widget oo-ui-widget-enabled oo-ui-iconElement-icon oo-ui-icon-check oo-ui-iconElement oo-ui-labelElement-invisible oo-ui-iconWidget oo-ui-image-invert"></span>
  122. </span>
  123. <label for="cv-cb-engine" class="oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Use search engine</label>
  124. </span>
  125. <input type="hidden" name="use_links" value="0">
  126. <span class="oo-ui-widget oo-ui-widget-enabled">
  127. <span class="cv-search-oo-ui oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-checkboxInputWidget">
  128. <input id="cv-cb-links" class="cv-search oo-ui-inputWidget-input" type="checkbox" name="use_links" value="1" ${'checked="checked"' if query.use_links not in ("0", "false") else ""}>
  129. <span class="oo-ui-checkboxInputWidget-checkIcon oo-ui-widget oo-ui-widget-enabled oo-ui-iconElement-icon oo-ui-icon-check oo-ui-iconElement oo-ui-labelElement-invisible oo-ui-iconWidget oo-ui-image-invert"></span>
  130. </span>
  131. <label for="cv-cb-links" class="oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Use links in page</label>
  132. </span>
  133. <input type="hidden" name="turnitin" value="0">
  134. <span class="oo-ui-widget oo-ui-widget-enabled">
  135. <span class="cv-search-oo-ui oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-checkboxInputWidget">
  136. <input id="cv-cb-turnitin" class="cv-search oo-ui-inputWidget-input" type="checkbox" name="turnitin" value="1" ${'checked="checked"' if query.turnitin in ("1", "true") else ""}>
  137. <span class="oo-ui-checkboxInputWidget-checkIcon oo-ui-widget oo-ui-widget-enabled oo-ui-iconElement-icon oo-ui-icon-check oo-ui-iconElement oo-ui-labelElement-invisible oo-ui-iconWidget oo-ui-image-invert"></span>
  138. </span>
  139. <label for="cv-cb-turnitin" class="oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Use Turnitin</label>
  140. </span>
  141. </div>
  142. <div class="oo-ui-layout oo-ui-horizontalLayout">
  143. <span class="oo-ui-widget oo-ui-widget-enabled">
  144. <span class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-radioInputWidget">
  145. <input id="action-compare" class="oo-ui-inputWidget-input" type="radio" name="action" value="compare" ${'checked="checked"' if query.action == "compare" else ""}><span></span>
  146. </span>
  147. <label for="action-compare" class="action oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement-label oo-ui-labelElement oo-ui-labelWidget">Copyvio compare</label>
  148. </span>
  149. <div class="compare-url cv-compare-oo-ui oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-textInputWidget oo-ui-textInputWidget-type-text oo-ui-textInputWidget-php">
  150. <input type="text" class="cv-compare oo-ui-inputWidget-input" name="url" placeholder="URL" title="URL to compare"
  151. % if query.url:
  152. value="${query.url | h}"
  153. % endif
  154. >
  155. </div>
  156. </div>
  157. % if query.nocache or (result and result.cached):
  158. <div class="oo-ui-layout oo-ui-horizontalLayout">
  159. <span class="cv-search-oo-ui oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-checkboxInputWidget">
  160. <input id="cb-nocache" class="oo-ui-inputWidget-input" type="checkbox" name="nocache" value="1" ${'checked="checked"' if query.nocache else ""}>
  161. <span class="oo-ui-checkboxInputWidget-checkIcon oo-ui-widget oo-ui-widget-enabled oo-ui-iconElement-icon oo-ui-icon-check oo-ui-iconElement oo-ui-labelElement-invisible oo-ui-iconWidget oo-ui-image-invert"></span>
  162. </span>
  163. <label for="cb-nocache">Bypass cache</label>
  164. </div>
  165. % endif
  166. <div class="oo-ui-layout oo-ui-horizontalLayout">
  167. <span class="oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-primary oo-ui-flaggedElement-progressive oo-ui-buttonWidget">
  168. <button type="submit" class="oo-ui-inputWidget-input oo-ui-buttonElement-button">
  169. <span class="oo-ui-labelElement-label">Submit</span>
  170. </button>
  171. </span>
  172. </div>
  173. </form>
  174. % if result:
  175. <div id="generation-time">
  176. Results
  177. % if result.cached:
  178. <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
  179. % endif
  180. generated in <span class="mono">${round(result.time, 3)}</span>
  181. % if query.action == "search":
  182. seconds using <span class="mono">${result.queries}</span> quer${"y" if result.queries == 1 else "ies"}.
  183. % else:
  184. seconds.
  185. % endif
  186. <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>
  187. </div>
  188. <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
  189. <table id="cv-result-head-table">
  190. <colgroup>
  191. <col>
  192. <col>
  193. <col>
  194. </colgroup>
  195. <tr>
  196. <td>
  197. <a href="${query.page.url}">${query.page.title | h}</a>
  198. % if query.oldid:
  199. @<a href="https://${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  200. % endif
  201. % if query.redirected_from:
  202. <br />
  203. <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>
  204. % endif
  205. </td>
  206. <td>
  207. <div>
  208. % if result.confidence >= T_SUSPECT:
  209. Violation suspected
  210. % elif result.confidence >= T_POSSIBLE:
  211. Violation possible
  212. % elif result.sources:
  213. Violation unlikely
  214. % else:
  215. No violation
  216. % endif
  217. </div>
  218. <div>${round(result.confidence * 100, 1)}%</div>
  219. <div>similarity</div>
  220. </td>
  221. <td>
  222. % if result.url:
  223. <a href="${result.url | h}">${result.url | urlstrip, h}</a>
  224. % else:
  225. <span id="result-head-no-sources">No matches found.</span>
  226. % endif
  227. </td>
  228. </tr>
  229. </table>
  230. </div>
  231. <% attrib = get_attribution_info(query.site, query.page) %>
  232. % if attrib:
  233. <div id="attribution-warning" class="yellow-box">
  234. 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.
  235. </div>
  236. % endif
  237. % if query.turnitin_result:
  238. <div id="turnitin-container" class="${'red' if query.turnitin_result.reports else 'green'}-box">
  239. <div id="turnitin-title">Turnitin Results</div>
  240. % if query.turnitin_result.reports:
  241. <table id="turnitin-table"><tbody>
  242. % for report in turnitin_result.reports:
  243. <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>:
  244. <ul>
  245. % for source in report.sources:
  246. <li>${source['percent']}% of revision text (${source['words']} words) found at <a href="${source['url'] | h}">${source['url'] | h}</a></li>
  247. % endfor
  248. </ul></td></tr>
  249. % endfor
  250. </tbody></table>
  251. % else:
  252. <div id="turnitin-summary">No matching sources found.</div>
  253. % endif
  254. </div>
  255. % endif
  256. % if query.action == "search":
  257. <% skips = False %>
  258. <div id="sources-container">
  259. <div id="sources-title">Checked Sources</div>
  260. % if result.sources:
  261. <table id="cv-result-sources">
  262. <colgroup>
  263. <col>
  264. <col>
  265. <col>
  266. </colgroup>
  267. <tr>
  268. <th>URL</th>
  269. <th>Similarity</th>
  270. <th>Compare</th>
  271. </tr>
  272. % for i, source in enumerate(result.sources):
  273. <tr ${'class="source-default-hidden"' if i >= 10 else 'id="source-row-selected"' if i == 0 else ""}>
  274. <td><a ${'id="source-selected"' if i == 0 else ""} class="source-url" href="${source.url | h}">${source.url | h}</a></td>
  275. <td>
  276. % if source.excluded:
  277. <span class="source-excluded">Excluded</span>
  278. % elif source.skipped:
  279. <% skips = True %>
  280. <span class="source-skipped">Skipped</span>
  281. % else:
  282. <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>
  283. % endif
  284. </td>
  285. <td>
  286. <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>
  287. </td>
  288. </tr>
  289. % endfor
  290. </table>
  291. % else:
  292. <div class="cv-source-footer">
  293. No sources checked.
  294. </div>
  295. % endif
  296. % if len(result.sources) > 10:
  297. <div id="cv-additional" class="cv-source-footer">
  298. ${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>
  299. </div>
  300. % endif
  301. % if skips or result.possible_miss:
  302. <div class="cv-source-footer">
  303. 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>
  304. </div>
  305. % endif
  306. </div>
  307. % endif
  308. <table id="cv-chain-table">
  309. <tr>
  310. <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>
  311. <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>
  312. </tr>
  313. </table>
  314. % endif
  315. <%include file="/support/footer.mako"/>