From 2b33822de9d4f1ffba59cd29c3da9928a18d4494 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 18 Jul 2019 02:36:56 -0700 Subject: [PATCH] storage: Stop using django-pipeline. Signed-off-by: Anders Kaseorg --- docs/subsystems/front-end-build-process.md | 6 ++-- docs/subsystems/html_css.md | 3 +- zerver/lib/storage.py | 6 ++-- zerver/tests/test_templates.py | 3 -- zerver/views/home.py | 1 - zproject/dev_urls.py | 2 +- zproject/settings.py | 37 +++------------------- 7 files changed, 10 insertions(+), 48 deletions(-) diff --git a/docs/subsystems/front-end-build-process.md b/docs/subsystems/front-end-build-process.md index 66cc58aa0f..10b0a90066 100644 --- a/docs/subsystems/front-end-build-process.md +++ b/docs/subsystems/front-end-build-process.md @@ -74,13 +74,11 @@ needs to be accessible from one of the entry points defined in the compiled JS and CSS. If you want to test minified files in development, look for the -`PIPELINE_ENABLED =` line in `zproject/settings.py` and set it to `True` --- or just set `DEBUG = False`. +`DEBUG =` line in `zproject/settings.py` and set it to `False`. ## How it works in production -You can learn a lot from reading about django-pipeline, but a few -useful notes are: +A few useful notes are: * Zulip installs static assets in production in `/home/zulip/prod-static`. When a new version is deployed, before the server is restarted, files are copied into that directory. diff --git a/docs/subsystems/html_css.md b/docs/subsystems/html_css.md index 15e2231821..fbd417555f 100644 --- a/docs/subsystems/html_css.md +++ b/docs/subsystems/html_css.md @@ -8,8 +8,7 @@ main third-party CSS library. Zulip currently does not use any CSS preprocessors, and is organized into several files. For most pages, the CSS is combined into a single -CSS file by the [static asset pipeline](../subsystems/front-end-build-process.html), -controlled by the `PIPELINE_CSS` code in `zproject/settings.py`. +CSS file by the [static asset pipeline](../subsystems/front-end-build-process.html). The CSS files are: diff --git a/zerver/lib/storage.py b/zerver/lib/storage.py index e7f45a168d..41f5a023b0 100644 --- a/zerver/lib/storage.py +++ b/zerver/lib/storage.py @@ -5,9 +5,8 @@ from typing import Optional from django.conf import settings from django.contrib.staticfiles.storage import ManifestStaticFilesStorage -from pipeline.storage import PipelineMixin -if not settings.PIPELINE_ENABLED: +if settings.DEBUG: from django.contrib.staticfiles.finders import find def static_path(path: str) -> str: @@ -44,8 +43,7 @@ class IgnoreBundlesManifestStaticFilesStorage(ManifestStaticFilesStorage): return name return super().hashed_name(name, content, filename) -class ZulipStorage(PipelineMixin, - IgnoreBundlesManifestStaticFilesStorage): +class ZulipStorage(IgnoreBundlesManifestStaticFilesStorage): # This is a hack to use staticfiles.json from within the # deployment, rather than a directory under STATIC_ROOT. By doing # so, we can use a different copy of staticfiles.json for each diff --git a/zerver/tests/test_templates.py b/zerver/tests/test_templates.py index 4968f91296..24eaa9730e 100644 --- a/zerver/tests/test_templates.py +++ b/zerver/tests/test_templates.py @@ -81,9 +81,6 @@ class TemplateTestCase(ZulipTestCase): 'zerver/emails/compiled/password_reset.html', 'corporate/zephyr.html', 'corporate/zephyr-mirror.html', - 'pipeline/css.jinja', - 'pipeline/inline_js.jinja', - 'pipeline/js.jinja', 'zilencer/enterprise_tos_accept_body.txt', 'zerver/zulipchat_migration_tos.html', 'zilencer/enterprise_tos_accept_body.txt', diff --git a/zerver/views/home.py b/zerver/views/home.py index 356c2869f2..d4c3c2ffa5 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -288,7 +288,6 @@ def home_real(request: HttpRequest) -> HttpResponse: 'avatar_url': avatar_url(user_profile), 'show_debug': settings.DEBUG and ('show_debug' in request.GET), - 'pipeline': settings.PIPELINE_ENABLED, 'search_pills_enabled': settings.SEARCH_PILLS_ENABLED, 'show_invites': show_invites, 'show_add_streams': show_add_streams, diff --git a/zproject/dev_urls.py b/zproject/dev_urls.py index bd2139e4a6..92a2329a64 100644 --- a/zproject/dev_urls.py +++ b/zproject/dev_urls.py @@ -11,7 +11,7 @@ import zerver.views.development.integrations # These URLs are available only in the development environment -use_prod_static = getattr(settings, 'PIPELINE_ENABLED', False) +use_prod_static = not settings.DEBUG urls = [ # Serve useful development environment resources (docs, coverage reports, etc.) diff --git a/zproject/settings.py b/zproject/settings.py index e8026eafd4..27307a0756 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -576,7 +576,6 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.staticfiles', 'confirmation', - 'pipeline', 'webpack_loader', 'zerver', 'social_django', @@ -861,7 +860,7 @@ if CAMO_URI != '': STATIC_URL = '/static/' -# ZulipStorage is a modified version of PipelineCachedStorage, +# ZulipStorage is a modified version of ManifestStaticFilesStorage, # and, like that class, it inserts a file hash into filenames # to prevent the browser from using stale files from cache. # @@ -869,16 +868,8 @@ STATIC_URL = '/static/' # STATIC_ROOT even for dev servers. So we only use # ZulipStorage when not DEBUG. -# This is the default behavior from Pipeline, but we set it -# here so that urls.py can read it. -PIPELINE_ENABLED = not DEBUG - -if PIPELINE_ENABLED: +if not DEBUG: STATICFILES_STORAGE = 'zerver.lib.storage.ZulipStorage' - STATICFILES_FINDERS = ( - 'django.contrib.staticfiles.finders.FileSystemFinder', - 'pipeline.finders.PipelineFinder', - ) if PRODUCTION: STATIC_ROOT = '/home/zulip/prod-static' else: @@ -893,24 +884,7 @@ FILE_UPLOAD_MAX_MEMORY_SIZE = 0 STATICFILES_DIRS = ['static/'] -# To use minified files in dev, set PIPELINE_ENABLED = True. For the full -# cache-busting behavior, you must also set DEBUG = False. -# -# You will need to run update-prod-static after changing -# static files. -# -# Useful reading on how this works is in -# https://zulip.readthedocs.io/en/latest/subsystems/front-end-build-process.html - -PIPELINE = { - 'PIPELINE_ENABLED': PIPELINE_ENABLED, - 'CSS_COMPRESSOR': 'pipeline.compressors.yui.YUICompressor', - 'YUI_BINARY': '/usr/bin/env yui-compressor', - 'STYLESHEETS': {}, - 'JAVASCRIPT': {}, -} - -if not PIPELINE_ENABLED: +if DEBUG: WEBPACK_STATS_FILE = os.path.join('var', 'webpack-stats-dev.json') else: WEBPACK_STATS_FILE = 'webpack-stats-production.json' @@ -942,7 +916,6 @@ base_template_engine_settings = { 'extensions': [ 'jinja2.ext.i18n', 'jinja2.ext.autoescape', - 'pipeline.jinja2.PipelineExtension', 'webpack_loader.contrib.jinja2ext.WebpackExtension', ], 'context_processors': [ @@ -961,9 +934,7 @@ default_template_engine_settings.update({ # The webhook integration templates os.path.join(DEPLOY_ROOT, 'zerver', 'webhooks'), # The python-zulip-api:zulip_bots package templates - os.path.join( - STATIC_ROOT if PIPELINE_ENABLED else 'static', 'generated', 'bots' - ), + os.path.join('static' if DEBUG else STATIC_ROOT, 'generated', 'bots'), ], 'APP_DIRS': True, })