Example #1
0
babel = Babel(app,default_domain=website.translation.messages_domain)

app.jinja_env.filters['markdown_docs'] = website.cms.markdown_docs
app.jinja_env.filters['markdown_blog'] = website.cms.markdown_blog
app.jinja_env.globals['gettext_parts'] = website.translation.gettext_parts
app.jinja_env.globals['gettext_docs'] = website.translation.gettext_docs

@babel.localeselector
def get_locale():
	lang_code = getattr(g,'lang_code',None)
	if lang_code is None:
		#the four most popular languages from the website
		lang_code = request.accept_languages.best_match(website.translation.languages,'en')
	return lang_code

rebuild_index(app)

@app.route('/')
def index():
	g.lang_code = get_locale()
	return redirect(url_for('main.index'))

@app.errorhandler(404)
def error_404(e):
	g.lang_code = get_locale()
	return render_template('error.html',
		page={'title' : 'Page not found'},
		title=gettext('Page not found (404)'),
		message=gettext('The page you are looking for does not exist. Maybe you made a mistake while typing the URL')
	), 404
Example #2
0
        usage()
    
    with open(path) as o:
        data = json.load(o)
    
    for node in data:
        redis.set( 'n:' + node['slug'], json.dumps(node))
    
    print "Loadded data from %s" % path

elif command == 'fixdb':
    import wiki, search
    types = wiki.get_types()
    for k, v in types.items():
        if k == 'type':
            continue
        try:
            wiki.put_type(k, v)
        except wiki.FormError, e:
            print e.field
    search.rebuild_index()
    wiki.rebuild_nodes()
    print "Wiki Rebuilt."

elif command == 'flushdb':
    redis.flushdb()

else:
    usage()