Beispiel #1
0
 def fix_generated_filenames(self):
     suffix = self.config().get("source_suffix", ".rst")
     for resource in self.__node.walk_resources():
         if resource.source_file.path.endswith(suffix):
             new_name = resource.source_file.name_without_extension + ".html"
             target_folder = File(resource.relative_deploy_path).parent
             resource.relative_deploy_path = target_folder.child(new_name)
             if self.__settings.get("block_map", None):
                 resource.meta.default_block = None
Beispiel #2
0
Datei: less.py Projekt: semk/hyde
 def begin_site(self):
     """
     Find all the less css files and set their relative deploy path.
     """
     for resource in self.site.content.walk_resources():
         if resource.source_file.kind == 'less':
             new_name = resource.source_file.name_without_extension + ".css"
             target_folder = File(resource.relative_deploy_path).parent
             resource.relative_deploy_path = target_folder.child(new_name)
Beispiel #3
0
 def begin_site(self):
     """
     Find all the coffee files and set their relative deploy path.
     """
     for resource in self.site.content.walk_resources():
         if resource.source_file.kind == 'coffee': #and \
             #self._should_parse_resource(resource):
             new_name = resource.source_file.name_without_extension + ".js"
             target_folder = File(resource.relative_deploy_path).parent
             resource.relative_deploy_path = target_folder.child(new_name)
             resource.uses_template==False
Beispiel #4
0
    def begin_site(self):
        """Event hook for when site processing begins.

        This hook checks that the site is correctly configured for building
        with sphinx, and adjusts any sphinx-controlled resources so that
        hyde will process them correctly.
        """
        settings = self.settings
        if settings.sanity_check:
            self._sanity_check()
        #  Find and adjust all the resource that will be handled by sphinx.
        #  We need to:
        #    * change the deploy name from .rst to .html
        #    * if a block_map is given, switch off default_block
        suffix = self.sphinx_config.get("source_suffix",".rst")
        for resource in self.site.content.walk_resources():
            if resource.source_file.path.endswith(suffix):
                new_name = resource.source_file.name_without_extension + ".html"
                target_folder = File(resource.relative_deploy_path).parent
                resource.relative_deploy_path = target_folder.child(new_name)
                if settings.block_map:
                    resource.meta.default_block = None
Beispiel #5
0
def test_child():
    p = File(__file__).parent
    c = p.child('data.dat')
    assert c == os.path.join(os.path.dirname(__file__), 'data.dat')
Beispiel #6
0
    assert True # No Exception
    c.delete()

def test_file_or_folder():
    f = FS.file_or_folder(__file__)
    assert isinstance(f, File)
    f = FS.file_or_folder(File(__file__).parent)
    assert isinstance(f, Folder)

DATA_ROOT = File(__file__).parent.child_folder('data')
TEMPLATE_ROOT = File(__file__).parent.child_folder('templates')
JINJA2 = TEMPLATE_ROOT.child_folder('jinja2')
HELPERS = File(JINJA2.child('helpers.html'))
INDEX = File(JINJA2.child('index.html'))
LAYOUT = File(JINJA2.child('layout.html'))
LOGO = File(TEMPLATE_ROOT.child('../../../resources/hyde-logo.png'))
XML = File(TEMPLATE_ROOT.child('../sites/test_jinja/content/crossdomain.xml'))

def test_ancestors():
    depth = 0
    next = JINJA2
    for folder in INDEX.ancestors():
        assert folder == next
        depth += 1
        next = folder.parent
    assert depth == len(JINJA2.path.split(os.sep))

def test_ancestors_stop():
    depth = 0
    next = JINJA2
    for folder in INDEX.ancestors(stop=TEMPLATE_ROOT.parent):
Beispiel #7
0
def test_child():
    p = File(__file__).parent
    c = p.child('data.dat')
    assert c == os.path.join(os.path.dirname(__file__), 'data.dat')
Beispiel #8
0

def test_file_or_folder():
    f = FS.file_or_folder(__file__)
    assert isinstance(f, File)
    f = FS.file_or_folder(File(__file__).parent)
    assert isinstance(f, Folder)


DATA_ROOT = File(__file__).parent.child_folder('data')
TEMPLATE_ROOT = File(__file__).parent.child_folder('templates')
JINJA2 = TEMPLATE_ROOT.child_folder('jinja2')
HELPERS = File(JINJA2.child('helpers.html'))
INDEX = File(JINJA2.child('index.html'))
LAYOUT = File(JINJA2.child('layout.html'))
LOGO = File(TEMPLATE_ROOT.child('../../../resources/hyde-logo.png'))
XML = File(TEMPLATE_ROOT.child('../sites/test_jinja/content/crossdomain.xml'))


def test_ancestors():
    depth = 0
    next = JINJA2
    for folder in INDEX.ancestors():
        assert folder == next
        depth += 1
        next = folder.parent
    assert depth == len(JINJA2.path.split(os.sep))


def test_ancestors_stop():
    depth = 0
Beispiel #9
0
 def begin_site(self):
     for resource in self.site.content.walk_resources():
         if resource.source_file.name == "rjs.conf":
             new_name = "app.js"
             target_folder = File(resource.relative_deploy_path).parent
             resource.relative_deploy_path = target_folder.child(new_name)