Upgrade to Django-Pipeline==1.6.8.

This commit is contained in:
Umair Khan
2016-07-04 12:33:57 +05:00
committed by Tim Abbott
parent 2d243c0703
commit 043ae8ad65
13 changed files with 74 additions and 81 deletions

View File

@@ -139,3 +139,6 @@ uritemplate==0.6
zope.interface==4.1.2 zope.interface==4.1.2
-r emailmirror.txt -r emailmirror.txt
# Django extension for static asset pipeline
django-pipeline==1.6.8

View File

@@ -2,9 +2,6 @@
enum34==1.0.4 enum34==1.0.4
# Django extension for static asset pipeline
django-pipeline==1.2.2
# Used for Hesiod lookups, etc. # Used for Hesiod lookups, etc.
pydns==2.3.6 pydns==2.3.6

View File

@@ -3,9 +3,6 @@
# Used for Hesiod lookups, etc. # Used for Hesiod lookups, etc.
py3dns==3.1.0 py3dns==3.1.0
# Django extension for static asset pipeline
django-pipeline==1.6.8
# Needed for LDAP integration # Needed for LDAP integration
pyldap==2.4.25.1 pyldap==2.4.25.1

View File

@@ -10,7 +10,7 @@
{% block customhead %} {% block customhead %}
{{ super() }} {{ super() }}
{{ minified_js('activity')|safe }} {{ minified_js('activity')|safe }}
{{ compressed_css('activity')|safe }} {% stylesheet 'activity' %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}

View File

