You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/07/18 21:02:22 UTC
[15/28] git commit: [#7027] Cache /nf/tool_icon_css better
[#7027] Cache /nf/tool_icon_css better
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1b61d2a9
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1b61d2a9
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1b61d2a9
Branch: refs/heads/db/7523
Commit: 1b61d2a9b570566e046a969596f0f15668a65a93
Parents: 2b5d4b2
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Sat Jun 28 15:52:24 2014 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Jul 10 15:12:30 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/static.py | 6 +++---
Allura/allura/lib/app_globals.py | 4 ++++
Allura/allura/lib/utils.py | 3 ++-
Allura/allura/templates/jinja_master/master.html | 2 +-
Allura/development.ini | 3 +++
5 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/1b61d2a9/Allura/allura/controllers/static.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/static.py b/Allura/allura/controllers/static.py
index 60d77c1..313a877 100644
--- a/Allura/allura/controllers/static.py
+++ b/Allura/allura/controllers/static.py
@@ -43,10 +43,10 @@ class NewForgeController(object):
return html
@expose()
- def tool_icon_css(self):
+ def tool_icon_css(self, *args, **kw):
"""Serve stylesheet containing icon urls for every installed tool.
"""
css, md5 = g.tool_icon_css
- return utils.serve_file(StringIO(css), 'tool_icon_css', 'text/css',
- etag=md5)
+ return utils.serve_file(
+ StringIO(css), 'tool_icon_css', 'text/css', etag=md5)
http://git-wip-us.apache.org/repos/asf/allura/blob/1b61d2a9/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index f30cee5..0037744 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -602,6 +602,10 @@ class Globals(object):
def noreply(self):
return unicode(config.get('noreply', 'noreply@%s' % config['domain']))
+ @property
+ def build_key(self):
+ return config.get('build_key', '')
+
class Icon(object):
http://git-wip-us.apache.org/repos/asf/allura/blob/1b61d2a9/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 14c485d..ce1836f 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -509,7 +509,8 @@ def take_while_true(source):
x = source()
-def serve_file(fp, filename, content_type, last_modified=None, cache_expires=None, size=None, embed=True, etag=None):
+def serve_file(fp, filename, content_type, last_modified=None,
+ cache_expires=None, size=None, embed=True, etag=None):
'''Sets the response headers and serves as a wsgi iter'''
if not etag and filename and last_modified:
etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
http://git-wip-us.apache.org/repos/asf/allura/blob/1b61d2a9/Allura/allura/templates/jinja_master/master.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/master.html b/Allura/allura/templates/jinja_master/master.html
index 0c4d188..dc21fd8 100644
--- a/Allura/allura/templates/jinja_master/master.html
+++ b/Allura/allura/templates/jinja_master/master.html
@@ -29,7 +29,7 @@
{% do g.register_forge_js('js/pb.transformie.min.js') %}
{% do g.register_forge_js('js/allura-base.js') %}
{% do g.register_forge_css('css/forge/hilite.css') %}
-{% do g.register_css('/nf/tool_icon_css', compress=False) %}
+{% do g.register_css('/nf/tool_icon_css?' + g.build_key, compress=False) %}
{% do g.theme.require() %}
{% do g.resource_manager.register_widgets(c) %}
{# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ #}
http://git-wip-us.apache.org/repos/asf/allura/blob/1b61d2a9/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index c26f459..8fdc222 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -134,6 +134,9 @@ static.url_base = /nf/%(build_key)s/_static_/
# static.url_base = ://a.fsdn.com/allura/nf/%(build_key)s/_static_/
# cdn.url_base = //a.fsdn.com/allura
+# default expires header for static resources (1 year in future)
+file_expires_header_secs = 31536000
+
ew.extra_headers = [ ('Access-Control-Allow-Origin', '*') ]
# SCM settings for local development