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.
 
 
 
 
 

175 lines
10 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.project and query.lang and (query.title or query.oldid):
  9. % if query.error == "bad URI":
  10. <div id="info-box" class="red-box">
  11. <p>Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.</p>
  12. </div>
  13. % elif query.error == "no data":
  14. <div id="info-box" class="red-box">
  15. <p>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.</p>
  16. </div>
  17. % elif query.error == "timeout":
  18. <div id="info-box" class="red-box">
  19. <p>The URL <a href="${query.url | h}">${query.url | h}</a> timed out before any data could be retrieved.</p>
  20. </div>
  21. % elif not query.site:
  22. <div id="info-box" class="red-box">
  23. <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>
  24. </div>
  25. % elif query.title and not result:
  26. <div id="info-box" class="red-box">
  27. <p>The given page doesn't seem to exist: <a href="${query.page.url}">${query.page.title | h}</a>.</p>
  28. </div>
  29. % elif query.oldid and not result:
  30. <div id="info-box" class="red-box">
  31. <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>
  32. </div>
  33. % endif
  34. %endif
  35. <p>This tool attempts to detect <a href="//en.wikipedia.org/wiki/WP:COPYVIO">copyright violations</a> in articles. Simply give the title of the page or ID of the revision you want to check and hit Submit. The tool will search for similar content elsewhere on the web using <a href="//info.yahoo.com/legal/us/yahoo/boss/pricing/">Yahoo! BOSS</a> and then display a report if a match is found. If you give a URL, it will skip the search engine step and directly display a report comparing the article to that particular webpage, like the <a href="//toolserver.org/~dcoetzee/duplicationdetector/">Duplication Detector</a>.</p>
  36. <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>
  37. <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>
  38. <form action="${request.script_root}" method="get">
  39. <table id="cv-form">
  40. <tr>
  41. <td>Site:</td>
  42. <td colspan="3">
  43. <span class="mono">http://</span>
  44. <select name="lang">
  45. <% 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 %>\
  46. % for code, name in query.all_langs:
  47. % if code == selected_lang:
  48. <option value="${code | h}" selected="selected">${name}</option>
  49. % else:
  50. <option value="${code | h}">${name}</option>
  51. % endif
  52. % endfor
  53. </select>
  54. <span class="mono">.</span>
  55. <select name="project">
  56. <% selected_project = query.project if query.project else g.cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in g.cookies else g.bot.wiki.get_site().project %>\
  57. % for code, name in query.all_projects:
  58. % if code == selected_project:
  59. <option value="${code | h}" selected="selected">${name}</option>
  60. % else:
  61. <option value="${code | h}">${name}</option>
  62. % endif
  63. % endfor
  64. </select>
  65. <span class="mono">.org</span>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td id="cv-col1">Page&nbsp;title:</td>
  70. <td id="cv-col2">
  71. % if query.title:
  72. <input class="cv-text" type="text" name="title" value="${query.page.title if query.page else query.title | h}" />
  73. % else:
  74. <input class="cv-text" type="text" name="title" />
  75. % endif
  76. </td>
  77. <td id="cv-col3">or&nbsp;revision&nbsp;ID:</td>
  78. <td id="cv-col4">
  79. % if query.oldid:
  80. <input class="cv-text" type="text" name="oldid" value="${query.oldid | h}" />
  81. % else:
  82. <input class="cv-text" type="text" name="oldid" />
  83. % endif
  84. </td>
  85. </tr>
  86. <tr>
  87. <td>URL&nbsp;(optional):</td>
  88. <td colspan="3">
  89. % if query.url:
  90. <input class="cv-text" type="text" name="url" value="${query.url | h}" />
  91. % else:
  92. <input class="cv-text" type="text" name="url" />
  93. % endif
  94. </td>
  95. </tr>
  96. % if query.nocache or (result and result.cached):
  97. <tr>
  98. <td>Bypass&nbsp;cache:</td>
  99. <td colspan="3">
  100. % if query.nocache:
  101. <input type="checkbox" name="nocache" value="1" checked="checked" />
  102. % else:
  103. <input type="checkbox" name="nocache" value="1" />
  104. % endif
  105. </td>
  106. </tr>
  107. % endif
  108. <tr>
  109. <td colspan="4">
  110. <button type="submit">Submit</button>
  111. </td>
  112. </tr>
  113. </table>
  114. </form>
  115. % if result:
  116. <% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %>
  117. <div class="divider"></div>
  118. <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
  119. <h2 id="cv-result-header">
  120. % if result.confidence >= T_POSSIBLE:
  121. <a href="${query.page.url}">${query.page.title | h}</a>
  122. % if query.oldid:
  123. @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  124. % endif
  125. is a ${"suspected" if result.confidence >= T_SUSPECT else "possible"} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.
  126. % else:
  127. % if query.oldid:
  128. 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>.
  129. % else:
  130. No violations detected in <a href="${query.page.url}">${query.page.title | h}</a>.
  131. % endif
  132. % endif
  133. </h2>
  134. <ul id="cv-result-list">
  135. % if result.confidence < T_POSSIBLE and not query.url:
  136. % if result.url:
  137. <li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li>
  138. % else:
  139. <li>No matches found.</li>
  140. % endif
  141. % endif
  142. % if result.url:
  143. <li><b><span class="mono">${round(result.confidence * 100, 1)}%</span></b> confidence of a violation.</li>
  144. % endif
  145. % if query.redirected_from:
  146. <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>
  147. % endif
  148. % if result.cached:
  149. <li>
  150. 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 URL of the "violated" source, but neither its 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>. Retrieved in <span class="mono">${round(result.time, 3)}</span> seconds (originally generated in
  151. % if result.queries:
  152. <span class="mono">${round(result.original_time, 3)}</span>s using <span class="mono">${result.queries}</span> queries).
  153. % else:
  154. <span class="mono">${round(result.original_time, 3)}</span>s).
  155. % endif
  156. <a href="${request.url | httpsfix, h}&amp;nocache=1">Bypass the cache.</a>
  157. </li>
  158. % else:
  159. <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
  160. % endif
  161. % if result.queries:
  162. <li><i>Fun fact:</i> The Wikimedia Foundation paid Yahoo! Inc. <a href="http://info.yahoo.com/legal/us/yahoo/search/bosspricing/details.html">$${result.queries * 0.0008} USD</a> for these results.</li>
  163. % endif
  164. <li><a id="cv-chain-link" href="#cv-chain-table" onclick="copyvio_toggle_details()">${"Show" if hide_comparison else "Hide"} comparison:</a></li>
  165. </ul>
  166. <table id="cv-chain-table" style="display: ${'none' if hide_comparison else 'table'};">
  167. <tr>
  168. <td class="cv-chain-cell">Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.delta_chain)}</p></div></td>
  169. <td class="cv-chain-cell">Source: <div class="cv-chain-detail"><p>${highlight_delta(result.source_chain, result.delta_chain)}</p></div></td>
  170. </tr>
  171. </table>
  172. </div>
  173. % endif
  174. <%include file="/support/footer.mako"/>