示例#1
0
class Theme(object):
    """Represents a theme."""

    def __init__(self, folder):
        self.id = path.basename(folder)
        self.folder = folder
        self.template_path = path.join(folder, 'templates')
        with open(path.join(folder, 'theme.ini')) as f:
            self.config = parse_ini(f)
        self.name = self.config.get('theme.name', self.id)
        self.packs = PackManager(path.join(folder, 'static'),
                                 self.get_link)
        for key, value in self.config.iteritems():
            if key.startswith('packs.'):
                self.packs.add_pack(key[6:], value.split())

    def open_resource(self, filename):
        """Opens a resource from the static folder as fd."""
        pieces = split_path_safely(filename)
        if pieces is not None:
            fn = path.join(self.folder, 'static', *pieces)
            if path.isfile(fn):
                return open(fn, 'rb')

    def get_link(self, filename, ext=None):
        return url_for('themes.get_resource', theme=self.id,
                       file=filename)
示例#2
0
class Theme(object):
    """Represents a theme."""
    def __init__(self, folder):
        self.id = path.basename(folder)
        self.folder = folder
        self.template_path = path.join(folder, 'templates')
        with open(path.join(folder, 'theme.ini')) as f:
            self.config = parse_ini(f)
        self.name = self.config.get('theme.name', self.id)
        self.packs = PackManager(path.join(folder, 'static'), self.get_link)
        for key, value in self.config.iteritems():
            if key.startswith('packs.'):
                self.packs.add_pack(key[6:], value.split())

    def open_resource(self, filename):
        """Opens a resource from the static folder as fd."""
        pieces = split_path_safely(filename)
        if pieces is not None:
            fn = path.join(self.folder, 'static', *pieces)
            if path.isfile(fn):
                return open(fn, 'rb')

    def get_link(self, filename, ext=None):
        return url_for('themes.get_resource', theme=self.id, file=filename)
示例#3
0
文件: packs.py 项目: DasIch/solace
# -*- coding: utf-8 -*-
"""
    solace.packs
    ~~~~~~~~~~~~

    The packs for static files.

    :copyright: (c) 2010 by the Solace Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""
import os
from solace.utils.packs import PackManager


pack_mgr = PackManager(os.path.join(os.path.dirname(__file__), 'static'))
pack_mgr.add_pack('default', ['layout.css', 'jquery.js', 'babel.js', 'solace.js',
                              'jquery.form.js', 'jquery.autocomplete.js',
                              'creole.js'])
示例#4
0
文件: packs.py 项目: tzoght/solace
# -*- coding: utf-8 -*-
"""
    solace.packs
    ~~~~~~~~~~~~

    The packs for static files.

    :copyright: (c) 2010 by the Solace Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""
import os
from solace.utils.packs import PackManager

pack_mgr = PackManager(os.path.join(os.path.dirname(__file__), 'static'))
pack_mgr.add_pack('default', [
    'layout.css', 'jquery.js', 'babel.js', 'solace.js', 'jquery.form.js',
    'jquery.autocomplete.js', 'creole.js'
])