Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple sass compiler for assets
- Loading branch information
1 parent
c775fc6
commit 46afdfb
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
#!/usr/bin/env python2 | ||
import os | ||
import shutil | ||
|
||
from verdandi.constants import CONTENT_DIRECTORY | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |