예제 #1
0
import os
from strange_case.strange_case_config import CONFIG
from strange_case.registry import Registry
from strange_case.extensions.configurator_title_from_name import titlecase


def project_title(CONFIG):
    if CONFIG.get('project', None) is None:
        import sys
        sys.stderr.write(
            "Usage:\n    scase project:hyphenated-name [desc:description]\n\n'project' is required\n"
        )
        sys.exit(1)

    CONFIG['project'] = CONFIG['project'].replace('-', '_')
    CONFIG['Project'] = titlecase(CONFIG['project'])
    CONFIG['ProJect'] = CONFIG['Project'].replace(' ', '')
    CONFIG['deploy_path'] = os.path.abspath(
        os.path.dirname(__file__) + '/../' + CONFIG['ProJect'])


CONFIG['config_hook'] = project_title
CONFIG['len'] = len
CONFIG['deploy_path'] = 'ignore'

Registry.associate('page', '*.*')
예제 #2
0
    if 'thumbnails' not in config:
        return (image_node,)

    thumbs = []
    thumb_index = 0
    for thumbnail in config['thumbnails']:
        if isinstance(config['thumbnails'], list):
            thumb_index += 1
            size = thumbnail
            thumbnail = thumb_index = 1 and 'thumbnail' or 'thumbnail_' + thumb_index
        else:
            size = config['thumbnails'][thumbnail]
        target_name, ext = os.path.splitext(image_node.target_name)
        target_name += '_' + thumbnail
        target_name += ext
        thumb_config = image_node.config_copy(name=thumbnail, target_name=target_name)
        thumb_config['size'] = size
        thumb_config['iterable'] = False
        thumb_config['is_thumbnail'] = True
        thumb_config['skip'] = config['skip']

        configurate(os.path.join(source_path, target_name), thumb_config)
        thumbnail_node = ImageNode(thumb_config, source_path, target_path)
        image_node.config[thumbnail] = thumbnail_node
        thumbs.append(thumbnail_node)
    return (image_node, ) + tuple(thumbs)

Registry.register('image', processor)
Registry.associate('image', ['*.png', '*.jpg', '*.jpeg', '*.gif'])
예제 #3
0
            body
        ).set_lineno(lineno)

    def _scss_support(self, caller):
        return scss_compiler(caller()).strip()


class ScssNode(AssetNode):
    """
    Converts a .scss file into css
    """
    def generate_file(self, site, source_path, target_path):
        if not self['skip']:
            scss_content = open(source_path, 'r').read()
            css_content = scss_compiler(scss_content)
            with open(target_path, 'w') as f:
                f.write(css_content)
        self.files_tracked.append(source_path)
        self.files_written.append(target_path)


def processor(config, source_path, target_path):
    if config['target_name'].endswith('.scss'):
        config['target_name'] = config['target_name'][:-4] + 'css'

    scss_node = ScssNode(config, source_path, target_path)
    return (scss_node,)

Registry.register('scss', processor)
Registry.associate('scss', ['*.scss'])
예제 #4
0
파일: scss.py 프로젝트: gsdu8g9/StrangeCase
                                      [], body).set_lineno(lineno)

    def _scss_support(self, caller):
        return scss_compiler(caller()).strip()


class ScssNode(AssetNode):
    """
    Converts a .scss file into css
    """
    def generate_file(self, site, source_path, target_path):
        if not self['skip']:
            scss_content = open(source_path, 'r').read()
            css_content = scss_compiler(scss_content)
            with open(target_path, 'w') as f:
                f.write(css_content)
        self.files_tracked.append(source_path)
        self.files_written.append(target_path)


def processor(config, source_path, target_path):
    if config['target_name'].endswith('.scss'):
        config['target_name'] = config['target_name'][:-4] + 'css'

    scss_node = ScssNode(config, source_path, target_path)
    return (scss_node, )


Registry.register('scss', processor)
Registry.associate('scss', ['*.scss'])
예제 #5
0

class CleverCssNode(AssetNode):
    """
    Converts a .ccss file into css
    """
    def generate_file(self, site, source_path, target_path):
        if not self['skip']:
            ccss_content = open(source_path, 'r').read()
            css_content = clevercss_compiler(ccss_content)
            with open(target_path, 'w') as f:
                f.write(css_content)
        elif self['__verbose']:
            sys.stderr.write("Skipping %s\n" % target_path)
        self.files_tracked.append(source_path)
        self.files_written.append(target_path)


def processor(config, source_path, target_path):
    if config['target_name'].endswith('ccss'):
        config['target_name'] = config['target_name'][:-4] + 'css'
    if config['target_name'].endswith('clevercss'):
        config['target_name'] = config['target_name'][:-9] + 'css'

    ccss_node = CleverCssNode(config, source_path, target_path)
    return (ccss_node,)


