예제 #1
0
def serve(port, root=None, debug=None, browser=None):
    from neorg.web import app, update_system_info, update_search_index
    from neorg.config import load_config
    from neorg.wiki import setup_wiki
    load_config(app, dirpath=root)
    if debug is not None:
        app.config['DEBUG'] = debug
    update_search_index()
    update_system_info()
    if browser:
        from threading import Timer
        from webbrowser import open_new_tab
        Timer(1, open_new_tab, args=['http://localhost:%d' % port]).start()
    setup_wiki()
    app.run(port=port)
예제 #2
0
파일: commands.py 프로젝트: tkf/neorg
def serve(port, root=None, debug=None, browser=None):
    from neorg.web import app, update_system_info, update_search_index
    from neorg.config import load_config
    from neorg.wiki import setup_wiki
    load_config(app, dirpath=root)
    if debug is not None:
        app.config['DEBUG'] = debug
    update_search_index()
    update_system_info()
    if browser:
        from threading import Timer
        from webbrowser import open_new_tab
        Timer(1, open_new_tab,
              args=['http://localhost:%d' % port]).start()
    setup_wiki()
    app.run(port=port)
예제 #3
0
파일: test_web.py 프로젝트: tkf/neorg
def setup_app():
    web.app.config.from_object(DefaultConfig)
    (db_fd, web.app.config['DATABASE']) = tempfile.mkstemp(prefix=TMP_PREFIX)
    dirpath = tempfile.mkdtemp(prefix=TMP_PREFIX)  # = NEORG_ROOT
    set_config(web.app.config, dirpath)
    os.mkdir(web.app.config['NEORG_DIR'])
    web.app.config['SECRET_KEY'] = 'key for testing'
    app = web.app.test_client()
    web.init_db()
    web.update_search_index()

    from neorg.wiki import setup_wiki, gene_html
    setup_wiki()

    def gene_html_with_encode(*args, **kwds):
        return gene_html(*args, **kwds).encode('utf-8')

    return (app, db_fd, gene_html_with_encode)
예제 #4
0
파일: test_web.py 프로젝트: tkf/neorg
def setup_app():
    web.app.config.from_object(DefaultConfig)
    (db_fd, web.app.config['DATABASE']) = tempfile.mkstemp(prefix=TMP_PREFIX)
    dirpath = tempfile.mkdtemp(prefix=TMP_PREFIX)  # = NEORG_ROOT
    set_config(web.app.config, dirpath)
    os.mkdir(web.app.config['NEORG_DIR'])
    web.app.config['SECRET_KEY'] = 'key for testing'
    app = web.app.test_client()
    web.init_db()
    web.update_search_index()

    from neorg.wiki import setup_wiki, gene_html
    setup_wiki()

    def gene_html_with_encode(*args, **kwds):
        return gene_html(*args, **kwds).encode('utf-8')

    return (app, db_fd, gene_html_with_encode)