def get_article(category, article): cache_dir = app._config['henet']['cache_dir'] cat_path = dict(app.vars['categories'])[category]['path'] article_path = os.path.join(cat_path, article) article = parse_article(article_path, cache_dir, cat_path) return {'article': article, 'category': category, 'now': datetime.datetime.now(), 'csrf_token': request.csrf_token, 'filename': os.path.split(article_path)[-1]}
def post_page(page, article): data = dict(request.POST.decode()) cache_dir = app._config['henet']['cache_dir'] page_path = dict(app.vars['pages'])[page]['path'] article_path = os.path.join(page_path, article) article = parse_article(article_path, cache_dir, page_path) # XXX all this update crap should be in a Document() class if 'title' in data: article['title'] = data['title'] if 'content' in data: article['body'] = data['content'] if 'date' in data: article.set_metadata('date', data['date']) with open(article_path, 'w') as f: f.write(article.render().encode('utf8')) emit(EVENT_CHANGED_CONTENT, article_path=article_path) redirect('/page/%s/%s' % (page, article['filename']))
def post_article(category, article): data = dict(request.POST.decode()) cache_dir = app._config['henet']['cache_dir'] cat_path = dict(app.vars['categories'])[category]['path'] article_path = os.path.join(cat_path, article) article = parse_article(article_path, cache_dir, cat_path) # XXX all this update crap should be in a Document() class if 'title' in data: article['title'] = data['title'] if 'content' in data: article['body'] = data['content'] for meta in ('location', 'date', 'eventdate'): if meta in data: article.set_metadata(meta, data[meta]) with open(article_path, 'w') as f: f.write(article.render().encode('utf8')) emit(EVENT_CHANGED_CONTENT, article_path=article_path) redirect('/category/%s/%s' % (category, article['filename']))