diff --git a/build.py b/build.py index 6c1d96f..a3b293f 100755 --- a/build.py +++ b/build.py @@ -17,13 +17,17 @@ sys.path.insert(0, ".") from mako.template import Template from mako.lookup import TemplateLookup +from toolserver.cookies import parse_cookies + def main(environ, start_response): lookup = TemplateLookup(directories=["{{pages_dir}}"], input_encoding="utf8") template = Template(filename="{{src}}", module_directory="{{temp_dir}}", lookup=lookup, format_exceptions=True) headers = [("Content-Type", "text/html")] - page = template.render(environ=environ, headers=headers).encode("utf8") + cookies = parse_cookies(environ) + page = template.render(environ=environ, headers=headers, + cookies=cookies).encode("utf8") start_response("200 OK", headers) return [page] diff --git a/pages/copyvios.mako b/pages/copyvios.mako index 3c2a058..deba046 100644 --- a/pages/copyvios.mako +++ b/pages/copyvios.mako @@ -1,9 +1,7 @@ -<%include file="/support/header.mako" args="environ=environ, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>\ +<%include file="/support/header.mako" args="environ=environ, cookies=cookies, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>\ <%namespace module="toolserver.copyvios" import="main, highlight_delta"/>\ -<%namespace module="toolserver.cookies" import="parse_cookies"/>\ <%namespace module="toolserver.misc" import="urlstrip"/>\ <% query, bot, all_langs, all_projects, page, result = main(environ) %> -<% cookies = parse_cookies(environ) %>

Copyvio Detector

This tool attempts to detect copyright violations 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 Duplication Detector. Check out the FAQ for more information and technical details.

@@ -129,4 +127,4 @@ % endif -<%include file="/support/footer.mako" args="environ=environ"/> +<%include file="/support/footer.mako" args="environ=environ, cookies=cookies"/> diff --git a/pages/debug.mako b/pages/debug.mako index f6a11a9..25dafca 100644 --- a/pages/debug.mako +++ b/pages/debug.mako @@ -1,4 +1,4 @@ -<%include file="/support/header.mako" args="environ=environ, title='Debug'"/> +<%include file="/support/header.mako" args="environ=environ, cookies=cookies, title='Debug'"/> -<%include file="/support/footer.mako" args="environ=environ"/> +<%include file="/support/footer.mako" args="environ=environ, cookies=cookies"/> diff --git a/pages/earwigbot.mako b/pages/earwigbot.mako index ded421a..da36883 100644 --- a/pages/earwigbot.mako +++ b/pages/earwigbot.mako @@ -48,8 +48,8 @@ since ${since} (${uptime} uptime) on ${host} % endif \ -<%include file="/support/header.mako" args="environ=environ, title='EarwigBot Status'"/> +<%include file="/support/header.mako" args="environ=environ, cookies=cookies, title='EarwigBot Status'"/>

EarwigBot Status

EarwigBot ${get_status()}.

Additional information: status.toolserver.org

-<%include file="/support/footer.mako" args="environ=environ"/> +<%include file="/support/footer.mako" args="environ=environ, cookies=cookies"/> diff --git a/pages/index.mako b/pages/index.mako index e401d4a..d518710 100644 --- a/pages/index.mako +++ b/pages/index.mako @@ -16,7 +16,7 @@ pretty = path.split(root)[0] %>\ <%def name="get_tools()"><% return tools %>\ -<%include file="/support/header.mako" args="environ=environ, title='Home', slug='home'"/> +<%include file="/support/header.mako" args="environ=environ, cookies=cookies, title='Home', slug='home'"/>

My Tools

% for tool in tools: % if tool != "DIVIDER": @@ -29,4 +29,4 @@ % endif % endif % endfor -<%include file="/support/footer.mako" args="environ=environ"/> +<%include file="/support/footer.mako" args="environ=environ, cookies=cookies"/> diff --git a/pages/settings.mako b/pages/settings.mako index ad718a3..23e33c5 100644 --- a/pages/settings.mako +++ b/pages/settings.mako @@ -1,7 +1,7 @@ -<%include file="/support/header.mako" args="environ=environ, title='Settings'"/>\ +<%include file="/support/header.mako" args="environ=environ, cookies=cookies, title='Settings'"/>\ <%namespace module="toolserver.settings" import="main"/>\ <%! from json import dumps, loads %> -<% bot, cookies, status, langs, projects = main(environ, headers) %> +<% bot, status, langs, projects = main(environ, headers, cookies) %> % if status:

${status}

@@ -86,4 +86,4 @@ % else:

No cookies!

% endif -<%include file="/support/footer.mako" args="environ=environ"/> +<%include file="/support/footer.mako" args="environ=environ, cookies=cookies"/> diff --git a/pages/support/footer.mako b/pages/support/footer.mako index e93f37f..5add092 100644 --- a/pages/support/footer.mako +++ b/pages/support/footer.mako @@ -1,4 +1,4 @@ -<%page args="environ"/>\ +<%page args="environ, cookies"/>\ <%! from os import path %>\ @@ -18,7 +18,9 @@

Copyright © 2009–2012 Ben Kurtovic • \ Contact • \ View Source • \ - Background • \ + % if ("EarwigBackground" in cookies and cookies["EarwigBackground"].value in ["potd", "list"]) or "EarwigBackground" not in cookies: + Background • \ + % endif Valid XHTML 1.0 Strict

@@ -29,4 +31,4 @@
- \ No newline at end of file + diff --git a/pages/support/header.mako b/pages/support/header.mako index 263dc2d..cb94f53 100644 --- a/pages/support/header.mako +++ b/pages/support/header.mako @@ -1,4 +1,4 @@ -<%page args="environ, title, slug=None, add_css=(), add_js=()"/>\ +<%page args="environ, cookies, title, slug=None, add_css=(), add_js=()"/>\ <%namespace name="index" file="/index.mako" import="get_tools"/>\ <%! from os import path @@ -28,7 +28,17 @@ % endfor - + % if "EarwigBackground" in cookies: + % if cookies["EarwigBackground"].value == "list": + + % elif cookies["EarwigBackground"].value == "plain": + + % else + + % endif + % else + + % endif