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.
 
 
 
 
 

171 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. % if result.confidence >= T_POSSIBLE:
  117. <% vio_type = "suspected" if result.confidence >= T_SUSPECT else "possible" %>
  118. % if query.oldid:
  119. <h2 id="cv-result-header"><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> is a ${vio_type} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2>
  120. % else:
  121. <h2 id="cv-result-header"><a href="${query.page.url}">${query.page.title | h}</a> is a ${vio_type} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2>
  122. % endif
  123. % else:
  124. % if query.oldid:
  125. <h2 id="cv-result-header">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>.</h2>
  126. % else:
  127. <h2 id="cv-result-header">No violations detected in <a href="${query.page.url}">${query.page.title | h}</a>.</h2>
  128. % endif
  129. % endif
  130. <ul id="cv-result-list">
  131. % if result.confidence < T_POSSIBLE and not query.url:
  132. % if result.url:
  133. <li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li>
  134. % else:
  135. <li>No matches found.</li>
  136. % endif
  137. % endif
  138. % if result.url:
  139. <li><b><span class="mono">${round(result.confidence * 100, 1)}%</span></b> confidence of a violation.</li>
  140. % endif
  141. % if query.redirected_from:
  142. <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>
  143. % endif
  144. % if result.cached:
  145. <li>
  146. 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
  147. % if result.queries:
  148. <span class="mono">${round(result.original_time, 3)}</span>s using <span class="mono">${result.queries}</span> queries).
  149. % else:
  150. <span class="mono">${round(result.original_time, 3)}</span>s).
  151. % endif
  152. <a href="${request.url | httpsfix, h}&amp;nocache=1">Bypass the cache.</a>
  153. </li>
  154. % else:
  155. <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
  156. % endif
  157. % if result.queries:
  158. <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>
  159. % endif
  160. <li><a id="cv-chain-link" href="#cv-chain-table" onclick="copyvio_toggle_details()">${"Show" if hide_comparison else "Hide"} comparison:</a></li>
  161. </ul>
  162. <table id="cv-chain-table" style="display: ${'none' if hide_comparison else 'table'};">
  163. <tr>
  164. <td class="cv-chain-cell">Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.delta_chain)}</p></div></td>
  165. <td class="cv-chain-cell">Source: <div class="cv-chain-detail"><p>${highlight_delta(result.source_chain, result.delta_chain)}</p></div></td>
  166. </tr>
  167. </table>
  168. </div>
  169. % endif
  170. <%include file="/support/footer.mako"/>