@@ -23,7 +23,7 @@
{% endif %} {% endif %}
{# We need to import jQuery before Bootstrap #} {# We need to import jQuery before Bootstrap #}
{{ compressed_css('common')|safe }} {% stylesheet 'common' %}
{% block page_params %} {% block page_params %}
{# blueslip needs page_params.debug_mode. Set it to false by default. #} {# blueslip needs page_params.debug_mode. Set it to false by default. #}
<script type="text/javascript"> <script type="text/javascript">

View File

@@ -31,9 +31,9 @@ var page_params = {{ page_params }};
{% if nofontface %} {% if nofontface %}
{# We can't use @font-face on qtwebkit, so use differently minified CSS #} {# We can't use @font-face on qtwebkit, so use differently minified CSS #}
{{ compressed_css('app-fontcompat')|safe }} {% stylesheet 'app-fontcompat' %}
{% else %} {% else %}
{{ compressed_css('app')|safe }} {% stylesheet 'app' %}
{% endif %} {% endif %}
{{ minified_js('app')|safe }} {{ minified_js('app')|safe }}

View File

@@ -7,7 +7,7 @@
#} #}
{% block customhead %} {% block customhead %}
{{ compressed_css('portico')|safe }} {% stylesheet 'portico' %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}

View File

@@ -1026,7 +1026,7 @@ def home(request):
'avatar_url': avatar_url(user_profile), 'avatar_url': avatar_url(user_profile),
'show_debug': 'show_debug':
settings.DEBUG and ('show_debug' in request.GET), settings.DEBUG and ('show_debug' in request.GET),
'pipeline': settings.PIPELINE, 'pipeline': settings.PIPELINE_ENABLED,
'show_invites': show_invites, 'show_invites': show_invites,
'is_admin': user_profile.is_realm_admin, 'is_admin': user_profile.is_realm_admin,
'show_webathena': user_profile.realm.domain == "mit.edu", 'show_webathena': user_profile.realm.domain == "mit.edu",

View File

@@ -4,7 +4,7 @@ import os.path
# These URLs are available only in the development environment # These URLs are available only in the development environment
use_prod_static = getattr(settings, 'PIPELINE', False) use_prod_static = getattr(settings, 'PIPELINE_ENABLED', False)
static_root = os.path.join(settings.DEPLOY_ROOT, 'prod-static/serve' if use_prod_static else 'static') static_root = os.path.join(settings.DEPLOY_ROOT, 'prod-static/serve' if use_prod_static else 'static')
urls = [url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': static_root})] urls = [url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': static_root})]

View File

@@ -8,7 +8,7 @@ from django.utils import translation
from django.http import HttpResponse from django.http import HttpResponse
from jinja2 import Environment from jinja2 import Environment
from .compressors import compressed_css, minified_js from .compressors import minified_js
from zerver.templatetags.app_filters import display_list from zerver.templatetags.app_filters import display_list
@@ -22,7 +22,6 @@ def environment(**options):
env.globals.update({ env.globals.update({
'static': staticfiles_storage.url, 'static': staticfiles_storage.url,
'url': reverse, 'url': reverse,
'compressed_css': compressed_css,
'minified_js': minified_js, 'minified_js': minified_js,
}) })

View File

@@ -5,15 +5,10 @@ from __future__ import absolute_import # Python 2 only
from django.conf import settings from django.conf import settings
from django.template import TemplateSyntaxError from django.template import TemplateSyntaxError
from pipeline.templatetags.compressed import CompressedCSSNode
from zerver.templatetags.minified_js import MinifiedJSNode from zerver.templatetags.minified_js import MinifiedJSNode
def compressed_css(package_name):
return CompressedCSSNode(package_name).render({package_name: package_name})
def minified_js(sourcefile): def minified_js(sourcefile):
if sourcefile not in settings.JS_SPECS: if sourcefile not in settings.JS_SPECS:
raise TemplateSyntaxError( raise TemplateSyntaxError(

View File

@@ -236,13 +236,14 @@ TEMPLATES = [
'DIRS': [ 'DIRS': [
os.path.join(DEPLOY_ROOT, 'templates'), os.path.join(DEPLOY_ROOT, 'templates'),
], ],
'APP_DIRS': False, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'debug': DEBUG, 'debug': DEBUG,
'environment': 'zproject.jinja2.environment', 'environment': 'zproject.jinja2.environment',
'extensions': [ 'extensions': [
'jinja2.ext.i18n', 'jinja2.ext.i18n',
'jinja2.ext.autoescape', 'jinja2.ext.autoescape',
'pipeline.jinja2.PipelineExtension',
], ],
'context_processors': [ 'context_processors': [
'zerver.context_processors.add_settings', 'zerver.context_processors.add_settings',
@@ -531,14 +532,15 @@ STATIC_URL = '/static/'
# This is the default behavior from Pipeline, but we set it # This is the default behavior from Pipeline, but we set it
# here so that urls.py can read it. # here so that urls.py can read it.
PIPELINE = not DEBUG PIPELINE_ENABLED = not DEBUG
if DEBUG: if DEBUG:
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage' STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
) )
if PIPELINE: if PIPELINE_ENABLED:
STATIC_ROOT = os.path.abspath('prod-static/serve') STATIC_ROOT = os.path.abspath('prod-static/serve')
else: else:
STATIC_ROOT = os.path.abspath('static/') STATIC_ROOT = os.path.abspath('static/')
@@ -558,61 +560,67 @@ FILE_UPLOAD_MAX_MEMORY_SIZE = 0
STATICFILES_DIRS = ['static/'] STATICFILES_DIRS = ['static/']
STATIC_HEADER_FILE = 'zerver/static_header.txt' STATIC_HEADER_FILE = 'zerver/static_header.txt'
# To use minified files in dev, set PIPELINE = True. For the full # To use minified files in dev, set PIPELINE_ENABLED = True. For the full
# cache-busting behavior, you must also set DEBUG = False. # cache-busting behavior, you must also set DEBUG = False.
# #
# You will need to run update-prod-static after changing # You will need to run update-prod-static after changing
# static files. # static files.
PIPELINE_CSS = { PIPELINE = {
'activity': { 'PIPELINE_ENABLED': PIPELINE_ENABLED,
'source_filenames': ('styles/activity.css',), 'CSS_COMPRESSOR': 'pipeline.compressors.yui.YUICompressor',
'output_filename': 'min/activity.css' 'YUI_BINARY': '/usr/bin/env yui-compressor',
}, 'STYLESHEETS': {
'portico': { 'activity': {
'source_filenames': ( 'source_filenames': ('styles/activity.css',),
'third/zocial/zocial.css', 'output_filename': 'min/activity.css'
'styles/portico.css', },
'styles/pygments.css', 'portico': {
'styles/thirdparty-fonts.css', 'source_filenames': (
'styles/fonts.css', 'third/zocial/zocial.css',
), 'styles/portico.css',
'output_filename': 'min/portico.css' 'styles/pygments.css',
}, 'styles/thirdparty-fonts.css',
# Two versions of the app CSS exist because of QTBUG-3467 'styles/fonts.css',
'app-fontcompat': { ),
'source_filenames': ( 'output_filename': 'min/portico.css'
'third/bootstrap-notify/css/bootstrap-notify.css', },
'third/spectrum/spectrum.css', # Two versions of the app CSS exist because of QTBUG-3467
'styles/zulip.css', 'app-fontcompat': {
'styles/settings.css', 'source_filenames': (
'styles/pygments.css', 'third/bootstrap-notify/css/bootstrap-notify.css',
'styles/thirdparty-fonts.css', 'third/spectrum/spectrum.css',
# We don't want fonts.css on QtWebKit, so its omitted here 'styles/zulip.css',
), 'styles/settings.css',
'output_filename': 'min/app-fontcompat.css' 'styles/pygments.css',
}, 'styles/thirdparty-fonts.css',
'app': { # We don't want fonts.css on QtWebKit, so its omitted here
'source_filenames': ( ),
'third/bootstrap-notify/css/bootstrap-notify.css', 'output_filename': 'min/app-fontcompat.css'
'third/spectrum/spectrum.css', },
'third/jquery-perfect-scrollbar/css/perfect-scrollbar.css', 'app': {
'styles/zulip.css', 'source_filenames': (
'styles/settings.css', 'third/bootstrap-notify/css/bootstrap-notify.css',
'styles/pygments.css', 'third/spectrum/spectrum.css',
'styles/thirdparty-fonts.css', 'third/jquery-perfect-scrollbar/css/perfect-scrollbar.css',
'styles/fonts.css', 'styles/zulip.css',
), 'styles/settings.css',
'output_filename': 'min/app.css' 'styles/pygments.css',
}, 'styles/thirdparty-fonts.css',
'common': { 'styles/fonts.css',
'source_filenames': ( ),
'third/bootstrap/css/bootstrap.css', 'output_filename': 'min/app.css'
'third/bootstrap/css/bootstrap-btn.css', },
'third/bootstrap/css/bootstrap-responsive.css', 'common': {
), 'source_filenames': (
'output_filename': 'min/common.css' 'third/bootstrap/css/bootstrap.css',
'third/bootstrap/css/bootstrap-btn.css',
'third/bootstrap/css/bootstrap-responsive.css',
),
'output_filename': 'min/common.css'
},
}, },
'JAVASCRIPT': {},
} }
JS_SPECS = { JS_SPECS = {
@@ -738,7 +746,7 @@ JS_SPECS = {
'js/referral.js', 'js/referral.js',
'js/custom_markdown.js', 'js/custom_markdown.js',
'js/bot_data.js', 'js/bot_data.js',
# JS bundled by webpack is also included here if PIPELINE setting is true # JS bundled by webpack is also included here if PIPELINE_ENABLED setting is true
], ],
'output_filename': 'min/app.js' 'output_filename': 'min/app.js'
}, },
@@ -755,18 +763,12 @@ JS_SPECS = {
}, },
} }
if PIPELINE: if PIPELINE_ENABLED:
# This is also done in test_settings.py, see comment there.. # This is also done in test_settings.py, see comment there..
JS_SPECS['app']['source_filenames'].append('js/bundle.js') JS_SPECS['app']['source_filenames'].append('js/bundle.js')
app_srcs = JS_SPECS['app']['source_filenames'] app_srcs = JS_SPECS['app']['source_filenames']
PIPELINE_JS = {} # Now handled in tools/minify-js
PIPELINE_JS_COMPRESSOR = None
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
PIPELINE_YUI_BINARY = '/usr/bin/env yui-compressor'
######################################################################## ########################################################################
# LOGGING SETTINGS # LOGGING SETTINGS
######################################################################## ########################################################################

View File

@@ -12,7 +12,7 @@ DATABASES["default"] = {"NAME": "zulip_test",
"OPTIONS": {"connection_factory": TimeTrackingConnection },} "OPTIONS": {"connection_factory": TimeTrackingConnection },}
# In theory this should just go in zproject/settings.py inside the `if # In theory this should just go in zproject/settings.py inside the `if
# PIPELINE` statement, but because zproject/settings.py is processed # PIPELINE_ENABLED` statement, but because zproject/settings.py is processed
# first, we have to add it here as a hack. # first, we have to add it here as a hack.
JS_SPECS['app']['source_filenames'].append('js/bundle.js') JS_SPECS['app']['source_filenames'].append('js/bundle.js')