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.

index.mako 10 KiB

10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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>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>
  37. <form action="${request.script_root}" method="get">
  38. <table id="cv-form">
  39. <tr>
  40. <td>Site:</td>
  41. <td colspan="3">
  42. <span class="mono">http://</span>
  43. <select name="lang">
  44. <% 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 %>\
  45. % for code, name in query.all_langs:
  46. % if code == selected_lang:
  47. <option value="${code | h}" selected="selected">${name}</option>
  48. % else:
  49. <option value="${code | h}">${name}</option>
  50. % endif
  51. % endfor
  52. </select>
  53. <span class="mono">.</span>
  54. <select name="project">
  55. <% selected_project = query.project if query.project else g.cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in g.cookies else g.bot.wiki.get_site().project %>\
  56. % for code, name in query.all_projects:
  57. % if code == selected_project:
  58. <option value="${code | h}" selected="selected">${name}</option>
  59. % else:
  60. <option value="${code | h}">${name}</option>
  61. % endif
  62. % endfor
  63. </select>
  64. <span class="mono">.org</span>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td id="cv-col1">Page&nbsp;title:</td>
  69. <td id="cv-col2">
  70. % if query.title:
  71. <input class="cv-text" type="text" name="title" value="${query.page.title if query.page else query.title | h}" />
  72. % else:
  73. <input class="cv-text" type="text" name="title" />
  74. % endif
  75. </td>
  76. <td id="cv-col3">or&nbsp;revision&nbsp;ID:</td>
  77. <td id="cv-col4">
  78. % if query.oldid:
  79. <input class="cv-text" type="text" name="oldid" value="${query.oldid | h}" />
  80. % else:
  81. <input class="cv-text" type="text" name="oldid" />
  82. % endif
  83. </td>
  84. </tr>
  85. <tr>
  86. <td>URL&nbsp;(optional):</td>
  87. <td colspan="3">
  88. % if query.url:
  89. <input class="cv-text" type="text" name="url" value="${query.url | h}" />
  90. % else:
  91. <input class="cv-text" type="text" name="url" />
  92. % endif
  93. </td>
  94. </tr>
  95. % if query.nocache or (result and result.cached):
  96. <tr>
  97. <td>Bypass&nbsp;cache:</td>
  98. <td colspan="3">
  99. % if query.nocache:
  100. <input type="checkbox" name="nocache" value="1" checked="checked" />
  101. % else:
  102. <input type="checkbox" name="nocache" value="1" />
  103. % endif
  104. </td>
  105. </tr>
  106. % endif
  107. <tr>
  108. <td colspan="4">
  109. <button type="submit">Submit</button>
  110. </td>
  111. </tr>
  112. </table>
  113. </form>
  114. % if result:
  115. <% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %>
  116. <div class="divider"></div>
  117. <div id="cv-result" class="${'red' if result.confidence >= T_SUSPECT else 'yellow' if result.confidence >= T_POSSIBLE else 'green'}-box">
  118. <h2 id="cv-result-header">
  119. % if result.confidence >= T_POSSIBLE:
  120. <a href="${query.page.url}">${query.page.title | h}</a>
  121. % if query.oldid:
  122. @<a href="//${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>
  123. % endif
  124. is a ${"suspected" if result.confidence >= T_SUSPECT else "possible"} violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.
  125. % else:
  126. % if query.oldid:
  127. 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>.
  128. % else:
  129. No violations detected in <a href="${query.page.url}">${query.page.title | h}</a>.
  130. % endif
  131. % endif
  132. </h2>
  133. <ul id="cv-result-list">
  134. % if result.confidence < T_POSSIBLE and not query.url:
  135. % if result.url:
  136. <li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li>
  137. % else:
  138. <li>No matches found.</li>
  139. % endif
  140. % endif
  141. % if result.url:
  142. <li><b><span class="mono">${round(result.confidence * 100, 1)}%</span></b> confidence of a violation.</li>
  143. % endif
  144. % if query.redirected_from:
  145. <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>
  146. % endif
  147. % if result.cached:
  148. <li>
  149. 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
  150. % if result.queries:
  151. <span class="mono">${round(result.original_time, 3)}</span>s using <span class="mono">${result.queries}</span> queries).
  152. % else:
  153. <span class="mono">${round(result.original_time, 3)}</span>s).
  154. % endif
  155. <a href="${request.url | httpsfix, h}&amp;nocache=1">Bypass the cache.</a>
  156. </li>
  157. % else:
  158. <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
  159. % endif
  160. % if result.queries:
  161. <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>
  162. % endif
  163. <li><a id="cv-chain-link" href="#cv-chain-table" onclick="copyvio_toggle_details()">${"Show" if hide_comparison else "Hide"} comparison:</a></li>
  164. </ul>
  165. <table id="cv-chain-table" style="display: ${'none' if hide_comparison else 'table'};">
  166. <tr>
  167. <td class="cv-chain-cell">Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.delta_chain)}</p></div></td>
  168. <td class="cv-chain-cell">Source: <div class="cv-chain-detail"><p>${highlight_delta(result.source_chain, result.delta_chain)}</p></div></td>
  169. </tr>
  170. </table>
  171. </div>
  172. % endif
  173. <%include file="/support/footer.mako"/>