diff --git a/pages/settings.mako b/pages/settings.mako index 84b9880..fbcd845 100644 --- a/pages/settings.mako +++ b/pages/settings.mako @@ -1,10 +1,66 @@ -<%include file="/support/header.mako" args="environ=environ, title='Settings'"/> +<%include file="/support/header.mako" args="environ=environ, title='Settings'"/>\ +<%namespace module="toolserver.misc" import="get_bot, parse_cookies"/>\ +<%namespace module="toolserver.sites" import="get_sites"/>\ +<% cookies = parse_cookies(environ) %> +<% langs, projects = get_sites(get_bot()) %>

Settings

This page contains some configurable options for this Toolserver site. Settings are saved as cookies. You can view and delete all cookies generated by this site at the bottom of this page.

Options

- + + + + + + + + + + + + +
Default site: + http:// + + . + + .org +
Background:

Cookies

+ % if cookies: + +
+ + + +
+ % else: +

No cookies!

+ % endif <%include file="/support/footer.mako" args="environ=environ"/> diff --git a/toolserver/copyvios/__init__.py b/toolserver/copyvios/__init__.py index 0992d6a..effecba 100644 --- a/toolserver/copyvios/__init__.py +++ b/toolserver/copyvios/__init__.py @@ -1,10 +1,8 @@ # -*- coding: utf-8 -*- -from earwigbot.bot import Bot - from .checker import get_results from .highlighter import highlight_delta -from ..misc import Query +from ..misc import get_bot, Query from ..sites import get_site, get_sites def main(context, environ): @@ -16,8 +14,8 @@ def main(context, environ): if query.project: query.project = query.project.lower() - bot = Bot(".earwigbot") - all_langs, all_projects = get_sites(bot) + bot = get_bot(context) + all_langs, all_projects = get_sites(context, bot) page = result = None if query.lang and query.project and query.title: site = get_site(bot, query, all_projects) diff --git a/toolserver/misc.py b/toolserver/misc.py index 8ed13e6..c546bd6 100644 --- a/toolserver/misc.py +++ b/toolserver/misc.py @@ -4,6 +4,7 @@ from Cookie import CookieError, SimpleCookie from os.path import expanduser from urlparse import parse_qs +from earwigbot.bot import Bot import oursql class Query(object): @@ -47,6 +48,9 @@ def urlstrip(context, url): url = url[:-1] return url +def get_bot(context): + return Bot(".earwigbot") + def parse_cookies(context, environ): try: return SimpleCookie(environ["HTTP_COOKIE"]) diff --git a/toolserver/sites.py b/toolserver/sites.py index e0260aa..bc496fc 100644 --- a/toolserver/sites.py +++ b/toolserver/sites.py @@ -27,7 +27,7 @@ def get_site(bot, query, all_projects): except (exceptions.APIError, exceptions.LoginError): return None -def get_sites(bot): +def get_sites(context, bot): max_staleness = 60 * 60 * 24 * 7 conn = open_sql_connection(bot, "globals") query1 = "SELECT update_time FROM updates WHERE update_service = ?"