From 3de23628b7eab40b62447cd9ab6217a88c3a7afe Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Fri, 3 Aug 2012 03:07:40 -0400 Subject: [PATCH] Switching a bit of code from client-side to server-side. - All POTD logic is now in Python instead of JS. - Removed EarwigBackgroundCache cookie (now stored in a new `background` table in the database). - Added EarwigScreenCache cookie - Increase cookie life from a year to three. --- pages/settings.mako | 2 +- pages/support/footer.mako | 3 +- pages/support/header.mako | 6 +- schema.sql | 15 ++++ static/js/copyvios.js | 2 +- static/js/potd.js | 183 ++++------------------------------------------ toolserver/background.py | 115 +++++++++++++++++++++++++++++ toolserver/misc.py | 18 ++++- toolserver/settings.py | 6 +- 9 files changed, 168 insertions(+), 182 deletions(-) create mode 100644 toolserver/background.py diff --git a/pages/settings.mako b/pages/settings.mako index b9fd47b..2834838 100644 --- a/pages/settings.mako +++ b/pages/settings.mako @@ -69,7 +69,7 @@

Cookies

% if cookies: - <% cookie_order = ["EarwigDefaultProject", "EarwigDefaultLang", "EarwigBackground", "EarwigCVShowDetails", "EarwigBackgroundCache"] %>\ + <% cookie_order = ["EarwigDefaultProject", "EarwigDefaultLang", "EarwigBackground", "EarwigScreenCache", "EarwigCVShowDetails"] %>\ % for key in [key for key in cookie_order if key in cookies]: <% cookie = cookies[key] %>\ diff --git a/pages/support/footer.mako b/pages/support/footer.mako index 2caa50c..a8844f2 100644 --- a/pages/support/footer.mako +++ b/pages/support/footer.mako @@ -1,4 +1,5 @@ <%page args="environ, cookies"/>\ +<%namespace module="toolserver.background" import="get_desc_url"/>\ <%! from os import path %>\ @@ -19,7 +20,7 @@ Contact • \ View Source • \ % if ("EarwigBackground" in cookies and cookies["EarwigBackground"].value in ["potd", "list"]) or "EarwigBackground" not in cookies: - Background • \ + Background • \ % endif Valid XHTML 1.0 Strict

diff --git a/pages/support/header.mako b/pages/support/header.mako index dd981e5..846e72e 100644 --- a/pages/support/header.mako +++ b/pages/support/header.mako @@ -1,4 +1,5 @@ <%page args="environ, cookies, title, slug=None, add_css=(), add_js=()"/>\ +<%namespace module="toolserver.background" import="set_background"/>\ <%namespace name="index" file="/index.mako" import="get_tools"/>\ <%! from os import path @@ -31,10 +32,9 @@ <% selected = cookies["EarwigBackground"].value if "EarwigBackground" in cookies else "list" %>\ % if selected in ["plain-brown", "plain-blue"]: - % elif selected == "potd": - % else: - + <% bg_url = set_background(cookies, selected) %>\ + % endif