Commits

powersurge360 committed dc82854

Initial commit. Includes the command and some basic utilities.

Comments (0)

Files changed (9)

+syntax: glob
+
+*.pyc
+*~
+~*
+*.bak

__init__.py

Empty file added.

management/__init__.py

Empty file added.

management/commands/__init__.py

Empty file added.

management/commands/compilescss.py

+import os
+import glob
+
+from django.core.management.base import BaseCommand
+from django.conf import settings
+
+import scss
+
+import djangosassy
+DJANGOSASSY_PATH = os.path.dirname(djangosassy.__file__)
+
+scss.LOAD_PATHS = scss.LOAD_PATHS+","+os.path.join(DJANGOSASSY_PATH, 'scss')
+
+class Command(BaseCommand):
+    '''A command that will pull down any files in blog/scss and compile it to
+    css.
+    '''
+    args = "<app_label app_label>..."
+    help = "Compile the scss for a given app."
+    compiler = scss.Scss()
+    can_import_settings = True
+
+    def handle(self, *args, **kwargs):
+        apps = args if args else settings.INSTALLED_APPS
+
+        for app in apps:
+            module = __import__(app)
+            directories = {}
+            directories['app_root'] = os.path.realpath(os.path.dirname(getattr(module, "__file__")))
+            directories['scss_dir'] = os.path.join(directories['app_root'], 'scss')
+            directories['static_dir'] = os.path.join(directories['app_root'], 'static')
+            directories['css_dir'] = os.path.join(directories['static_dir'], 'styles')
+
+            # Try to create the directories.
+            self._create_directories(directories)
+
+            # Scss works out of the working directory.
+            os.chdir(directories['scss_dir'])
+
+            self._compile_styles(directories['scss_dir'], directories['css_dir'])
+
+    def _compile_styles(self, scss_dir, css_dir):
+        for file_name in glob.glob(os.path.join(scss_dir, '*.scss')):
+            # Build a CSS file based on the scss file
+            css_file_name = '.'.join(file_name.split('.')[:-1]) + '.css'
+            css_file_name = css_file_name.split(os.sep)[-1]
+
+            # Open both files, compile from one and write compiled css to the
+            # other. Note the escaped newline is not PEP8, but the recommended
+            # parens did not work here.
+            with open(file_name) as scss_file, \
+                 open(os.path.join(css_dir, css_file_name), 'w') as css_file:
+                css_file.write(self.compiler.compile(scss_file.read()))
+
+    def _create_directories(self, directory_dict):
+        for directory in directory_dict.values():
+            try:
+                os.mkdir(directory)
+            except OSError:
+                pass

scss/960/mixins.scss

+$gutter = 10px;
+$column = (($total-width - ($columns * $gutter * 2)) / $columns);
+
+@mixin number-of-columns($number) {
+    width: ($column * $number) + ($gutter * (($number * 2) - 2));
+    margin: 0 $gutter;
+    float: left;
+    display: inline;
+}
+
+@mixin pull($pull) {
+    position: relative;
+    right: ($column * $pull) + ($gutter * (($pull * 2) - 2));
+}
+
+@mixin push($push) {
+    position: relative;
+    left: ($column * $push) + ($gutter * (($push * 2) - 2));
+}
+
+@mixin suffix($number) {
+    padding-right: ($total-width / $columns) * $number;
+}
+
+@mixin prefix($number) {
+    padding-left: ($total-width / $columns) * $number;
+}
+
+@mixin alpha() {
+    margin-left: 0px;
+}
+
+@mixin omega() {
+    margin-right: 0px;
+}

scss/960/sixteen_column.scss

+$columns = 16;
+$total-width = 960px;

scss/960/twelve_column.scss

+$columns = 12;
+$total-width = 960px;

scss/utilities/clearfix.scss

+@mixin clearfix() {
+    &:after {
+        content: ".";
+        clear: both;
+        overflow: hidden;
+        visibility: none;
+        line-height: none;
+        display: block;
+        height: 0;
+        width: 0;
+    }
+}