Esempio n. 1
0
def preBuild(site):
    global CLOUDCASTS
    
    cloudcast_paths = CLOUDCASTS.copy()
    
    json_pages = filter(lambda x: x.endswith('.json'), fileList(site.paths['pages']))
    
    for key in cloudcast_paths.keys():
        key_path = os.sep + key + os.sep
        cloudcast_paths[key] = filter(lambda x: key_path in x, json_pages)

    template = get_template('mix.html')
    
    for type, mixes in cloudcast_paths.items():
        for mix in mixes:
            page = Page(site, mix)
            context = Context(page.context())
            with open(mix, 'r') as input_file:
                context.update(json.load(input_file))
                CLOUDCASTS[type].append(context)

            path = mix.replace('.json', '.html')
            with codecs.open(path, mode='w', encoding='utf-8') as output_file:
                output_file.write(template.render(context))
                CLEANUP.append(path)
                
    random.shuffle(CLOUDCASTS['mix'])
Esempio n. 2
0
def postBuild(site):

    for root, dirs, files in os.walk(site.page_path, topdown=False):
        for name in files:
            if name == '.htaccess':
                full_path = os.path.join(root, name)
                path = os.path.relpath(full_path, site.page_path)
                page = Page(site, path)
                page.build()

    for root, dirs, files in os.walk(site.static_path, topdown=False):
        for name in files:
            if name == '.htaccess':
                full_path = os.path.join(root, name)
                path = os.path.relpath(full_path, site.static_path)
                static = Static(site, path)
                static.build()
Esempio n. 3
0
    def pages(self):
        """
        List of pages.
        """

        if not hasattr(self, "_page_cache"):
            self._page_cache = {}

        pages = []

        for path in fileList(self.page_path, relative=True):

            if path.endswith("~"):
                continue

            if path not in self._page_cache:
                logger.debug("Found page: %s", path)
                self._page_cache[path] = Page(self, path)

            pages.append(self._page_cache[path])

        return pages