zproject: Remove unused template tags minified_js, static.

`minified_js` was obsoleted by the Webpack migration and `static` has
never been used.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-06-28 21:45:21 -07:00 committed by Tim Abbott
parent fc3305b623
commit 0334be7053
4 changed files with 0 additions and 54 deletions

View File

@ -160,11 +160,6 @@ This is used to deploy essentially all configuration in production.
* `zproject/jinja2/__init__.py` Jinja2 environment.
* `zproject/jinja2/backends.py` Jinja2 backend.
* `zproject/jinja2/compressors.py` Jinja2 compatible functions of
Django-Pipeline.
-----------------------------------------------------------------------
### Translation files

View File

@ -1,29 +0,0 @@
from typing import Any, Dict
from django.conf import settings
from django.contrib.staticfiles.storage import staticfiles_storage
from django.template import Library, Node
register = Library()
class MinifiedJSNode(Node):
def __init__(self, sourcefile: str, csp_nonce: str) -> None:
self.sourcefile = sourcefile
self.csp_nonce = csp_nonce
def render(self, context: Dict[str, Any]) -> str:
if settings.DEBUG:
source_files = settings.JS_SPECS[self.sourcefile]
normal_source = source_files['source_filenames']
minified_source = source_files.get('minifed_source_filenames', [])
# Minified source files (most likely libraries) should be loaded
# first to prevent any dependency errors.
scripts = minified_source + normal_source
else:
scripts = [settings.JS_SPECS[self.sourcefile]['output_filename']]
script_urls = [staticfiles_storage.url(script) for script in scripts]
script_tags = ['<script nonce="%s" src="%s"></script>' % (self.csp_nonce, url)
for url in script_urls]
return '\n'.join(script_tags)

View File

@ -1,7 +1,6 @@
from typing import Any
from django.contrib.staticfiles.storage import staticfiles_storage
from django.template.defaultfilters import slugify, pluralize
from django.urls import reverse
from django.utils import translation
@ -9,17 +8,14 @@ from django.utils.timesince import timesince
from jinja2 import Environment
from two_factor.templatetags.two_factor import device_action
from .compressors import minified_js
from zerver.templatetags.app_filters import display_list, render_markdown_path
def environment(**options: Any) -> Environment:
env = Environment(**options)
env.globals.update({
'static': staticfiles_storage.url,
'url': reverse,
'render_markdown_path': render_markdown_path,
'minified_js': minified_js,
})
env.install_gettext_translations(translation, True)

View File

@ -1,16 +0,0 @@
"""
`minified_js` is taken from `zerver.templatetags.minified_js.py`
"""
from django.conf import settings
from django.template import TemplateSyntaxError
from zerver.templatetags.minified_js import MinifiedJSNode
def minified_js(sourcefile: str, csp_nonce: str) -> str:
if sourcefile not in settings.JS_SPECS:
raise TemplateSyntaxError(
"Invalid argument: no JS file %s".format(sourcefile))
return MinifiedJSNode(sourcefile, csp_nonce).render({})