# HG changeset patch # User Steve Losh # Date 1455882618 0 # Node ID 1ddb600eeb223c3bb043cb7cb527ae3c87d64e45 # Parent 0372f764542171c6b280d8fac969f32abbe833d0 Add support for Wisp diff -r 0372f7645421 -r 1ddb600eeb22 custom/processors.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/custom/processors.py Fri Feb 19 11:50:18 2016 +0000 @@ -0,0 +1,22 @@ +import os +import sys +from django.conf import settings +from hydeengine.file_system import File +from subprocess import check_output, CalledProcessError + +class Wisp: + @staticmethod + def process(resource): + wisp = settings.WISP_PATH + if not wisp or not os.path.exists(wisp): + raise ValueError("Wisp cannot be found at [%s]" % wisp) + + try: + data = check_output([wisp, "-c", resource.source_file.path]).decode('utf-8') + except CalledProcessError, e: + print 'Syntax Error when calling Wisp:', e + return None + + out_file = File(resource.source_file.path_without_extension + ".js") + resource.source_file = out_file + resource.source_file.write(data) diff -r 0372f7645421 -r 1ddb600eeb22 settings.py --- a/settings.py Wed Dec 16 23:25:03 2015 +0000 +++ b/settings.py Fri Feb 19 11:50:18 2016 +0000 @@ -45,7 +45,10 @@ 'images/': { '.png': ('hydeengine.media_processors.Thumbnail',), '.jpg': ('hydeengine.media_processors.Thumbnail',), - } + }, + 'js/': { + '.wisp': ('custom.processors.Wisp',), + }, } CONTENT_PROCESSORS = {} @@ -104,6 +107,7 @@ THUMBNAIL_MAX_WIDTH = 1400000000 THUMBNAIL_MAX_HEIGHT = 100 THUMBNAIL_FILENAME_POSTFIX = '-thumb' +WISP_PATH = '/usr/local/bin/wisp' # Django settings