Esempio n. 1
0
def wiki(request, tmp_path):
    config = hatta.WikiConfig(
        pages_path=os.path.join(tmp_path, 'pages'),
        cache_path=os.path.join(tmp_path, 'cache'),
    )
    request.addfinalizer(lambda: clear_directory(tmp_path))
    return hatta.Wiki(config)
Esempio n. 2
0
def pytest_funcarg__wiki(request):
    basedir = str(request.config.ensuretemp('repo'))
    config = hatta.WikiConfig(
        pages_path=os.path.join(basedir, 'pages'),
        cache_path=os.path.join(basedir, 'cache'),
    )
    request.addfinalizer(lambda: clear_directory(basedir))
    return hatta.Wiki(config)
Esempio n. 3
0
def main(args):
    hatta_config = hatta.WikiConfig()
    hatta_config.parse_files(files=[args.input_config])
    hatta_config.set('read_only', True)
    wiki = hatta.Wiki(hatta_config)
    # list of all page names
    page_names = list(wiki.storage.all_pages())
    mkdir_p(args.output_dir)
    print('Converting %d wiki entries' % len(page_names))
    for page_name in page_names:
        convert_page(page_name,
                     wiki=wiki,
                     out_dir=args.output_dir,
                     file_prefix=args.file_prefix,
                     files_in_one_dir=args.files_in_one_dir,
                     add_link_ext=args.add_link_ext)
    print('Done!')
Esempio n. 4
0
def req(request, tmp_path):
    request.addfinalizer(lambda: clear_directory(tmp_path))
    config = hatta.WikiConfig(
        pages_path=os.path.join(tmp_path, 'pages'),
        cache_path=os.path.join(tmp_path, 'cache'),
        default_style="...",
    )
    wiki = hatta.Wiki(config)
    environ = {
        'SERVER_NAME': 'hatta',
        'wsgi.url_scheme': 'http',
        'SERVER_PORT': '80',
        'REQUEST_METHOD': 'GET',
        'PATH_INFO': '/',
        'SCRIPT_NAME': '',
    }
    adapter = wiki.url_map.bind_to_environ(environ)
    return wiki, hatta.WikiRequest(wiki, adapter, environ)
Esempio n. 5
0
    def load_from_config(self, conf_file):
        config = hatta.WikiConfig()
        config.parse_files([conf_file])
        config.sanitize()
        wiki = hatta.Wiki(config, site_id=conf_file)

        # file name is the domain name _path
        # if the path is set, use the dispatcher middleware
        splitname = os.path.basename(os.path.splitext(conf_file)[0]).split(
            '_', 1)
        domain_name = splitname[0]
        if len(splitname) == 2:
            self.apps.setdefault(
                domain_name,
                DispatcherMiddleware(self.default_application, None)).mounts[
                    '/' + splitname[1].replace('_', '/')] = wiki.application
        else:
            self.apps[domain_name] = wiki.application
Esempio n. 6
0
def pytest_funcarg__req(request):
    basedir = str(request.config.ensuretemp('repo'))
    request.addfinalizer(lambda: clear_directory(basedir))
    config = hatta.WikiConfig(
        pages_path=os.path.join(basedir, 'pages'),
        cache_path=os.path.join(basedir, 'cache'),
        default_style="...",
    )
    wiki = hatta.Wiki(config)
    environ = {
        'SERVER_NAME': 'hatta',
        'wsgi.url_scheme': 'http',
        'SERVER_PORT': '80',
        'REQUEST_METHOD': 'GET',
        'PATH_INFO': '/',
        'SCRIPT_NAME': '',
    }
    adapter = wiki.url_map.bind_to_environ(environ)
    return wiki, hatta.WikiRequest(wiki, adapter, environ)
Esempio n. 7
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
An auto-reloading standalone wiki server, useful for development.
"""

import hatta
import werkzeug
from werkzeug.middleware.profiler import ProfilerMiddleware

if __name__ == "__main__":
    config = hatta.WikiConfig()
    config.parse_args()
    #    config.parse_files()
    wiki = hatta.Wiki(config)

    application = wiki.application

    # application = ProfilerMiddleware(application)

    host = config.get('interface', 'localhost')
    port = int(config.get('port', 8080))
    werkzeug.run_simple(host, port, application, use_reloader=True)