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.
 
 
 
 
 

162 lines
12 KiB

  1. <%include file="/support/header.mako" args="environ=environ, cookies=cookies, title='Earwig\'s Copyvio Detector'"/>\
  2. <%namespace module="copyvios" import="main, highlight_delta"/>\
  3. <%namespace module="copyvios.misc" import="urlstrip"/>\
  4. <%
  5. query = main(environ)
  6. # Unpack query data:
  7. lang, orig_lang, title, oldid, url, nocache = query.lang, query.orig_lang, query.title, query.oldid, query.url, query.nocache
  8. bot, site, page, result = query.bot, query.site, query.page, query.result
  9. %>\
  10. % if query.project and lang and (title or oldid):
  11. % if not site:
  12. <div id="info-box" class="red-box">
  13. <p>The given site (project=<b><span class="mono">${query.project | h}</span></b>, language=<b><span class="mono">${lang | h}</span></b>) doesn't seem to exist. It may also be closed or private. <a href="//${lang | h}.${query.project | h}.org/">Confirm its URL.</a></p>
  14. </div>
  15. % elif title and not result:
  16. <div id="info-box" class="red-box">
  17. <p>The given page doesn't seem to exist: <a href="${page.url}">${page.title | h}</a>.</p>
  18. </div>
  19. % elif oldid and not result:
  20. <div id="info-box" class="red-box">
  21. <p>The given revision ID doesn't seem to exist: <a href="//${site.domain | h}/w/index.php?oldid=${oldid | h}">${oldid | h}</a>.</p>
  22. </div>
  23. % elif url and result == "bad URI":
  24. <% result = None %>
  25. <div id="info-box" class="red-box">
  26. <p>Unsupported URI scheme: <a href="${url | h}">${url | h}</a>.</p>
  27. </div>
  28. % endif
  29. %endif
  30. <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 and display a report if a match is found. If you also provide a URL, it will not query any search engines and instead display a report comparing the article to that particular webpage, like the <a href="//toolserver.org/~dcoetzee/duplicationdetector/">Duplication Detector</a>. Check out the <a href="//en.wikipedia.org/wiki/User:EarwigBot/Copyvios/FAQ">FAQ</a> for more information and technical details.</p>
  31. <p><i>Note:</i> The tool is still in beta. You are completely welcome to use it and provide <a href="//en.wikipedia.org/wiki/User_talk:The_Earwig">feedback</a>, but be aware that it may produce strange or broken results.</p>
  32. <form action="${environ['REQUEST_URI']}" method="get">
  33. <table id="cv-form">
  34. <tr>
  35. <td>Site:</td>
  36. <td colspan="3">
  37. <span class="mono">http://</span>
  38. <select name="lang">
  39. <% selected_lang = orig_lang if orig_lang else cookies["CopyviosDefaultLang"].value if "CopyviosDefaultLang" in cookies else bot.wiki.get_site().lang %>\
  40. % for code, name in query.all_langs:
  41. % if code == selected_lang:
  42. <option value="${code | h}" selected="selected">${name}</option>
  43. % else:
  44. <option value="${code | h}">${name}</option>
  45. % endif
  46. % endfor
  47. </select>
  48. <span class="mono">.</span>
  49. <select name="project">
  50. <% selected_project = query.project if query.project else cookies["CopyviosDefaultProject"].value if "CopyviosDefaultProject" in cookies else bot.wiki.get_site().project %>\
  51. % for code, name in query.all_projects:
  52. % if code == selected_project:
  53. <option value="${code | h}" selected="selected">${name}</option>
  54. % else:
  55. <option value="${code | h}">${name}</option>
  56. % endif
  57. % endfor
  58. </select>
  59. <span class="mono">.org</span>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td id="cv-col1">Page&nbsp;title:</td>
  64. <td id="cv-col2">
  65. % if page:
  66. <input class="cv-text" type="text" name="title" value="${page.title | h}" />
  67. % elif title:
  68. <input class="cv-text" type="text" name="title" value="${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 oldid:
  76. <input class="cv-text" type="text" name="oldid" value="${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 url:
  86. <input class="cv-text" type="text" name="url" value="${url | h}" />
  87. % else:
  88. <input class="cv-text" type="text" name="url" />
  89. % endif
  90. </td>
  91. </tr>
  92. % if nocache or (result and result.cached):
  93. <tr>
  94. <td>Bypass&nbsp;cache:</td>
  95. <td colspan="3">
  96. % if 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. <% show_details = "CopyviosShowDetails" in cookies and cookies["CopyviosShowDetails"].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. <h2 id="cv-result-header"><a href="${page.url}">${page.title | h}</a> is a suspected violation of <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</h2>
  117. % else:
  118. <h2 id="cv-result-header">No violations detected in <a href="${page.url}">${page.title | h}</a>.</h2>
  119. % endif
  120. <ul id="cv-result-list">
  121. % if not result.violation and not url:
  122. % if result.url:
  123. <li>Best match: <a href="${result.url | h}">${result.url | urlstrip, h}</a>.</li>
  124. % else:
  125. <li>No matches found.</li>
  126. % endif
  127. % endif
  128. <li><b><span class="mono">${round(result.confidence * 100, 1)}%</span></b> confidence of a violation.</li>
  129. % if result.cached:
  130. <li>Results are <a id="cv-cached" href="#">cached
  131. <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>
  132. </a> from ${result.cache_time} (${result.cache_age} ago). <a href="${environ['REQUEST_URI'] | h}&amp;nocache=1">Bypass the cache.</a></li>
  133. % else:
  134. <li>Results generated in <span class="mono">${round(result.time, 3)}</span> seconds using <span class="mono">${result.queries}</span> queries.</li>
  135. % endif
  136. <li><a id="cv-result-detail-link" href="#cv-result-detail" onclick="copyvio_toggle_details()">${"Hide" if show_details else "Show"} details:</a></li>
  137. </ul>
  138. <div id="cv-result-detail" style="display: ${'block' if show_details else 'none'};">
  139. <ul id="cv-result-detail-list">
  140. <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>
  141. % if result.cached:
  142. % if result.queries:
  143. <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>
  144. % else:
  145. <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>
  146. % endif
  147. % endif
  148. % if result.queries:
  149. <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>
  150. % endif
  151. </ul>
  152. <table id="cv-chain-table">
  153. <tr>
  154. <td class="cv-chain-cell">Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.delta_chain)}</p></div></td>
  155. <td class="cv-chain-cell">Source: <div class="cv-chain-detail"><p>${highlight_delta(result.source_chain, result.delta_chain)}</p></div></td>
  156. </tr>
  157. </table>
  158. </div>
  159. </div>
  160. % endif
  161. <%include file="/support/footer.mako" args="environ=environ, cookies=cookies"/>