Issue #56, Remove the MAIN_ENABLE_SCROLL_JS and associated code, remove remaining web theme selection code
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
"""Configuration options for the main app"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from smart_settings.api import register_setting, register_settings
|
||||
|
||||
register_settings(
|
||||
namespace=u'main',
|
||||
module=u'main.settings',
|
||||
settings=[
|
||||
{'name': u'ENABLE_SCROLL_JS', 'global_name': u'MAIN_ENABLE_SCROLL_JS', 'default': True, 'hidden': True},
|
||||
]
|
||||
)
|
||||
@@ -9,10 +9,8 @@
|
||||
{% load registration_tags %}
|
||||
{% load search_tags %}
|
||||
{% load settings %}
|
||||
{% load theme_tags %}
|
||||
{% load variable_tags %}
|
||||
|
||||
{% get_theme as web_theme %}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
@@ -391,12 +389,6 @@
|
||||
|
||||
{% compress js %}
|
||||
<script type="text/javascript" charset="utf-8" src="{% static 'packages/jquery-2.1.1.min.js' %}"></script>
|
||||
|
||||
{% if enable_scroll_js %}
|
||||
<script type="text/javascript" charset="utf-8" src="{% static 'web_theme_media/javascripts/jquery.scrollTo.js' %}"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="{% static 'web_theme_media/javascripts/jquery.localscroll.js' %}"></script>
|
||||
{% endif %}
|
||||
|
||||
<script type="text/javascript" src="{% static 'packages/jquery.scrollview.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'packages/jquery_lazyload-master/jquery.lazyload.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'packages/jquery.scrollstop.js' %}"></script>
|
||||
|
||||
@@ -11,31 +11,6 @@ from main import settings as web_theme_settings
|
||||
register = Library()
|
||||
|
||||
|
||||
class GetThemeNode(Node):
|
||||
def __init__(self, var_name, *args):
|
||||
self.var_name = var_name
|
||||
|
||||
def render(self, context):
|
||||
context['enable_scroll_js'] = web_theme_settings.ENABLE_SCROLL_JS
|
||||
return ''
|
||||
|
||||
|
||||
@register.tag
|
||||
def get_theme(parser, token):
|
||||
try:
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, arg = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise TemplateSyntaxError('%r tag requires arguments' % token.contents.split()[0])
|
||||
|
||||
m = re.search(r'as (\w+)', arg)
|
||||
if not m:
|
||||
raise TemplateSyntaxError('%r tag had invalid arguments' % tag_name)
|
||||
var_name = m.groups()
|
||||
|
||||
return GetThemeNode(var_name)
|
||||
|
||||
|
||||
class LoginRedirectNode(Node):
|
||||
def render(self, context):
|
||||
context['LOGIN_REDIRECT_URL'] = getattr(settings, 'LOGIN_REDIRECT_URL', '/')
|
||||
@@ -47,33 +22,6 @@ def get_login_redirect_url(parser, token):
|
||||
return LoginRedirectNode()
|
||||
|
||||
|
||||
class SettingsNode(Node):
|
||||
def __init__(self, format_string, var_name):
|
||||
self.format_string = format_string
|
||||
self.var_name = var_name
|
||||
|
||||
def render(self, context):
|
||||
context[self.var_name] = getattr(web_theme_settings, self.format_string, '')
|
||||
return ''
|
||||
|
||||
|
||||
@register.tag
|
||||
def get_web_theme_setting(parser, token):
|
||||
# This version uses a regular expression to parse tag contents.
|
||||
try:
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, arg = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise TemplateSyntaxError('%r tag requires arguments' % token.contents.split()[0])
|
||||
m = re.search(r'(.*?) as (\w+)', arg)
|
||||
if not m:
|
||||
raise TemplateSyntaxError('%r tag had invalid arguments' % tag_name)
|
||||
format_string, var_name = m.groups()
|
||||
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
|
||||
raise TemplateSyntaxError('%r tag\'s argument should be in quotes' % tag_name)
|
||||
return SettingsNode(format_string[1:-1], var_name)
|
||||
|
||||
|
||||
@register.filter
|
||||
def highlight(text, word):
|
||||
return mark_safe(unicode(text).replace(word, mark_safe('<mark>%s</mark>' % word)))
|
||||
|
||||
Reference in New Issue
Block a user