def static_page(): """ Render the administrative static page """ user_db = UserDB() role_db = RoleDB() event_log = EventLog() icebox = Icebox() if current_user.is_authenticated() and current_user.is_active(): is_admin = user_db.in_group(current_user, mainApp.config['ADMIN_GROUP']) all_activities = set() for m in role_db.get_roles(current_user): acts = role_db.get_activities(m.role_id) for act in acts: if acts[act]: all_activities.add(act) can_admin_static = 'make_static' in all_activities can_admin_static_now = 'make_static_now' in all_activities if is_admin or can_admin_static: if request.method == 'POST': if 'sched_rebuild' in request.form: event_log.add('rebuild_static', current_user.id) flash(_('Full site rebuild scheduled.')) elif 'incr_build' in request.form: icebox.generate_pages() flash(_('New/updated pages generated.')) elif 'rebuild_now' in request.form: if can_admin_static_now: icebox.generate_pages(True) flash(_('Full site rebuilt')) else: flash(_('Not authorized for full site rebuild', 'error')) return render_template('admin_static.html', state=get_state(), can_admin_static=can_admin_static, can_admin_static_now=can_admin_static_now, title=_('Administrate Static Site'), sched_rebuild_text=_('Schedule a full site rebuild'), sched_rebuild_button=_('Schedule'), incr_build_text=_('Perform an incremental build'), incr_build_button=_('Incremental'), rebuild_now_text=_('Perform a full rebuild now'), rebuild_now_button=_('Rebuild')) else: return _not_auth() else: return _not_auth()
""" Should be run from cron, at whatever interval you deem necessary """ from noink.icebox import Icebox i = Icebox() i.generate_pages()
print("Dropping an entry due to some entryDB problem (likely duplicate URL") print("because of random URL generation- Should be safe to ignore)\n") pass # stupid, but for our tests we don't care we just may get duplicate URLs def __del__(self): del(self.testMain) def run(self, debug): print("mainApp.jinja_env") print("-----------------") print("\nmainApp.jinja_loader") print("___________________") print("\n%s" % mainApp.jinja_loader.searchpath) mainApp.run(host="0.0.0.0", debug=debug) if __name__ == '__main__': parser = ArgumentParser(description='Simple, manual noink test') parser.add_argument('-f', help='Freeze the site and output static', action='store_true') parser.add_argument('-a', help='Generate all site', action='store_true') args = parser.parse_args() se = SimpleEntries() if args.f: icebox = Icebox() icebox.generate_pages() elif args.a: icebox = Icebox() icebox.generate_pages(True) else: se.run(True)