def fetch_article_by_repofile(self, repofile): """Fetch single article info by repofile (path starting from root of repository). Returns None if no article exists with that name. """ filename = os.path.join(self.root_dir, repofile) fullname = self._file2name(filename) if not self.exists(fullname): raise ArticleNotFoundError(fullname) article = make_article(fullname, filename, self.meta_types) return call_plugins_arg('on_article_fetch', article)
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)
def fetch_article(self, fullname): """Fetches an article, calling all the plugins""" article = self._fetch_by_fullname(fullname) return call_plugins_arg('on_article_fetch', article)
def fetch_article_by_info(self, article_info): """Fetches an article, calling all the plugins""" article = self._fetch_by_fullname(article_info.fullname) article.info = article_info return call_plugins_arg('on_article_fetch', article)