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

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