Added a simple sass compiler for assets

This commit is contained in:
Sebastian 2016-04-23 00:42:04 +02:00
parent c775fc64c5
commit 46afdfb241
3 changed files with 44 additions and 2 deletions

View File

@ -1,6 +1,4 @@
#!/usr/bin/env python2
import os
import shutil
from verdandi.constants import CONTENT_DIRECTORY

39
modules/sassassets.py Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env python2
import os
from pylibsass import sass
from verdandi.mixins.messagemixin import MessageMixin
from verdandi.mixins.rendermixin import RenderMixin
from verdandi.mixins.assetsmixin import AssetsMixin
class SassAssets(MessageMixin, RenderMixin, AssetsMixin):
def collect_assets(self, output_directory):
super(SassAssets, self).collect_assets(output_directory)
assets = self.get_assets()
for source, destination in assets:
source_path = os.path.join(self.asset_directory, source)
dest_path = os.path.join(output_directory, destination);
if os.path.isfile(source_path):
self.compile_file(source_path, dest_path)
else:
print "Skipping %s is not a file" % source_path
def compile_file(self, source_path, dest_path):
print "Compiling %s to %s" % (source_path, dest_path)
sass_file = open(source_path, 'r')
css_file = open(dest_path, 'w')
sass_string = sass_file.read().decode('utf-8')
css_string = sass.compile_str(sass_string)
css_file.write(css_string.encode('utf-8'))
sass_file.close()
css_file.close()

View File

@ -1,7 +1,12 @@
argh==0.26.1
inotify==0.2.4
Jinja2==2.7.3
Markdown==2.6
MarkupSafe==0.23
pathtools==0.1.2
Pillow==3.1.0
pylibsass==0.1.4
python-dateutil==2.4.2
PyYAML==3.11
six==1.10.0
watchdog==0.8.3