def main(init_db=False, insert_defaults=False, debug=False): if init_db: db.connect() db.create_tables([Page, PageHistory, Option]) if insert_defaults: Option.set_value('default_lang', 'ru') Option.set_value('main_page', 'main') Page.create(lang='ru', title='default_main', path='main', content='Welcome to Wikitone') app.run(debug=debug)
def show_page(lang, path=''): if len(lang) != 2 and lang not in ('ru', 'en'): path = lang + '/' + path lang = Option.get('default_lang', 'en') return redirect(url_for('show_path', lang=lang, path=path)) try: page = Page.get(Page.path == path, Page.lang == lang) return render_template('page.html', page=page, title=page.title, content=page.content_html) except DoesNotExist as e: app.logger.debug('Page "%s" does not exist. %s', path, e.message) return redirect(url_for('edit_page', lang=lang, path=path))
def make_main(lang, path): Option.set_value('main_page', path) return redirect(url_for('show_page', path=path, lang=lang))
def home(): path = Option.get_value('main_page', 'main') lang = Option.get_value('default_lang', 'ru') return redirect(url_for('show_page', lang=lang, path=path))
def options(): return render_template('options.html', options=Option.select())