Skip to content
Permalink
Browse files
move site init outside of main()
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 6, 2015
1 parent ee3cbc2 commit 2786ad7043410bb786d791d2f0e558ff7293414d
Showing with 33 additions and 29 deletions.
  1. +32 −28 COMET/__init__.py
  2. +1 −1 COMET/templates/mako/comet_users_edit.tmpl
@@ -462,39 +462,43 @@ def acp_users_reload():
read_users()
return redirect('/users')

nikola.__main__._RETURN_DOITNIKOLA = True
DN = nikola.__main__.main([])
DN.sub_cmds = DN.get_commands()
_site = DN.nikola
init_site()

_site.template_hooks['menu_alt'].append(generate_menu_alt)
PORT = 8001

site = _site.config['SITE_URL']
_site.config['SITE_URL'] = 'http://localhost:{0}/'.format(PORT)
_site.config['BASE_URL'] = 'http://localhost:{0}/'.format(PORT)
_site.GLOBAL_CONTEXT['blog_url'] = 'http://localhost:{0}/'.format(PORT)
_site.config['NAVIGATION_LINKS'] = {'en': ((site, 'Back to {0}'.format(_site.GLOBAL_CONTEXT['blog_title']('en'))),)}
_site.GLOBAL_CONTEXT['navigation_links'] = {'en':((site, 'Back to {0}'.format(_site.GLOBAL_CONTEXT['blog_title']('en'))),)}
_site.config['SOCIAL_BUTTONS'] = ''
_site.GLOBAL_CONTEXT['social_buttons_code'] = lambda _: ''
TITLE = _site.GLOBAL_CONTEXT['blog_title']('en') + ' Administration'
_site.config['BLOG_TITLE'] = lambda _: TITLE
_site.GLOBAL_CONTEXT['blog_title'] = lambda _: TITLE
_site.GLOBAL_CONTEXT['lang'] = 'en'
app.secret_key = _site.config['COMET_SECRET_KEY']

mod_dir = os.path.dirname(__file__)
tmpl_dir = os.path.join(
mod_dir, 'templates', _site.template_system.name
)
if os.path.isdir(tmpl_dir):
# Inject tmpl_dir low in the theme chain
_site.template_system.inject_directory(tmpl_dir)

def main():
global _site, app
nikola.__main__._RETURN_DOITNIKOLA = True
DN = nikola.__main__.main([])
DN.sub_cmds = DN.get_commands()
_site = DN.nikola
init_site()
global _site
port = 8001

_site.template_hooks['menu_alt'].append(generate_menu_alt)

site = _site.config['SITE_URL']
_site.config['SITE_URL'] = 'http://localhost:{0}/'.format(port)
_site.config['BASE_URL'] = 'http://localhost:{0}/'.format(port)
_site.GLOBAL_CONTEXT['blog_url'] = 'http://localhost:{0}/'.format(port)
_site.config['NAVIGATION_LINKS'] = {'en': ((site, 'Back to {0}'.format(_site.GLOBAL_CONTEXT['blog_title']('en'))),)}
_site.GLOBAL_CONTEXT['navigation_links'] = {'en':((site, 'Back to {0}'.format(_site.GLOBAL_CONTEXT['blog_title']('en'))),)}
_site.config['SOCIAL_BUTTONS'] = ''
_site.GLOBAL_CONTEXT['social_buttons_code'] = lambda _: ''
TITLE = _site.GLOBAL_CONTEXT['blog_title']('en') + ' Administration'
_site.config['BLOG_TITLE'] = lambda _: TITLE
_site.GLOBAL_CONTEXT['blog_title'] = lambda _: TITLE
_site.GLOBAL_CONTEXT['lang'] = 'en'
app.secret_key = _site.config['COMET_SECRET_KEY']

mod_dir = os.path.dirname(__file__)
tmpl_dir = os.path.join(
mod_dir, 'templates', _site.template_system.name
)
if os.path.isdir(tmpl_dir):
# Inject tmpl_dir low in the theme chain
_site.template_system.inject_directory(tmpl_dir)

#if options and options.get('browser'):
#webbrowser.open('http://localhost:{0}'.format(port))

@@ -23,7 +23,7 @@
<input name="uid" type="hidden" value="${user.uid}">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Real name</label>
<div class="col-sm-10"><input class="form-control" id="realname" name="realname" value="${user.realname}" @placeholder="Real name" required></div>
<div class="col-sm-10"><input class="form-control" id="realname" name="realname" value="${user.realname}" placeholder="Real name" required></div>
</div>
% if user.password:
<div class="form-group">

0 comments on commit 2786ad7

Please sign in to comment.