Registry.register('clevercss', processor)
Registry.associate('clevercss', ['*.ccss', '*.clevercss'])
예제 #6
0
    if 'thumbnails' not in config:
        return (image_node,)

    thumbs = []
    thumb_index = 0
    for thumbnail in config['thumbnails']:
        if isinstance(config['thumbnails'], list):
            thumb_index += 1
            size = thumbnail
            thumbnail = thumb_index = 1 and 'thumbnail' or 'thumbnail_' + thumb_index
        else:
            size = config['thumbnails'][thumbnail]
        target_name, ext = os.path.splitext(image_node.target_name)
        target_name += '_' + thumbnail
        target_name += ext
        thumb_config = image_node.config_copy(name=thumbnail, target_name=target_name)
        thumb_config['size'] = size
        thumb_config['iterable'] = False
        thumb_config['is_thumbnail'] = True
        thumb_config['skip'] = config['skip']

        configurate(os.path.join(source_path, target_name), thumb_config)
        thumbnail_node = ImageNode(thumb_config, source_path, target_path)
        image_node.config[thumbnail] = thumbnail_node
        thumbs.append(thumbnail_node)
    return (image_node, ) + tuple(thumbs)

Registry.register('image', processor)
Registry.associate('image', ['*.png', '*.jpg', '*.jpeg', '*.gif',
                             '*.PNG', '*.JPG', '*.JPEG', '*.GIF'])
예제 #7
0
    if 'thumbnails' not in config:
        return (image_node,)

    thumbs = []
    thumb_index = 0
    for thumbnail in config['thumbnails']:
        if isinstance(config['thumbnails'], list):
            thumb_index += 1
            size = thumbnail
            thumbnail = thumb_index = 1 and 'thumbnail' or 'thumbnail_' + thumb_index
        else:
            size = config['thumbnails'][thumbnail]
        target_name, ext = os.path.splitext(image_node.target_name)
        target_name += '_' + thumbnail
        target_name += ext
        thumb_config = image_node.config_copy(name=thumbnail, target_name=target_name)
        thumb_config['size'] = size
        thumb_config['iterable'] = False
        thumb_config['is_thumbnail'] = True
        thumb_config['skip'] = config['skip']

        configurate(os.path.join(source_path, target_name), thumb_config)
        thumbnail_node = ImageNode(thumb_config, source_path, target_path)
        image_node.config[thumbnail] = thumbnail_node
        thumbs.append(thumbnail_node)
    return (image_node, ) + tuple(thumbs)

Registry.register('image', processor)
Registry.associate('image', ['*.png', '*.jpg', '*.jpeg', '*.gif',
                             '*.PNG', '*.JPG', '*.JPEG', '*.GIF'])
예제 #8
0
import os
from strange_case.strange_case_config import CONFIG
from strange_case.registry import Registry
from strange_case.extensions.configurator_title_from_name import titlecase


def project_title(CONFIG):
    if CONFIG.get('project', None) is None:
        import sys
        sys.stderr.write("Usage:\n    scase project:hyphenated-name [desc:description]\n\n'project' is required\n")
        sys.exit(1)

    CONFIG['project'] = CONFIG['project'].replace('-', '_')
    CONFIG['Project'] = titlecase(CONFIG['project'])
    CONFIG['ProJect'] = CONFIG['Project'].replace(' ', '')
    CONFIG['deploy_path'] = os.path.abspath(os.path.dirname(__file__) + '/../' + CONFIG['ProJect'])

CONFIG['config_hook'] = project_title
CONFIG['len'] = len
CONFIG['deploy_path'] = 'ignore'

Registry.associate('page', '*.*')
예제 #9
0

class CleverCssNode(AssetNode):
    """
    Converts a .ccss file into css
    """
    def generate_file(self, site, source_path, target_path):
        if self['skip']:
            print 'Skipping %s' % target_path
        if not self['skip']:
            ccss_content = open(source_path, 'r').read()
            css_content = clevercss_compiler(ccss_content)
            with open(target_path, 'w') as f:
                f.write(css_content)
        self.files_tracked.append(source_path)
        self.files_written.append(target_path)


def processor(config, source_path, target_path):
    if config['target_name'].endswith('ccss'):
        config['target_name'] = config['target_name'][:-4] + 'css'
    if config['target_name'].endswith('clevercss'):
        config['target_name'] = config['target_name'][:-9] + 'css'

    ccss_node = CleverCssNode(config, source_path, target_path)
    return (ccss_node,)


Registry.register('clevercss', processor)
Registry.associate('clevercss', ['*.ccss', '*.clevercss'])