Commit 7dcc6b38 by Calen Pennington

Moving sass compilation to django-pipeline

parent 26a3e6cd
......@@ -137,6 +137,9 @@ STATIC_ROOT = ENV_ROOT / "staticfiles" # We don't run collectstatic -- this is t
STATICFILES_DIRS = (
PROJECT_ROOT / "static",
ASKBOT_ROOT / "askbot" / "skins",
("circuits", DATA_DIR / "images"),
("handouts", DATA_DIR / "handouts"),
("subs", DATA_DIR / "subs"),
# This is how you would use the textbook images locally
# ("book", ENV_ROOT / "book_images")
......@@ -183,8 +186,8 @@ WIKI_REQUIRE_LOGIN_VIEW = True
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder',
)
# List of callables that know how to import templates from various sources.
......@@ -220,6 +223,37 @@ MIDDLEWARE_CLASSES = (
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
)
############################### Pipeline #######################################
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS = {
'application': {
'source_filenames': ['css/application.scss'],
'output_filename': 'css/application.css',
},
'marketing': {
'source_filenames': ['css/marketing.scss'],
'output_filename': 'css/marketing.css',
},
'marketing-ie': {
'source_filenames': ['css/marketing-ie.scss'],
'output_filename': 'css/marketing-ie.css',
},
'print': {
'source_filenames': ['css/print.scss'],
'output_filename': 'css/print.css',
}
}
PIPELINE_COMPILERS = [
'pipeline.compilers.sass.SASSCompiler'
]
PIPELINE_SASS_ARGUMENTS = '-r {proj_dir}/bourbon/lib/bourbon.rb'.format(proj_dir=PROJECT_ROOT)
PIPELINE_CSS_COMPRESSOR = None
################################### APPS #######################################
INSTALLED_APPS = (
# Standard ones that are always installed...
......@@ -229,9 +263,12 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'south',
# For asset pipelining
'pipeline',
'staticfiles',
# Our courseware
'circuit',
'courseware',
......
......@@ -10,6 +10,7 @@ sessions. Assumes structure:
from common import *
DEBUG = True
PIPELINE = True
TEMPLATE_DEBUG = True
LOGGING = logsettings.get_logger_config(ENV_ROOT / "log",
......
......@@ -82,5 +82,10 @@ def get_logger_config(log_dir,
'level' : 'DEBUG',
'propagate' : False
},
'keyedcache' : {
'handlers' : handlers,
'level' : 'DEBUG',
'propagate' : False
},
}
}
\ No newline at end of file
}
try:
from staticfiles.storage import staticfiles_storage
except ImportError:
from django.contrib.staticfiles.storage import staticfiles_storage # noqa
from mitxmako.shortcuts import render_to_string
from pipeline.conf import settings
from pipeline.packager import Packager, PackageNotFound
from pipeline.utils import guess_type
def compressed_css(package_name):
package = settings.PIPELINE_CSS.get(package_name, {})
if package:
package = {package_name: package}
packager = Packager(css_packages=package, js_packages={})
try:
package = packager.package_for('css', package_name)
except PackageNotFound:
return '' # fail silently, do not return anything if an invalid group is specified
if settings.PIPELINE:
return render_css(package, package.output_filename)
else:
paths = packager.compile(package.paths)
return render_individual_css(package, paths)
def render_css(package, path):
template_name = package.template_name or "pipeline/css.html"
context = package.extra_context
context.update({
'type': guess_type(path, 'text/css'),
'url': staticfiles_storage.url(path)
})
return render_to_string(template_name, context)
def render_individual_css(package, paths):
tags = [render_css(package, path) for path in paths]
return '\n'.join(tags)
def compressed_js(package_name):
package = settings.PIPELINE_JS.get(package_name, {})
if package:
package = {package_name: package}
packager = Packager(css_packages={}, js_packages=package)
try:
package = packager.package_for('js', package_name)
except PackageNotFound:
return '' # fail silently, do not return anything if an invalid group is specified
if settings.PIPELINE:
return render_js(package, package.output_filename)
else:
paths = packager.compile(package.paths)
templates = packager.pack_templates(package)
return render_individual_js(package, paths, templates)
def render_js(package, path):
template_name = package.template_name or "pipeline/js.html"
context = package.extra_context
context.update({
'type': guess_type(path, 'text/javascript'),
'url': staticfiles_storage.url(path)
})
return render_to_string(template_name, context)
def render_inline_js(package, js):
context = package.extra_context
context.update({
'source': js
})
return render_to_string("pipeline/inline_js.html", context)
def render_individual_js(package, paths, templates=None):
tags = [render_js(package, js) for js in paths]
if templates:
tags.append(render_inline_js(package, templates))
return '\n'.join(tags)
../../book_images/
\ No newline at end of file
../../data/images/
\ No newline at end of file
../../askbot-devel/askbot/skins/common/
\ No newline at end of file
......@@ -115,7 +115,7 @@ div.info-wrapper {
}
div.hitarea {
background-image: url('/static/images/treeview-default.gif');
background-image: url('../images/treeview-default.gif');
width: 100%;
height: 100%;
max-height: 20px;
......
......@@ -23,7 +23,7 @@ div.book-wrapper {
div.hitarea {
margin-left: -22px;
background-image: url('/static/images/treeview-default.gif');
background-image: url('../images/treeview-default.gif');
position: relative;
top: 4px;
......@@ -106,7 +106,7 @@ div.book-wrapper {
padding: 0;
a {
background-image: url('/static/images/slide-right-icon.png');
background-image: url('../images/slide-right-icon.png');
}
h2 {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -177,7 +177,7 @@ h1.top-header {
}
a {
background: #eee url('/static/images/slide-left-icon.png') center center no-repeat;
background: #eee url('../images/slide-left-icon.png') center center no-repeat;
border: 1px solid #D3D3D3;
@include border-radius(3px 0 0 3px);
height: 16px;
......
/* Generated by Font Squirrel (http://www.fontsquirrel.com) on January 25, 2012 05:06:34 PM America/New_York */
// Not used in UI
// @font-face {
// font-family: 'Open Sans';
// src: url('../fonts/OpenSans-Light-webfont.eot');
// src: url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
// url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
// url('../fonts/OpenSans-Light-webfont.ttf') format('truetype'),
// url('../fonts/OpenSans-Light-webfont.svg#OpenSansLight') format('svg');
// font-weight: 300;
// font-style: normal;
// }
// @font-face {
// font-family: 'Open Sans';
// src: url('../fonts/OpenSans-LightItalic-webfont.eot');
// src: url('../fonts/OpenSans-LightItalic-webfont.eot?#iefix') format('embedded-opentype'),
// url('../fonts/OpenSans-LightItalic-webfont.woff') format('woff'),
// url('../fonts/OpenSans-LightItalic-webfont.ttf') format('truetype'),
// url('../fonts/OpenSans-LightItalic-webfont.svg#OpenSansLightItalic') format('svg');
// font-weight: 300;
// font-style: italic;
// }
@font-face {
font-family: 'Open Sans';
src: url('../fonts/OpenSans-Regular-webfont.eot');
src: url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
url('../fonts/OpenSans-Regular-webfont.ttf') format('truetype'),
url('../fonts/OpenSans-Regular-webfont.svg#OpenSansRegular') format('svg');
font-weight: 600;
font-style: normal;
}
@font-face {
font-family: 'Open Sans';
src: url('../fonts/OpenSans-Italic-webfont.eot');
src: url('../fonts/OpenSans-Italic-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Italic-webfont.woff') format('woff'),
url('../fonts/OpenSans-Italic-webfont.ttf') format('truetype'),
url('../fonts/OpenSans-Italic-webfont.svg#OpenSansItalic') format('svg');
font-weight: 400;
font-style: italic;
}
// Not used in UI
// @font-face {
// font-family: 'Open Sans';
// src: url('../fonts/OpenSans-Semibold-webfont.eot');
// src: url('../fonts/OpenSans-Semibold-webfont.eot?#iefix') format('embedded-opentype'),
// url('../fonts/OpenSans-Semibold-webfont.woff') format('woff'),
// url('../fonts/OpenSans-Semibold-webfont.ttf') format('truetype'),
// url('../fonts/OpenSans-Semibold-webfont.svg#OpenSansSemibold') format('svg');
// font-weight: 600;
// font-style: normal;
// }
// @font-face {
// font-family: 'Open Sans';
// src: url('../fonts/OpenSans-SemiboldItalic-webfont.eot');
// src: url('../fonts/OpenSans-SemiboldItalic-webfont.eot?#iefix') format('embedded-opentype'),
// url('../fonts/OpenSans-SemiboldItalic-webfont.woff') format('woff'),
// url('../fonts/OpenSans-SemiboldItalic-webfont.ttf') format('truetype'),
// url('../fonts/OpenSans-SemiboldItalic-webfont.svg#OpenSansSemiboldItalic') format('svg');
// font-weight: 600;
// font-style: italic;
// }
@font-face {
font-family: 'Open Sans';
src: url('../fonts/OpenSans-Bold-webfont.eot');
src: url('../fonts/OpenSans-Bold-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Bold-webfont.woff') format('woff'),
url('../fonts/OpenSans-Bold-webfont.ttf') format('truetype'),
url('../fonts/OpenSans-Bold-webfont.svg#OpenSansBold') format('svg');
font-weight: 700;
font-style: normal;
}
@font-face {
font-family: 'Open Sans';
src: url('../fonts/OpenSans-BoldItalic-webfont.eot');
src: url('../fonts/OpenSans-BoldItalic-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-BoldItalic-webfont.woff') format('woff'),
url('../fonts/OpenSans-BoldItalic-webfont.ttf') format('truetype'),
url('../fonts/OpenSans-BoldItalic-webfont.svg#OpenSansBoldItalic') format('svg');
font-weight: 700;
font-style: italic;
}
@font-face {
font-family: 'Open Sans';
src: url('../fonts/OpenSans-ExtraBold-webfont.eot');
src: url('../fonts/OpenSans-ExtraBold-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-ExtraBold-webfont.woff') format('woff'),
url('../fonts/OpenSans-ExtraBold-webfont.ttf') format('truetype'),
url('../fonts/OpenSans-ExtraBold-webfont.svg#OpenSansExtrabold') format('svg');
font-weight: 800;
font-style: normal;
}
@font-face {
font-family: 'Open Sans';
src: url('../fonts/OpenSans-ExtraBoldItalic-webfont.eot');
src: url('../fonts/OpenSans-ExtraBoldItalic-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-ExtraBoldItalic-webfont.woff') format('woff'),
url('../fonts/OpenSans-ExtraBoldItalic-webfont.ttf') format('truetype'),
url('../fonts/OpenSans-ExtraBoldItalic-webfont.svg#OpenSansExtraboldItalic') format('svg');
font-weight: 800;
font-style: italic;
}
......@@ -78,7 +78,7 @@ div.course-wrapper {
span {
&.unanswered, &.ui-icon-bullet {
@include inline-block();
background: url('/static/images/unanswered-icon.png') center center no-repeat;
background: url('../images/unanswered-icon.png') center center no-repeat;
height: 14px;
position: relative;
top: 4px;
......@@ -87,7 +87,7 @@ div.course-wrapper {
&.correct, &.ui-icon-check {
@include inline-block();
background: url('/static/images/correct-icon.png') center center no-repeat;
background: url('../images/correct-icon.png') center center no-repeat;
height: 20px;
position: relative;
top: 6px;
......@@ -96,7 +96,7 @@ div.course-wrapper {
&.incorrect, &.ui-icon-close {
@include inline-block();
background: url('/static/images/incorrect-icon.png') center center no-repeat;
background: url('../images/incorrect-icon.png') center center no-repeat;
height: 20px;
width: 20px;
position: relative;
......@@ -192,7 +192,7 @@ div.course-wrapper {
a.ui-slider-handle {
@include box-shadow(inset 0 1px 0 lighten($mit-red, 10%));
background: $mit-red url(/static/images/slider-bars.png) center center no-repeat;
background: $mit-red url(../images/slider-bars.png) center center no-repeat;
border: 1px solid darken($mit-red, 20%);
cursor: pointer;
......@@ -212,7 +212,7 @@ div.course-wrapper {
padding: 0;
a {
background-image: url('/static/images/slide-right-icon.png');
background-image: url('../images/slide-right-icon.png');
}
h2 {
......
......@@ -71,57 +71,57 @@ nav.sequence-nav {
//video
&.seq_video_inactive {
@extend .inactive;
background-image: url('/static/images/sequence-nav/video-icon-normal.png');
background-image: url('../images/sequence-nav/video-icon-normal.png');
background-position: center;
}
&.seq_video_visited {
@extend .visited;
background-image: url('/static/images/sequence-nav/video-icon-visited.png');
background-image: url('../images/sequence-nav/video-icon-visited.png');
background-position: center;
}
&.seq_video_active {
@extend .active;
background-image: url('/static/images/sequence-nav/video-icon-current.png');
background-image: url('../images/sequence-nav/video-icon-current.png');
background-position: center;
}
//other
&.seq_other_inactive {
@extend .inactive;
background-image: url('/static/images/sequence-nav/document-icon-normal.png');
background-image: url('../images/sequence-nav/document-icon-normal.png');
background-position: center;
}
&.seq_other_visited {
@extend .visited;
background-image: url('/static/images/sequence-nav/document-icon-visited.png');
background-image: url('../images/sequence-nav/document-icon-visited.png');
background-position: center;
}
&.seq_other_active {
@extend .active;
background-image: url('/static/images/sequence-nav/document-icon-current.png');
background-image: url('../images/sequence-nav/document-icon-current.png');
background-position: center;
}
//vertical & problems
&.seq_vertical_inactive, &.seq_problem_inactive {
@extend .inactive;
background-image: url('/static/images/sequence-nav/list-icon-normal.png');
background-image: url('../images/sequence-nav/list-icon-normal.png');
background-position: center;
}
&.seq_vertical_visited, &.seq_problem_visited {
@extend .visited;
background-image: url('/static/images/sequence-nav/list-icon-visited.png');
background-image: url('../images/sequence-nav/list-icon-visited.png');
background-position: center;
}
&.seq_vertical_active, &.seq_problem_active {
@extend .active;
background-image: url('/static/images/sequence-nav/list-icon-current.png');
background-image: url('../images/sequence-nav/list-icon-current.png');
background-position: center;
}
}
......@@ -209,7 +209,7 @@ nav.sequence-nav {
&.prev {
a {
background-image: url('/static/images/sequence-nav/previous-icon.png');
background-image: url('../images/sequence-nav/previous-icon.png');
&:hover {
background-color: none;
......@@ -219,7 +219,7 @@ nav.sequence-nav {
&.next {
a {
background-image: url('/static/images/sequence-nav/next-icon.png');
background-image: url('../images/sequence-nav/next-icon.png');
&:hover {
background-color: none;
......@@ -287,7 +287,7 @@ section.course-content {
&.prev {
a {
background-image: url('/static/images/sequence-nav/previous-icon.png');
background-image: url('../images/sequence-nav/previous-icon.png');
&:hover {
background-color: none;
......@@ -297,7 +297,7 @@ section.course-content {
&.next {
a {
background-image: url('/static/images/sequence-nav/next-icon.png');
background-image: url('../images/sequence-nav/next-icon.png');
&:hover {
background-color: none;
......
......@@ -114,7 +114,7 @@ section.course-content {
a.ui-slider-handle {
@include border-radius(15px);
@include box-shadow(inset 0 1px 0 lighten($mit-red, 10%));
background: $mit-red url(/static/images/slider-handle.png) center center no-repeat;
background: $mit-red url(../images/slider-handle.png) center center no-repeat;
border: 1px solid darken($mit-red, 20%);
cursor: pointer;
height: 15px;
......@@ -165,7 +165,7 @@ section.course-content {
@include transition();
&.play {
background: url('/static/images/play-icon.png') center center no-repeat;
background: url('../images/play-icon.png') center center no-repeat;
&:hover {
background-color: #444;
......@@ -173,7 +173,7 @@ section.course-content {
}
&.pause {
background: url('/static/images/pause-icon.png') center center no-repeat;
background: url('../images/pause-icon.png') center center no-repeat;
&:hover {
background-color: #444;
......@@ -267,7 +267,7 @@ section.course-content {
width: 30px;
text-indent: -9999px;
font-weight: 800;
background: url('/static/images/cc.png') center no-repeat;
background: url('../images/cc.png') center no-repeat;
-webkit-font-smoothing: antialiased;
@include transition();
opacity: 1;
......
......@@ -73,7 +73,7 @@ body.askbot {
}
.acLoading {
background : url('../images/indicator.gif') right center no-repeat;
background : url('../default/media/images/indicator.gif') right center no-repeat;
}
.acSelect {
......
......@@ -50,7 +50,7 @@
margin-left: 5px;
margin-right: 5px;
position: absolute;
background-image: url(/static/images/askbot/wmd-buttons.png);
background-image: url(../images/askbot/wmd-buttons.png);
background-repeat: no-repeat;
background-position: 0px 0px;
display: inline-block;
......
......@@ -80,7 +80,7 @@ body.user-profile-page {
&.up {
background-color:#d1e3a8;
background-image: url(/static/images/askbot/vote-arrow-up-activate.png);
background-image: url(../images/askbot/vote-arrow-up-activate.png);
margin-right: 6px;
span.vote-count {
......@@ -89,7 +89,7 @@ body.user-profile-page {
}
&.down {
background-image: url(/static/images/askbot/vote-arrow-down-activate.png);
background-image: url(../images/askbot/vote-arrow-down-activate.png);
background-color:#eac6ad;
span.vote-count {
......
......@@ -25,23 +25,23 @@ div.question-header {
}
&.question-img-upvote, &.answer-img-upvote {
background-image: url(/static/images/askbot/vote-arrow-up.png);
background-image: url(../images/askbot/vote-arrow-up.png);
@include box-shadow(inset 0 1px 0px rgba(255, 255, 255, 0.5));
&:hover, &.on {
background-color:#d1e3a8;
border-color: darken(#D1E3A8, 20%);
background-image: url(/static/images/askbot/vote-arrow-up-activate.png);
background-image: url(../images/askbot/vote-arrow-up-activate.png);
}
}
&.question-img-downvote, &.answer-img-downvote {
background-image: url(/static/images/askbot/vote-arrow-down.png);
background-image: url(../images/askbot/vote-arrow-down.png);
&:hover, &.on {
background-color:#EAC6AD;
border-color: darken(#EAC6AD, 20%);
background-image: url(/static/images/askbot/vote-arrow-down-activate.png);
background-image: url(../images/askbot/vote-arrow-down-activate.png);
}
}
}
......
......@@ -106,7 +106,7 @@ div.discussion-wrapper aside {
input[type='submit'] {
@include box-shadow(none);
opacity: 0.5;
background: url(/static/images/askbot/search-icon.png) no-repeat center;
background: url(../images/askbot/search-icon.png) no-repeat center;
border: 0;
margin-left: 3px;
position: absolute;
......
......@@ -6,7 +6,7 @@ footer {
div.footer-wrapper {
border-top: 1px solid #e5e5e5;
padding: lh() 0;
background: url('/static/images/marketing/mit-logo.png') right center no-repeat;
background: url('../images/marketing/mit-logo.png') right center no-repeat;
@media screen and (max-width: 780px) {
background-position: left bottom;
......@@ -84,15 +84,15 @@ footer {
}
&.twitter a {
background: url('/static/images/marketing/twitter.png') 0 0 no-repeat;
background: url('../images/marketing/twitter.png') 0 0 no-repeat;
}
&.facebook a {
background: url('/static/images/marketing/facebook.png') 0 0 no-repeat;
background: url('../images/marketing/facebook.png') 0 0 no-repeat;
}
&.linkedin a {
background: url('/static/images/marketing/linkedin.png') 0 0 no-repeat;
background: url('../images/marketing/linkedin.png') 0 0 no-repeat;
}
}
}
......
......@@ -6,10 +6,10 @@ header.announcement {
-webkit-font-smoothing: antialiased;
&.home {
background: #e3e3e3 url("/static/images/marketing/shot-5-medium.jpg");
background: #e3e3e3 url("../images/marketing/shot-5-medium.jpg");
@media screen and (min-width: 1200px) {
background: #e3e3e3 url("/static/images/marketing/shot-5-large.jpg");
background: #e3e3e3 url("../images/marketing/shot-5-large.jpg");
}
div {
......@@ -33,14 +33,14 @@ header.announcement {
}
&.course {
background: #e3e3e3 url("/static/images/marketing/course-bg-small.jpg");
background: #e3e3e3 url("../images/marketing/course-bg-small.jpg");
@media screen and (min-width: 1200px) {
background: #e3e3e3 url("/static/images/marketing/course-bg-large.jpg");
background: #e3e3e3 url("../images/marketing/course-bg-large.jpg");
}
@media screen and (max-width: 1199px) and (min-width: 700px) {
background: #e3e3e3 url("/static/images/marketing/course-bg-medium.jpg");
background: #e3e3e3 url("../images/marketing/course-bg-medium.jpg");
}
div {
......
......@@ -221,16 +221,16 @@ section.index-content {
&.course {
h2 {
padding-top: lh(5);
background: url('/static/images/marketing/circuits-bg.jpg') 0 0 no-repeat;
background: url('../images/marketing/circuits-bg.jpg') 0 0 no-repeat;
@include background-size(contain);
@media screen and (max-width: 998px) and (min-width: 781px){
background: url('/static/images/marketing/circuits-medium-bg.jpg') 0 0 no-repeat;
background: url('../images/marketing/circuits-medium-bg.jpg') 0 0 no-repeat;
}
@media screen and (max-width: 780px) {
padding-top: lh(5);
background: url('/static/images/marketing/circuits-bg.jpg') 0 0 no-repeat;
background: url('../images/marketing/circuits-bg.jpg') 0 0 no-repeat;
}
@media screen and (min-width: 500px) and (max-width: 781px) {
......
......@@ -6,7 +6,7 @@ li.calc-main {
a.calc {
@include hide-text;
background: url("/static/images/calc-icon.png") rgba(#111, .9) no-repeat center;
background: url("../images/calc-icon.png") rgba(#111, .9) no-repeat center;
border-bottom: 0;
color: #fff;
float: right;
......@@ -24,7 +24,7 @@ li.calc-main {
}
&.closed {
background-image: url("/static/images/close-calc-icon.png");
background-image: url("../images/close-calc-icon.png");
}
}
......@@ -103,7 +103,7 @@ li.calc-main {
@include hide-text;
width: 17px;
height: 17px;
background: url("/static/images/info-icon.png") center center no-repeat;
background: url("../images/info-icon.png") center center no-repeat;
}
dl {
......
......@@ -80,15 +80,15 @@ footer {
}
&.twitter a {
background: url('/static/images/twitter.png') 0 0 no-repeat;
background: url('../images/twitter.png') 0 0 no-repeat;
}
&.facebook a {
background: url('/static/images/facebook.png') 0 0 no-repeat;
background: url('../images/facebook.png') 0 0 no-repeat;
}
&.linkedin a {
background: url('/static/images/linkedin.png') 0 0 no-repeat;
background: url('../images/linkedin.png') 0 0 no-repeat;
}
}
}
......
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