Commit cac53cf1 by Calen Pennington

Switch the cms over to using django-pipeline

parent 28237273
...@@ -23,6 +23,12 @@ import sys ...@@ -23,6 +23,12 @@ import sys
import tempfile import tempfile
from path import path from path import path
############################ FEATURE CONFIGURATION #############################
MITX_FEATURES = {
'USE_DJANGO_PIPELINE': True,
}
############################# SET PATH INFORMATION ############################# ############################# SET PATH INFORMATION #############################
PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /mitx/cms PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /mitx/cms
COMMON_ROOT = PROJECT_ROOT.dirname() / "common" COMMON_ROOT = PROJECT_ROOT.dirname() / "common"
...@@ -43,7 +49,10 @@ sys.path.append(COMMON_ROOT / 'lib') ...@@ -43,7 +49,10 @@ sys.path.append(COMMON_ROOT / 'lib')
# This is where we stick our compiled template files. # This is where we stick our compiled template files.
MAKO_MODULE_DIR = tempfile.mkdtemp('mako') MAKO_MODULE_DIR = tempfile.mkdtemp('mako')
MAKO_TEMPLATES = {} MAKO_TEMPLATES = {}
MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates'] MAKO_TEMPLATES['main'] = [
PROJECT_ROOT / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates'
]
MITX_ROOT_URL = '' MITX_ROOT_URL = ''
...@@ -59,8 +68,8 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -59,8 +68,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
# List of finder classes that know how to find static files in # List of finder classes that know how to find static files in
# various locations. # various locations.
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 'staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'staticfiles.finders.AppDirectoriesFinder',
) )
# List of callables that know how to import templates from various sources. # List of callables that know how to import templates from various sources.
...@@ -132,14 +141,60 @@ USE_L10N = True ...@@ -132,14 +141,60 @@ USE_L10N = True
# Messages # Messages
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
############################### Pipeline #######################################
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS = {
'base-style': {
'source_filenames': ['sass/base-style.scss'],
'output_filename': 'css/base-style.css',
},
}
PIPELINE_ALWAYS_RECOMPILE = ['sass/base-style.scss']
PIPELINE_JS = {
}
PIPELINE_COMPILERS = [
'pipeline.compilers.sass.SASSCompiler',
'pipeline.compilers.coffee.CoffeeScriptCompiler',
]
PIPELINE_SASS_ARGUMENTS = '-t compressed -r {proj_dir}/static/sass/bourbon/lib/bourbon.rb'.format(proj_dir=PROJECT_ROOT)
PIPELINE_CSS_COMPRESSOR = None
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
STATICFILES_IGNORE_PATTERNS = (
"sass/*",
"coffee/*",
"*.py",
"*.pyc"
)
PIPELINE_YUI_BINARY = 'yui-compressor'
PIPELINE_SASS_BINARY = 'sass'
PIPELINE_COFFEE_SCRIPT_BINARY = 'coffee'
# Setting that will only affect the MITx version of django-pipeline until our changes are merged upstream
PIPELINE_COMPILE_INPLACE = True
############################ APPS ##################################### ############################ APPS #####################################
INSTALLED_APPS = ( INSTALLED_APPS = (
# Standard apps
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.sites', 'django.contrib.sites',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles',
# For CMS
'contentstore', 'contentstore',
# For asset pipelining
'pipeline',
'staticfiles',
) )
<%namespace name='static' file='static_content.html'/>
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
% if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']:
<%static:css group='base-style'/>
% else:
<link rel="stylesheet" href="${ STATIC_URL }/css/base-style.css"> <link rel="stylesheet" href="${ STATIC_URL }/css/base-style.css">
% endif
<link rel="stylesheet" type="text/css" href="${ STATIC_URL }/js/markitup/skins/simple/style.css" /> <link rel="stylesheet" type="text/css" href="${ STATIC_URL }/js/markitup/skins/simple/style.css" />
<link rel="stylesheet" type="text/css" href="${ STATIC_URL }/js/markitup/sets/wiki/style.css" /> <link rel="stylesheet" type="text/css" href="${ STATIC_URL }/js/markitup/sets/wiki/style.css" />
<title><%block name="title"></%block></title> <title><%block name="title"></%block></title>
......
...@@ -21,7 +21,7 @@ def compressed_css(package_name): ...@@ -21,7 +21,7 @@ def compressed_css(package_name):
return render_individual_css(package, paths) return render_individual_css(package, paths)
def render_css(package, path): def render_css(package, path):
template_name = package.template_name or "pipeline_mako/css.html" template_name = package.template_name or "mako/css.html"
context = package.extra_context context = package.extra_context
context.update({ context.update({
'type': guess_type(path, 'text/css'), 'type': guess_type(path, 'text/css'),
...@@ -50,7 +50,7 @@ def compressed_js(package_name): ...@@ -50,7 +50,7 @@ def compressed_js(package_name):
return render_individual_js(package, paths, templates) return render_individual_js(package, paths, templates)
def render_js(package, path): def render_js(package, path):
template_name = package.template_name or "pipeline_mako/js.html" template_name = package.template_name or "mako/js.html"
context = package.extra_context context = package.extra_context
context.update({ context.update({
'type': guess_type(path, 'text/javascript'), 'type': guess_type(path, 'text/javascript'),
...@@ -63,7 +63,7 @@ def render_inline_js(package, js): ...@@ -63,7 +63,7 @@ def render_inline_js(package, js):
context.update({ context.update({
'source': js 'source': js
}) })
return render_to_string("pipeline_mako/inline_js.html", context) return render_to_string("mako/inline_js.html", context)
def render_individual_js(package, paths, templates=None): def render_individual_js(package, paths, templates=None):
tags = [render_js(package, js) for js in paths] tags = [render_js(package, js) for js in paths]
......
...@@ -73,7 +73,9 @@ MAKO_TEMPLATES['course'] = [DATA_DIR] ...@@ -73,7 +73,9 @@ MAKO_TEMPLATES['course'] = [DATA_DIR]
MAKO_TEMPLATES['sections'] = [DATA_DIR / 'sections'] MAKO_TEMPLATES['sections'] = [DATA_DIR / 'sections']
MAKO_TEMPLATES['custom_tags'] = [DATA_DIR / 'custom_tags'] MAKO_TEMPLATES['custom_tags'] = [DATA_DIR / 'custom_tags']
MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates', MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates',
COMMON_ROOT / 'templates',
COMMON_ROOT / 'lib' / 'capa' / 'templates', COMMON_ROOT / 'lib' / 'capa' / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
DATA_DIR / 'info', DATA_DIR / 'info',
DATA_DIR / 'problems'] DATA_DIR / 'problems']
......
...@@ -13,7 +13,7 @@ python-memcached ...@@ -13,7 +13,7 @@ python-memcached
django-celery django-celery
path.py path.py
django_debug_toolbar django_debug_toolbar
-e git+git://github.com/MITx/django-pipeline.git@incremental_compile#egg=django-pipeline -e git+git://github.com/MITx/django-pipeline.git#egg=django-pipeline
django-staticfiles>=1.2.1 django-staticfiles>=1.2.1
django-masquerade django-masquerade
fs fs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment