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.
 
 
 
 
 

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