ソースを参照

Cookies to store state of collapsable box.

pull/24/head
Ben Kurtovic 12年前
コミット
79a938f3b9
5個のファイルの変更57行の追加7行の削除
  1. +12
    -3
      pages/copyvios.mako
  2. +0
    -2
      pages/extensions.mako
  3. +0
    -1
      pages/index.mako
  4. +38
    -1
      static/js/copyvios.js
  5. +7
    -0
      toolserver/misc.py

+ 12
- 3
pages/copyvios.mako ファイルの表示

@@ -1,7 +1,8 @@
<%include file="/support/header.mako" args="environ=environ, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>\
<%namespace module="toolserver.copyvios" import="main, highlight_delta"/>\
<%namespace module="toolserver.misc" import="urlstrip"/>\
<%namespace module="toolserver.misc" import="parse_cookies, urlstrip"/>\
<% query, bot, all_langs, all_projects, page, result = main(environ) %>
<% cookies = parse_cookies(environ) %>
<h1>Copyvio Detector</h1>
<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 you want to check and hit Submit. The tool will then search for its content elsewhere on the web and display a report if a similar webpage 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>
<form action="${environ['PATH_INFO']}" method="get">
@@ -94,9 +95,17 @@
% else:
<li>Results generated in <tt>${round(result.tdiff, 3)}</tt> seconds using <tt>${result.queries}</tt> queries.</li>
% endif
<li><a id="cv-result-detail-link" href="#cv-result-detail" onclick="copyvio_toggle_details()">Show details:</a></li>
% if "EarwigCVShowDetails" cookies and cookies["EarwigCVShowDetails"] == "True":
<li><a id="cv-result-detail-link" href="#cv-result-detail" onclick="copyvio_toggle_details()">Hide details:</a></li>
% else:
<li><a id="cv-result-detail-link" href="#cv-result-detail" onclick="copyvio_toggle_details()">Show details:</a></li>
% endif
</ul>
<div id="cv-result-detail" style="display: none;">
% if "EarwigCVShowDetails" cookies and cookies["EarwigCVShowDetails"] == "True":
<div id="cv-result-detail" style="display: block;">
% else:
<div id="cv-result-detail" style="display: none;">
% endif
<ul id="cv-result-detail-list">
<li>Trigrams: <i>Article:</i> <tt>${result.article_chain.size()}</tt> / <i>Source:</i> <tt>${result.source_chain.size()}</tt> / <i>Delta:</i> <tt>${result.delta_chain.size()}</tt></li>
% if result.cached:


+ 0
- 2
pages/extensions.mako ファイルの表示

@@ -1,2 +0,0 @@
<%include file="/support/header.mako" args="environ=environ, title='File Extension Checker'"/>
<%include file="/support/footer.mako" args="environ=environ"/>

+ 0
- 1
pages/index.mako ファイルの表示

@@ -5,7 +5,6 @@
("Home", "home", "index", True, None),
("Copyvio Detector", "copyvios", "copyvios", True, "Blah"),
("EarwigBot Status", "earwigbot", "earwigbot", True, "Blah"),
("File Extension Checker", "extensions", "extensions", False, "Blah"),
("Contribution Surveyor", "surveyor", "surveyor", False, "Blah"),
("SWMT Helper", "swmt", "swmt", False, "Blah"),
]


+ 38
- 1
static/js/copyvios.js ファイルの表示

@@ -1,12 +1,49 @@
// Thanks to http://www.quirksmode.org/js/cookies.html for the cookie code.

function get_cookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length, c.length);
}
}
return null;
}

function set_cookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else {
var expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/~earwig";
}

function delete_cookie(name) {
set_cookie(name, "", -1);
}

function copyvio_toggle_details(details) {
link = document.getElementById("cv-result-detail-link");
details = document.getElementById("cv-result-detail");
if (link.innerHTML == "Show details:") {
details.style.display = "block";
link.innerHTML = "Hide details:";
set_cookie("EarwigCVShowDetails", "True", 180);
} else {
details.style.display = "none";
link.innerHTML = "Show details:";
if (get_cookie("EarwigCVShowDetails")) {
delete_cookie("EarwigCVShowDetails");
}
}
}

+ 7
- 0
toolserver/misc.py ファイルの表示

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from Cookie import CookieError, SimpleCookie
from os.path import expanduser
from urlparse import parse_qs

@@ -45,3 +46,9 @@ def urlstrip(context, url):
if url.endswith("/"):
url = url[:-1]
return url

def parse_cookies(context, environ):
try:
return SimpleCookie(environ["HTTP_COOKIE"])
except CookieError:
return SimpleCookie()

読み込み中…
キャンセル
保存