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.
 
 
 
 
 

172 lines
10 KiB

  1. <%! from flask import g, request %>\
  2. <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/>
  3. <%namespace module="copyvios.checker" import="T_POSSIBLE, T_SUSPECT"/>\
  4. <%namespace module="copyvios.highlighter" import="highlight_delta"/>\
  5. <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\
  6. % if query.project and query.lang and (query.title or query.oldid):
  7. % if query.error == "bad URI":
  8. <div id="info-box" class="red-box">
  9. <p>Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.</p>
  10. </div>
  11. % elif query.error == "no data":
  12. <div id="info-box" class="red-box">
  13. <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>
  14. </div>
  15. % elif query.error == "timeout":
  16. <div id="info-box" class="red-box">
  17. <p>The URL <a href="${query.url | h}">${query.url | h}</a> timed out before any data could be retrieved.</p>
  18. </div>
  19. % elif not query.site:
  20. <div id="info-box" class="red-box">
  21. <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>
  22. </div>
  23. % elif query.title and not result:
  24. <div id="info-box" class="red-box">
  25. <p>The given page doesn't seem to exist: <a href="${query.page.url}">${query.page.title | h}</a>.</p>
  26. </div>
  27. % elif query.oldid and not result:
  28. <div id="info-box" class="red-box">
  29. <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>
  30. </div>
  31. % endif
  32. %endif
  33. <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>
  34. <p>Specific websites can be excluded from the check (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>
  35. <form action="${request.script_root}" method="get">
  36. <table id="cv-form">
  37. <tr>
  38. <td>Site:</td>
  39. <td colspan="3">
  40. <span class="mono">http://</span>
  41. <select name="lang">
  42. <% 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 %>\
  43. % for code, name in query.all_langs:
  44. % if code == selected_lang:
  45. <option value="${code | h}" selected="selected">${name}</option>
  46. % else:
  47. <option value="${code | h}">${name}</option>
  48. % endif
  49. % endfor
  50. </select>
  51. <span class="mono">.</span>
  52. <select name="project">
  53. <% selected_project = query.project if query.project else g.cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in g.cookies else g.bot.wiki.get_site().project %>\
  54. % for code, name in query.all_projects:
  55. % if code == selected_project:
  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">.org</span>
  63. </td>
  64. </tr>
  65. <tr>
  66. <td id="cv-col1">Page&nbsp;title:</td>
  67. <td id="cv-col2">
  68. % if query.title:
  69. <input class="cv-text" type="text" name="title" value="${query.page.title if query.page else query.title | h}" />
  70. % else:
  71. <input class="cv-text" type="text" name="title" />
  72. % endif
  73. </td>
  74. <td id="cv-col3">or&nbsp;revision&nbsp;ID:</td>
  75. <td id="cv-col4">
  76. % if query.oldid:
  77. <input class="cv-text" type="text" name="oldid" value="${query.oldid | h}" />
  78. % else:
  79. <input class="cv-text" type="text" name="oldid" />
  80. % endif
  81. </td>
  82. </tr>
  83. <tr>
  84. <td>URL&nbsp;(optional):</td>
  85. <td colspan="3">
  86. % if query.url:
  87. <input class="cv-text" type="text" name="url" value="${query.url | h}" />
  88. % else:
  89. <input class="cv-text" type="text" name="url" />
  90. % endif
  91. </td>
  92. </tr>
  93. % if query.nocache or (result and result.cached):
  94. <tr>
  95. <td>Bypass&nbsp;cache:</td>
  96. <td colspan="3">
  97. % if query.nocache:
  98. <input type="checkbox" name="nocache" value="1" checked="checked" />
  99. % else:
  100. <input type="checkbox" name="nocache" value="1" />
  101. % endif
  102. </td>
  103. </tr>
  104. % endif
  105. <tr>
  106. <td colspan="4">
  107. <button type="submit">Submit</button>
  108. </td>
  109. </tr>
  110. </table>
  111. </form>
  112. % if result:
  113. <% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %>
  114. <div class="divider"></div>
  115. <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
  116. <h2 id="cv-result-header">
  117. % if result.confidence >= T_POSSIBLE:
  118. <a href="${query.page.url}">${query.page.title | h}</a>
  119. % if query.oldid:
  120. @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  121. % endif
  122. is a ${"suspected" if result.confidence >= T_SUSPECT else "possible"} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.
  123. % else:
  124. % if query.oldid:
  125. 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>.
  126. % else:
  127. No violations detected in <a href="${query.page.url}">${query.page.title | h}</a>.
  128. % endif
  129. % endif
  130. </h2>
  131. <ul id="cv-result-list">
  132. % if result.confidence < T_POSSIBLE and not query.url:
  133. % if result.url:
  134. <li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li>
  135. % else:
  136. <li>No matches found.</li>
  137. % endif
  138. % endif
  139. % if result.url:
  140. <li><b><span class="mono">${round(result.confidence * 100, 1)}%</span></b> confidence of a violation.</li>
  141. % endif
  142. % if query.redirected_from:
  143. <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>
  144. % endif
  145. % if result.cached:
  146. <li>
  147. 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
  148. % if result.queries:
  149. <span class="mono">${round(result.original_time, 3)}</span>s using <span class="mono">${result.queries}</span> queries).
  150. % else:
  151. <span class="mono">${round(result.original_time, 3)}</span>s).
  152. % endif
  153. <a href="${request.url | httpsfix, h}&amp;nocache=1">Bypass the cache.</a>
  154. </li>
  155. % else:
  156. <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
  157. % endif
  158. % if result.queries:
  159. <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>
  160. % endif
  161. <li><a id="cv-chain-link" href="#cv-chain-table" onclick="copyvio_toggle_details()">${"Show" if hide_comparison else "Hide"} comparison:</a></li>
  162. </ul>
  163. <table id="cv-chain-table" style="display: ${'none' if hide_comparison else 'table'};">
  164. <tr>
  165. <td class="cv-chain-cell">Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.delta_chain)}</p></div></td>
  166. <td class="cv-chain-cell">Source: <div class="cv-chain-detail"><p>${highlight_delta(result.source_chain, result.delta_chain)}</p></div></td>
  167. </tr>
  168. </table>
  169. </div>
  170. % endif
  171. <%include file="/support/footer.mako"/>