Exemplo n.º 1
0
def _post_and_save(post, networks, link):
    metadata = post_social(post, networks, link)
    now = datetime.datetime.utcnow()
    metadata.update({'create_time': now.isoformat(),
                     'modified_time': now.isoformat()})

    tags = _extract_tags(post)
    if tags:
        metadata['tags'] = ','.join(tags)

    root_dir = g.site.root_dir
    repo_category = os.path.join(content_folder(),
                                 cfg('YAWT_MICROPOST_CATEGORY'))
    ensure_path(os.path.join(root_dir, repo_category))

    slug = "{0:02d}{1:02d}{2:02d}{3:02d}{4:02d}{5:02d}"
    slug = slug.format(now.year, now.month, now.day, now.hour, now.minute, now.second)
    repo_file = os.path.join(repo_category, slug)
    repo_file += "." + cfg('YAWT_MICROPOST_EXTENSION')
    write_post(metadata, post, os.path.join(root_dir, repo_file))
    return repo_file
Exemplo n.º 2
0
    def initialize(self):
        """Set up an empty blog folder"""
        if os.path.exists(self.root_dir):
            raise SiteExistsError(self.root_dir)

        ensure_path(self._content_root())
        ensure_path(self._draft_root())
        ensure_path(self._template_root())
        config_content = '# put configuration here'
        save_file(os.path.join(self.root_dir, 'config.py'), config_content)
        template_contents = yawt.default_templates.default_article_template
        self._save_template('article', 'html', template_contents)
        template_404_contents = yawt.default_templates.default_404_template
        self._save_template('404', 'html', template_404_contents)
        files = ['config.py', 'article.html', '404.html']
        return call_plugins_arg('on_new_site', files)