def begin_site(self): """ Configuration example --------------------- #yaml suffix: - target_extension: - markdown - md output_extension: html - target_extension: - rst - md output_extension: html """ config = self.site.config if not hasattr(config, 'suffix'): return suffix_config = attrgetter('suffix')(config) for resource in self.site.content.walk_resources(): for conf in suffix_config: conf = conf.to_dict() target = conf.get('target_extension', []) output = conf.get('output_extension', 'html') if resource.source_file.kind in target: new_name = resource.source_file.name_without_extension + "." + output target_folder = File(resource.relative_deploy_path).parent resource.relative_deploy_path = target_folder.child(new_name)
def begin_site(self): """ Configuration example --------------------- #yaml suffix: - target_extension: - markdown - md output_extension: html - target_extension: - rst - md output_extension: html """ config = self.site.config if not hasattr(config, 'suffix'): return suffix_config = attrgetter('suffix')(config) for resource in self.site.content.walk_resources(): for conf in suffix_config: conf = conf.to_dict() target = conf.get('target_extension', []) output = conf.get('output_extension', 'html') if resource.source_file.kind in target: new_name = resource.source_file.name_without_extension if output: new_name += "." + output target_folder = File(resource.relative_deploy_path).parent resource.relative_deploy_path = target_folder.child( new_name)
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': 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)
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 self._should_parse_resource(resource): 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)
def begin_site(self): """ Find all the md files and set their relative deploy path. """ for resource in self.site.content.walk_resources(): if resource.source_file.kind == 'md': 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) md_hdr = self.__resource_meta__(resource, resource.source_file.read_all()) # Have to call metaplugin to update metadata if hasattr(resource, 'meta'): resource.meta.update(md_hdr)
def begin_site(self): """ Find all the sassycss files and set their relative deploy path. """ self.scss.STATIC_URL = self.site.content_url('/') self.scss.STATIC_ROOT = self.site.config.content_root_path.path self.scss.ASSETS_URL = self.site.media_url('/') self.scss.ASSETS_ROOT = self.site.config.deploy_root_path.child( self.site.config.media_root) for resource in self.site.content.walk_resources(): if self._should_parse_resource(resource): 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)
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
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)
def test_child(): p = File(__file__).parent c = p.child("data.dat") assert c == os.path.join(os.path.dirname(__file__), "data.dat")
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") ROOT_FOLDER = File(__file__).parent.child_folder("arootfolder") AFOLDER = ROOT_FOLDER.child_folder("afolder") HELPERS = File(AFOLDER.child("helpers.html")) INDEX = File(AFOLDER.child("index.html")) LAYOUT = File(AFOLDER.child("layout.html")) LOGO = File(ROOT_FOLDER.child("../logo.png")) XML = File(ROOT_FOLDER.child("../atextfile.xml")) def test_ancestors(): depth = 0 next = AFOLDER for folder in INDEX.ancestors(): assert folder == next depth += 1 next = folder.parent assert depth == len(AFOLDER.path.split(os.sep)) def test_ancestors_stop(): depth = 0
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') ROOT_FOLDER = File(__file__).parent.child_folder('arootfolder') AFOLDER = ROOT_FOLDER.child_folder('afolder') HELPERS = File(AFOLDER.child('helpers.html')) INDEX = File(AFOLDER.child('index.html')) LAYOUT = File(AFOLDER.child('layout.html')) LOGO = File(ROOT_FOLDER.child('../logo.png')) XML = File(ROOT_FOLDER.child('../atextfile.xml')) def test_ancestors(): depth = 0 next = AFOLDER for folder in INDEX.ancestors(): assert folder == next depth += 1 next = folder.parent assert depth == len(AFOLDER.path.split(os.sep)) def test_ancestors_stop(): depth = 0