Permalink
Browse files

To be continued in Kunming.

  • Loading branch information...
1 parent 44ada49 commit 647e5de80c0418a4c97202494aa285b720767ddb @livid committed Nov 28, 2010
View
@@ -18,7 +18,10 @@ handlers:
upload: static/img/apple-touch-icon.png
- url: /static
- static_dir: static
+ static_dir: static
+
+- url: /css/.*
+ script: css.py
- url: /settings
script: member.py
View
@@ -1438,10 +1438,16 @@ def get(self):
template_values['site_meta'] = site.meta
else:
template_values['site_meta'] = ''
+ if site.theme is not None:
+ template_values['site_theme'] = site.theme
+ else:
+ template_values['site_theme'] = 'default'
s = GetLanguageSelect(site.l10n)
template_values['s'] = s
template_values['member'] = member
template_values['system_version'] = SYSTEM_VERSION
+ themes = os.listdir(os.path.join(os.path.dirname(__file__), 'tpl', 'themes'))
+ template_values['themes'] = themes
path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'backstage_site.html')
output = template.render(path, template_values)
self.response.out.write(output)
@@ -1603,7 +1609,18 @@ def post(self):
# Verification: meta
site_meta = self.request.get('meta')
template_values['site_meta'] = site_meta
+ # Verification: theme
+ site_theme = self.request.get('theme')
+ themes = os.listdir(os.path.join(os.path.dirname(__file__), 'tpl', 'themes'))
+ template_values['themes'] = themes
+ if site_theme in themes:
+ template_values['site_theme'] = site_theme
+ else:
+ site_theme = 'default'
+ template_values['site_theme'] = site_theme
+
template_values['errors'] = errors
+
if errors == 0:
site.title = site_title
site.slogan = site_slogan
@@ -1618,6 +1635,7 @@ def post(self):
site.topic_create_level = site_topic_create_level
site.topic_reply_level = site_topic_reply_level
site.meta = site_meta
+ site.theme = site_theme
site.put()
memcache.delete('index_categories')
template_values['message'] = l10n.site_settings_updated;
View
42 css.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# coding=utf-8
+
+import os
+import datetime
+
+from google.appengine.ext import webapp
+from google.appengine.api import memcache
+from google.appengine.ext import db
+from google.appengine.ext.webapp import util
+from google.appengine.ext.webapp import template
+
+from v2ex.babel import SYSTEM_VERSION
+
+template.register_template_library('v2ex.templatetags.filters')
+
+class CSSHandler(webapp.RequestHandler):
+ def get(self, theme):
+ template_values = {}
+ themes = os.listdir(os.path.join(os.path.dirname(__file__), 'tpl', 'themes'))
+ if theme in themes:
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'themes', theme, 'style.css')
+ else:
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'themes', 'default', 'style.css')
+ output = template.render(path, template_values)
+ expires_date = datetime.datetime.utcnow() + datetime.timedelta(days=7)
+ expires_str = expires_date.strftime("%d %b %Y %H:%M:%S GMT")
+ self.response.headers.add_header("Expires", expires_str)
+ self.response.headers['Cache-Control'] = 'max-age=120, must-revalidate'
+ self.response.headers['Content-type'] = 'text/css;charset=UTF-8'
+ self.response.out.write(output)
+
+def main():
+ application = webapp.WSGIApplication([
+ ('/css/([a-zA-Z0-9]+).css', CSSHandler)
+ ],
+ debug=True)
+ util.run_wsgi_app(application)
+
+
+if __name__ == '__main__':
+ main()
View
0 docs/zh-Hans/Installation.md 100644 → 100755
No changes.
View
@@ -41,6 +41,7 @@ def get(self):
path = os.path.join(os.path.dirname(__file__), 'tpl', 'feed', 'index.xml')
output = template.render(path, template_values)
memcache.set('feed_index', output, 600)
+ self.response.headers['Content-type'] = 'application/xml;charset=UTF-8'
self.response.out.write(output)
def main():
View
0 main.py 100755 → 100644
No changes.
View
0 mapreduce/lib/__init__.py 100755 → 100644
No changes.
View
No changes.
View
0 mapreduce/lib/graphy/__init__.py 100755 → 100644
No changes.
View
No changes.
No changes.
No changes.
No changes.
View
0 mapreduce/lib/graphy/bar_chart.py 100755 → 100644
No changes.
View
0 mapreduce/lib/graphy/common.py 100755 → 100644
No changes.
View
No changes.
View
No changes.
View
0 mapreduce/lib/graphy/pie_chart.py 100755 → 100644
No changes.
View
0 mapreduce/lib/graphy/util.py 100755 → 100644
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 mapreduce/model.py 100644 → 100755
No changes.
View
0 mapreduce/operation/counters.py 100755 → 100644
No changes.
View
0 mapreduce/util.py 100644 → 100755
No changes.
@@ -97,6 +97,22 @@
</tr>
<tr>
<td width="100" align="right">
+ {{ l10n.site_theme }}
+ </td>
+ <td width="200" align="left">
+ <select name="theme">
+ {% for theme in themes %}
+ {% ifequal theme site_theme %}
+ <option value="{{ theme }}" selected="selected">{{ theme }}</option>
+ {% else %}
+ <option value="{{ theme }}">{{ theme }}</option>
+ {% endifequal %}
+ {% endfor %}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="100" align="right">
Analytics ID
</td>
<td width="200" align="left">
@@ -5,7 +5,7 @@
<meta content="True" name="HandheldFriendly" />
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0; name='viewport'" />
<title>{{ page_title|escape }}</title>
- <link rel="stylesheet" type="text/css" media="screen" href="/static/css/desktop/style.css?v={{ system_version }}" />
+ <link rel="stylesheet" type="text/css" media="screen" href="/css/{{ site.theme }}.css?v={{ system_version }}" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="alternate" type="application/atom+xml" href="/index.xml" />
{% if canonical %}<link rel="canonical" href="{{ canonical }}" />{% endif %}
Oops, something went wrong.

0 comments on commit 647e5de

Please sign in to comment.