Skip to content

Commit

Permalink
move site init outside of main()
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 6, 2015
1 parent ee3cbc2 commit 2786ad7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
60 changes: 32 additions & 28 deletions COMET/__init__.py
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion COMET/templates/mako/comet_users_edit.tmpl
Expand Up @@ -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">
Expand Down

0 comments on commit 2786ad7

Please sign in to comment.