A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

262 lines
16 KiB

  1. <%!
  2. from flask import g, request
  3. from copyvios.checker import T_POSSIBLE, T_SUSPECT
  4. %>\
  5. <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/>
  6. <%namespace module="copyvios.highlighter" import="highlight_delta"/>\
  7. <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\
  8. % if query.submitted:
  9. % if query.error:
  10. <div id="info-box" class="red-box"><p>
  11. % if query.error == "bad action":
  12. Unknown action: <b><span class="mono">${query.action | h}</span></b>.
  13. % elif query.error == "no search method":
  14. No copyvio search methods were selected. A check can only be made using a search engine, links present in the page, or both.
  15. % elif query.error == "no URL":
  16. 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.
  17. % elif query.error == "bad URI":
  18. Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.
  19. % elif query.error == "no data":
  20. Couldn't find any text in <a href="${query.url | h}">${query.url | h}</a>. <i>Note:</i> only HTML and plain text pages are supported, and content generated by JavaScript or found inside iframes is ignored.
  21. % elif query.error == "timeout":
  22. The URL <a href="${query.url | h}">${query.url | h}</a> timed out before any data could be retrieved.
  23. % elif query.error == "search error":
  24. 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>.
  25. % else:
  26. An unknown error occurred.
  27. % endif
  28. </p></div>
  29. % elif not query.site:
  30. <div id="info-box" class="red-box">
  31. <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>
  32. </div>
  33. % elif query.title and not result:
  34. <div id="info-box" class="red-box">
  35. <p>The given page doesn't seem to exist: <a href="${query.page.url}">${query.page.title | h}</a>.</p>
  36. </div>
  37. % elif query.oldid and not result:
  38. <div id="info-box" class="red-box">
  39. <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>
  40. </div>
  41. % endif
  42. %endif
  43. <p>This tool attempts to detect <a href="//en.wikipedia.org/wiki/WP:COPYVIO">copyright violations</a> in articles. In search mode, it will check for similar content elsewhere on the web using <a href="//developer.yahoo.com/boss/search/">Yahoo! BOSS</a> and/or external links present in the text of the page, depending on which options are selected. In comparison mode, 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>
  44. <p>Running a full check can take up to 45 seconds if other websites are slow. Please be patient. If you get a timeout, wait a moment and refresh the page.</p>
  45. <p>Specific websites can be skipped (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>
  46. <form id="cv-form" action="${request.script_root}" method="get">
  47. <table id="cv-form-outer">
  48. <tr>
  49. <td>Site:</td>
  50. <td colspan="3">
  51. <span class="mono">https://</span>
  52. <select name="lang">
  53. <% selected_lang = query.orig_lang if query.orig_lang else g.cookies["CopyviosDefaultLang"].value if "CopyviosDefaultLang" in g.cookies else g.bot.wiki.get_site().lang %>\
  54. % for code, name in query.all_langs:
  55. % if code == selected_lang:
  56. <option value="${code | h}" selected="selected">${name}</option>
  57. % else:
  58. <option value="${code | h}">${name}</option>
  59. % endif
  60. % endfor
  61. </select>
  62. <span class="mono">.</span>
  63. <select name="project">
  64. <% selected_project = query.project if query.project else g.cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in g.cookies else g.bot.wiki.get_site().project %>\
  65. % for code, name in query.all_projects:
  66. % if code == selected_project:
  67. <option value="${code | h}" selected="selected">${name}</option>
  68. % else:
  69. <option value="${code | h}">${name}</option>
  70. % endif
  71. % endfor
  72. </select>
  73. <span class="mono">.org</span>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td id="cv-col1">Page&nbsp;title:</td>
  78. <td id="cv-col2">
  79. % if query.title:
  80. <input class="cv-text" type="text" name="title" value="${query.page.title if query.page else query.title | h}" />
  81. % else:
  82. <input class="cv-text" type="text" name="title" />
  83. % endif
  84. </td>
  85. <td id="cv-col3">or&nbsp;revision&nbsp;ID:</td>
  86. <td id="cv-col4">
  87. % if query.oldid:
  88. <input class="cv-text" type="text" name="oldid" value="${query.oldid | h}" />
  89. % else:
  90. <input class="cv-text" type="text" name="oldid" />
  91. % endif
  92. </td>
  93. </tr>
  94. <tr>
  95. <td>Action:</td>
  96. <td colspan="3">
  97. <table id="cv-form-inner">
  98. <tr>
  99. <td id="cv-inner-col1">
  100. <input id="action-search" type="radio" name="action" value="search" ${'checked="checked"' if (query.action == "search" or not query.action) else ""} />
  101. </td>
  102. <td id="cv-inner-col2"><label for="action-search">Copyvio&nbsp;search:</label></td>
  103. <td id="cv-inner-col3">
  104. <input class="cv-search" type="hidden" name="use_engine" value="0" />
  105. <input id="cv-cb-engine" class="cv-search" type="checkbox" name="use_engine" value="1" ${'checked="checked"' if (query.use_engine != "0") else ""} />
  106. <label for="cv-cb-engine">Use&nbsp;search&nbsp;engine</label>
  107. <input class="cv-search" type="hidden" name="use_links" value="0" />
  108. <input id="cv-cb-links" class="cv-search" type="checkbox" name="use_links" value="1" ${'checked="checked"' if (query.use_links != "0") else ""} />
  109. <label for="cv-cb-links">Use&nbsp;links&nbsp;in&nbsp;page</label>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>
  114. <input id="action-compare" type="radio" name="action" value="compare" ${'checked="checked"' if query.action == "compare" else ""} />
  115. </td>
  116. <td><label for="action-compare">URL&nbsp;comparison:</label></td>
  117. <td>
  118. <input class="cv-compare cv-text" type="text" name="url"
  119. % if query.url:
  120. value="${query.url | h}"
  121. % endif
  122. />
  123. </td>
  124. </tr>
  125. </table>
  126. </td>
  127. </tr>
  128. % if query.nocache or (result and result.cached):
  129. <tr>
  130. <td><label for="cb-nocache">Bypass&nbsp;cache:</label></td>
  131. <td colspan="3">
  132. <input id="cb-nocache" type="checkbox" name="nocache" value="1" ${'checked="checked"' if query.nocache else ""} />
  133. </td>
  134. </tr>
  135. % endif
  136. <tr>
  137. <td colspan="4">
  138. <button type="submit">Submit</button>
  139. </td>
  140. </tr>
  141. </table>
  142. </form>
  143. % if result:
  144. % if query.action == "compare":
  145. <div id="generation-time">Results generated in <span class="mono">${round(result.time, 3)}</span> seconds.</div>
  146. % endif
  147. <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
  148. % if query.action == "search":
  149. <h2 id="cv-result-header">
  150. % if result.confidence >= T_POSSIBLE:
  151. <a href="${query.page.url}">${query.page.title | h}</a>
  152. % if query.oldid:
  153. @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  154. % endif
  155. is a ${"suspected" if result.confidence >= T_SUSPECT else "possible"} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.
  156. % else:
  157. % if query.oldid:
  158. No violations detected in <a href="${query.page.url}">${query.page.title | h}</a> @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>.
  159. % else:
  160. No violations detected in <a href="${query.page.url}">${query.page.title | h}</a>.
  161. % endif
  162. % endif
  163. </h2>
  164. % elif query.action == "compare":
  165. <table id="cv-result-head-table">
  166. <tr>
  167. <td>
  168. <a href="${query.page.url}">${query.page.title | h}</a>
  169. % if query.oldid:
  170. @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  171. % endif
  172. % if query.redirected_from:
  173. <br />
  174. <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>
  175. % endif
  176. </td>
  177. <td>
  178. <div>
  179. % if result.confidence >= T_SUSPECT:
  180. Violation&nbsp;Suspected
  181. % elif result.confidence >= T_POSSIBLE:
  182. Violation&nbsp;Possible
  183. % else:
  184. Violation&nbsp;Unlikely
  185. % endif
  186. </div>
  187. <div>${round(result.confidence * 100, 1)}%</div>
  188. <div>confidence</div>
  189. </td>
  190. <td><a href="${result.url | h}">${result.url | urlstrip, h}</a></td>
  191. </tr>
  192. </table>
  193. % endif
  194. </div>
  195. <% skips = False %>
  196. % if query.action == "search":
  197. <div id="sources-container">
  198. <div id="sources-title">Checked Sources</div>
  199. % if result.sources:
  200. <table id="cv-result-sources">
  201. <tr>
  202. <th>URL</th>
  203. <th>Confidence</th>
  204. <th>Compare</th>
  205. </tr>
  206. % for i, source in enumerate(result.sources):
  207. <tr ${'class="source-default-hidden"' if i >= 10 else 'id="source-row-selected"' if i == 0 else ""}>
  208. <td><a ${'id="source-selected"' if i == 0 else ""} class="source-url" href="${source.url | h}">${source.url | h}</a></td>
  209. <td>
  210. % if source.skipped:
  211. <% skips = True %>
  212. <span class="source-skipped">Skipped</span>
  213. % else:
  214. <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>
  215. % endif
  216. </td>
  217. <td>
  218. % if i == 0:
  219. <a href="#cv-chain-table">Compare</a>
  220. % else:
  221. <a href="${request.url | httpsfix, h}&amp;action=compare&amp;url=${source.url | u}">Compare</a>
  222. % endif
  223. </td>
  224. </tr>
  225. % endfor
  226. </table>
  227. % else:
  228. <div id="cv-no-sources">
  229. <span class="source-footer-text">No sources checked.</span>
  230. </div>
  231. % endif
  232. % if len(result.sources) > 10:
  233. <div id="cv-additional">
  234. <span class="source-footer-text">${len(result.sources) - 10} URL${"s" if len(result.sources) > 11 else ""} with lower confidence hidden.</span> <a id="show-additional-sources" href="#">Show them.</a>
  235. </div>
  236. % endif
  237. </div>
  238. <ul id="cv-result-list">
  239. % if query.redirected_from:
  240. <li>Redirected from <a href="${query.redirected_from.url}">${query.redirected_from.title | h}</a>. <a href="${request.url | httpsfix, h}&amp;noredirect=1">Check the original page.</a></li>
  241. % endif
  242. % if skips:
  243. <li>Since a suspected source was found with a high confidence value, some URLs were skipped. <a href="${request.url | httpsfix, h}&amp;noskip=1">Check all URLs.</a></li>
  244. % endif
  245. % if result.cached:
  246. <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 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 generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries. <a href="${request.url | httpsfix, h}&amp;nocache=1">Bypass the cache.</a></li>
  247. % else:
  248. <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
  249. % endif
  250. </ul>
  251. % endif
  252. <div id="cv-chain-container">
  253. <table id="cv-chain-table">
  254. <tr>
  255. <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>
  256. <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>
  257. </tr>
  258. </table>
  259. </div>
  260. % endif
  261. <%include file="/support/footer.mako"/>