changeset 2580:fb44a83e9720

add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
author RogerHaase <haaserd@gmail.com>
date Sat, 15 Mar 2014 08:06:12 -0700
parents 5c6c4fe6da4a
children a9c1d79b06b2
files make.py
diffstat 1 files changed, 24 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/make.py	Sat Mar 15 07:54:29 2014 -0700
+++ b/make.py	Sat Mar 15 08:06:12 2014 -0700
@@ -101,7 +101,7 @@
 run             run built-in wiki server
 backup *        roll 3 prior backups and create new backup *option, specify file
 
-css             run Stylus to update CSS files
+css             run Stylus and lessc to update theme CSS files
 tests           run tests, output goes to pytest.txt and pytestpep8.txt
 coding-std      correct scripts that taint the repository with trailing spaces..
 api             update moin api docs (files are under hg version control)
@@ -182,6 +182,12 @@
     print 'Deleted %s files matching "%s".' % (matches, pattern)
 
 
+def get_bootstrap_data_location():
+    """Return the virtualenv site-packages/xstatic/pkg/bootstrap/data location."""
+    command = ACTIVATE + 'python -c "from xstatic.pkg.bootstrap import BASE_DIR; print BASE_DIR"'
+    return subprocess.check_output(command, shell=True)
+
+
 class Commands(object):
     """Each cmd_ method processes a choice on the menu."""
     def __init__(self):
@@ -341,18 +347,29 @@
             print 'Error: cannot backup wiki because it has not been created.'
 
     def cmd_css(self, *args):
-        """run Stylus to update CSS files"""
-        print 'Running Stylus to update CSS files...'
-        command = 'cd {0}{1}stylus --include-css --compress < main.styl > ../common.css'.format(os.path.normpath('MoinMoin/themes/modernized/static/css/stylus'), SEP)
+        """run Stylus and lessc to update CSS files"""
+        print 'Running Stylus to update Modernized theme CSS files...'
+        # Note: we use / here to specify directory offsets; this works as used below in Windows XP, 2000, 7, 8
+        command = 'cd {0}{1}stylus --include-css --compress < main.styl > ../common.css'.format('MoinMoin/themes/modernized/static/css/stylus', SEP)
         result = subprocess.call(command, shell=True)
-        command = 'cd {0}{1} stylus --include-css --compress < main.styl > ../common.css'.format(os.path.normpath('MoinMoin/themes/foobar/static/css/stylus'), SEP)
+        print 'Running Stylus to update Foobar theme CSS files...'
+        command = 'cd {0}{1} stylus --include-css --compress < main.styl > ../common.css'.format('MoinMoin/themes/foobar/static/css/stylus', SEP)
         result2 = subprocess.call(command, shell=True)
-
         if result == 0 and result2 == 0:
-            print 'Success: CSS files updated.'
+            print 'Success: Modernized and Foobar CSS files updated.'
         else:
             print 'Error: stylus failed to update css files, see error messages above.'
 
+        print 'Running lessc to update Basic theme CSS files...'
+        data_loc = get_bootstrap_data_location().strip()
+        include = '--include-path=' + data_loc + '/less'
+        command = 'cd MoinMoin/themes/basic/static/custom-less{0}lessc {1} basic.less ../css/basic.css'.format(SEP, include)
+        result = subprocess.call(command, shell=True)
+        if result == 0:
+            print 'Success: Basic theme CSS files updated.'
+        else:
+            print 'Error: Basic theme CSS files update failed, see error messages above.'
+
     def cmd_tests(self, *args):
         """run tests, output goes to pytest.txt and pytestpep8.txt"""
         print 'Running tests... output written to %s and %s.' % (PYTEST, PEP8)