def init(config): merge_config(config, twmconfig) if 'selector' in config: config['selector'].add('/', GET=home) config['selector'].add('/manifestos', GET=manifestos) config['selector'].add('/manifestos/{manifesto_name:segment}', GET=manifestor) config['selector'].add( '/manifestos/{manifesto_name:segment}/{definition:segment}', GET=definition) config['wikitext.default_renderer'] = ( 'tiddlywebplugins.manifestopheles.contextify') @make_command() def manifest(args): """Make a new manifesto. <manifesto name> <dictionary prefix>""" store = get_store(config) try: recipe_name = args[0] bag_name = args[1] + '-dictionary' except IndexError: usage("manifesto name and dictionary prefix required") # add policy info later ensure_bag(recipe_name, store) ensure_bag(bag_name, store) recipe = Recipe(recipe_name) recipe.set_recipe([ (bag_name, ''), (recipe_name, '')]) recipe = store.put(recipe)
def _initialize_app(tmpdir): # XXX: side-effecty and inscrutable instance_dir = os.path.join(tmpdir, 'instance') spawn(instance_dir, init_config, instance) old_cwd = os.getcwd() os.chdir(instance_dir) # force loading of instance's `tiddlywebconfig.py` while old_cwd in sys.path: sys.path.remove(old_cwd) sys.path.insert(0, os.getcwd()) merge_config(CONFIG, {}, reconfig=True) # XXX: should not be necessary!? CONFIG['server_host'] = { 'scheme': 'http', 'host': 'example.org', 'port': '8001', } # TODO: test with server_prefix # add symlink to templates -- XXX: hacky, should not be necessary!? templates_path = instance.__file__.split(os.path.sep)[:-2] + ['templates'] os.symlink(os.path.sep.join(templates_path), 'templates') httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('example.org', 8001, load_app)
def init(config): """ init function for tiddlywebpages. Set URLs define serializers """ merge_config(config, twp_config) #provide a way to allow people to refresh their URLs config['selector'].add('/tiddlywebpages/refresh', GET=refresh) #get the store store = get_store(config) #set the default config info BAG_OF_TEMPLATES = config['tw_pages']['template_bag'] if 'config' in config['tw_pages']: register_config(config, store) for new_filter in config['tw_pages']['filters']: _temp = __import__(new_filter, {}, {}, [new_filter]) TW_PAGES_FILTERS.append((new_filter, getattr(_temp, new_filter))) if 'config' in config['tw_pages']: register_config(config, store) register_templates(config, store)
def init(config): """ init function for tiddlywebpages. Set URLs define serializers """ merge_config(config, twp_config) # provide a way to allow people to refresh their URLs config["selector"].add("/tiddlywebpages/refresh", GET=refresh) # get the store store = get_store(config) # set the default config info BAG_OF_TEMPLATES = config["tw_pages"]["template_bag"] if "config" in config["tw_pages"]: register_config(config, store) for new_filter in config["tw_pages"]["filters"]: _temp = __import__(new_filter, {}, {}, [new_filter]) TW_PAGES_FILTERS.append((new_filter, getattr(_temp, new_filter))) if "config" in config["tw_pages"]: register_config(config, store) register_templates(config, store)
def init(config): merge_config(config, local_config) tiddlywebplugins.wikidata.magicuser.init(config) tiddlywebplugins.jsonp.init(config) if "selector" in config: tiddlywebplugins.logout.init(config) config["selector"].add("/pages/{template_file:segment}", GET=template_route) config["selector"].add("/test/{template_file:segment}", GET=test_template_route) config["selector"].add("/index.html", GET=index) config["selector"].add("/verify", POST=verify) config["selector"].add("/verify_simple", POST=verify_simple) config["selector"].add("/lib/fields.js", GET=get_fields_js) config["selector"].add("/env", GET=env) config["selector"].add("/register", POST=register) config["selector"].add("/_admin/createuser", GET=tier2_user_form, POST=create_tier2_user) config["selector"].add("/_admin/updateuser", GET=update_user_form, POST=update_user) config["selector"].add("/createuser", POST=create_tier1_user) replace_handler(config["selector"], "/", dict(GET=index)) remove_handler(config["selector"], "/recipes") remove_handler(config["selector"], "/recipes/{recipe_name}") remove_handler(config["selector"], "/recipes/{recipe_name}/tiddlers") remove_handler(config["selector"], "/bags") remove_handler(config["selector"], "/bags/{bag_name}") remove_handler(config["selector"], "/bags/{bag_name}/tiddlers")
def init(config): merge_config(config, local_config) tiddlywebplugins.wikidata.magicuser.init(config) tiddlywebplugins.jsonp.init(config) if 'selector' in config: tiddlywebplugins.logout.init(config) config['selector'].add('/pages/{template_file:segment}', GET=template_route) config['selector'].add('/test/{template_file:segment}', GET=test_template_route) config['selector'].add('/index.html', GET=index) config['selector'].add('/verify', POST=verify) config['selector'].add('/verify_simple', POST=verify_simple) config['selector'].add('/lib/fields.js', GET=get_fields_js) config['selector'].add('/env', GET=env) config['selector'].add('/register', POST=register) config['selector'].add('/_admin/createuser', GET=tier2_user_form, POST=create_tier2_user) config['selector'].add('/_admin/updateuser', GET=update_user_form, POST=update_user) config['selector'].add('/createuser', POST=create_tier1_user) replace_handler(config['selector'], '/', dict(GET=index)) remove_handler(config['selector'], '/recipes') remove_handler(config['selector'], '/recipes/{recipe_name}') remove_handler(config['selector'], '/recipes/{recipe_name}/tiddlers') remove_handler(config['selector'], '/bags') remove_handler(config['selector'], '/bags/{bag_name}') remove_handler(config['selector'], '/bags/{bag_name}/tiddlers')
def init(config): """ Update the standard config with tiddlywebplugins.lazy.config. """ from tiddlyweb.util import merge_config from tiddlywebplugins.lazy.config import config as lconfig merge_config(config, lconfig)
def init(config): import tiddlywebwiki import tiddlywebplugins.register import tiddlywebplugins.wimporter import tiddlywebplugins.logout import tiddlywebplugins.form merge_config(config, hoster_config) tiddlywebwiki.init(config) tiddlywebplugins.register.init(config) tiddlywebplugins.wimporter.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.form.init(config) merge_config(config, hoster_config) if 'selector' in config: remove_handler(config['selector'], '/{recipe_name:segment}') replace_handler(config['selector'], '/', dict(GET=front)) config['selector'].add('/help', GET=help_page) config['selector'].add('/login', GET=login) config['selector'].add('/uploader', GET=uploader) config['selector'].add('/formeditor', GET=get_tiddler_edit, POST=post_tiddler_edit) config['selector'].add('/addemail', POST=add_email) config['selector'].add('/follow', POST=add_friend) config['selector'].add('/members', GET=members_list) config['selector'].add('/bagfavor', POST=bag_favor) config['selector'].add('/recipefavor', POST=recipe_favor) config['selector'].add('/bagpolicy', POST=entity_policy) config['selector'].add('/recipepolicy', POST=entity_policy) config['selector'].add('/createrecipe', GET=get_createrecipe, POST=post_createrecipe) config['selector'].add('/createbag', GET=get_createbag, POST=post_createbag) config['selector'].add('/feedbag[.{format}]', GET=public_stuff) config['selector'].add('/home', GET=get_home) # THE FOLLOWING MUST COME LAST config['selector'].add('/{userpage:segment}', GET=user_page) new_serializer = [ 'tiddlywebplugins.hoster.serialization', 'text/html; charset=UTF-8' ] config['serializers']['text/html'] = new_serializer else: @make_command() def upstore(args): """Update the store structure.""" from tiddlywebplugins.hoster.instance import store_structure from tiddlywebplugins.instancer import Instance from tiddlyweb.config import config instance = Instance('.', config) instance._init_store(store_structure)
def init(config): import tiddlywebplugins.tagdex as tagdex tagdex.init(config) selector = config.get('selector') if selector: init_server(config, selector) merge_config(config, bfwconfig)
def test_merge_addition(): config = deepcopy(global_config) new_config = { 'extra': { 'stuff': ['one', 'two'], } } merge_config(config, new_config, reconfig=False) assert 'extra' in config assert 'stuff' in config['extra'] assert 'one' in config['extra']['stuff']
def test_merge_addition(): config = deepcopy(global_config) new_config = { 'extra': { 'stuff': ['one', 'two'], } } merge_config(config, new_config, reconfig=False) assert 'extra' in config assert 'stuff' in config['extra'] assert 'one' in config['extra']['stuff']
def init(config): import tiddlywebwiki import tiddlywebplugins.register import tiddlywebplugins.wimporter import tiddlywebplugins.logout import tiddlywebplugins.form merge_config(config, hoster_config) tiddlywebwiki.init(config) tiddlywebplugins.register.init(config) tiddlywebplugins.wimporter.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.form.init(config) merge_config(config, hoster_config) if 'selector' in config: remove_handler(config['selector'], '/{recipe_name:segment}') replace_handler(config['selector'], '/', dict(GET=front)) config['selector'].add('/help', GET=help_page) config['selector'].add('/login', GET=login) config['selector'].add('/uploader', GET=uploader) config['selector'].add('/formeditor', GET=get_tiddler_edit, POST=post_tiddler_edit) config['selector'].add('/addemail', POST=add_email) config['selector'].add('/follow', POST=add_friend) config['selector'].add('/members', GET=members_list) config['selector'].add('/bagfavor', POST=bag_favor) config['selector'].add('/recipefavor', POST=recipe_favor) config['selector'].add('/bagpolicy', POST=entity_policy) config['selector'].add('/recipepolicy', POST=entity_policy) config['selector'].add('/createrecipe', GET=get_createrecipe, POST=post_createrecipe) config['selector'].add('/createbag', GET=get_createbag, POST=post_createbag) config['selector'].add('/feedbag[.{format}]', GET=public_stuff) config['selector'].add('/home', GET=get_home) # THE FOLLOWING MUST COME LAST config['selector'].add('/{userpage:segment}', GET=user_page) new_serializer = ['tiddlywebplugins.hoster.serialization', 'text/html; charset=UTF-8'] config['serializers']['text/html'] = new_serializer else: @make_command() def upstore(args): """Update the store structure.""" from tiddlywebplugins.hoster.instance import store_structure from tiddlywebplugins.instancer import Instance from tiddlyweb.config import config instance = Instance('.', config) instance._init_store(store_structure)
def init(config): merge_config(config, tank_config, reconfig=True) make_validators() whoosh_init(config) links_init(config) policy_init(config) dispatcher_init(config) listener_init(config) if 'selector' in config: establish_web(config) # second time to ensure serializers are correct merge_config(config, tank_config, reconfig=True)
def init(config): merge_config(config, tank_config, reconfig=True) whoosh_init(config) links_init(config) policy_init(config) dispatcher_init(config) listener_init(config) if 'selector' in config: make_validators() establish_web(config) # second time to ensure serializers are correct merge_config(config, tank_config, reconfig=True)
def test_merge_addition_double_over_twc(): new_config = { 'extra': { 'show': ['three', 'four'], 'stuff': ['five', 'six'], } } merge_config(global_config, new_config) assert 'extra' in global_config assert 'stuff' in global_config['extra'] assert 'one' in global_config['extra']['stuff'] assert 'show' in global_config['extra'] assert 'three' in global_config['extra']['show']
def test_merge_addition_double_over_twc(): new_config = { 'extra': { 'show': ['three', 'four'], 'stuff': ['five', 'six'], } } merge_config(global_config, new_config) assert 'extra' in global_config assert 'stuff' in global_config['extra'] assert 'one' in global_config['extra']['stuff'] assert 'show' in global_config['extra'] assert 'three' in global_config['extra']['show']
def spawn(instance_path, init_config, instance_module): """ convenience wrapper for instance-creation scripts """ # extend module search path for access to local tiddlywebconfig.py sys.path.insert(0, os.getcwd()) from tiddlyweb.util import merge_config from tiddlyweb.config import config merge_config(config, init_config) instance = Instance(instance_path, config, instance_module.instance_config) instance.spawn(instance_module.store_structure) instance.update_store()
def _external_load(module, config): """ Load a module to adjust configuration. """ if module.endswith('.py'): path, module = os.path.split(module) module = module.replace('.py', '') sys.path.insert(0, path) imported_config = _import_module_config(module) sys.path.pop(0) else: imported_config = _import_module_config(module) merge_config(config, imported_config)
def init(config): import tiddlywebplugins.instancer merge_config(config, plugin_config) if 'selector' in config: establish_handlers(config) # XXX Dupe from tiddlywebwiki, should probably be in instancer... @make_command() def update(args): """Update all instance_tiddlers in the current instance.""" from tiddlywebplugins.instancer import Instance instance = Instance('.', config) instance.update_store()
def _external_load(module, config): """ Load a module to adjust configuration. """ if module.endswith('.py'): path, module = os.path.split(module) module = module.replace('.py', '') sys.path.insert(0, path) imported_config = _import_module_config(module) sys.path.pop(0) else: imported_config = _import_module_config(module) merge_config(config, imported_config)
def test_merge_sub_addition(): config = deepcopy(global_config) new_config = { 'serializers': { 'text/bar': ['bar', 'type'], } } merge_config(config, new_config, reconfig=False) assert 'text/bar' in config['serializers'] assert config['serializers']['text/bar'] == ['bar', 'type'] assert 'text/html' in config['serializers'] assert 'html' in config['serializers']['text/html'] assert 'default_serializer' in config assert config['default_serializer'] == 'text/html'
def test_merge_sub_replace(): config = deepcopy(global_config) new_config = { 'serializers': { 'text/html': ['bar', 'type'], } } merge_config(config, new_config, reconfig=False) assert 'text/html' in config['serializers'] assert config['serializers']['text/html'] == ['bar', 'type'] assert 'application/json' in config['serializers'] assert 'json' in config['serializers']['application/json'] assert 'default_serializer' in config assert config['default_serializer'] == 'text/html'
def test_merge_sub_addition(): config = deepcopy(global_config) new_config = { 'serializers': { 'text/bar': ['bar', 'type'], } } merge_config(config, new_config, reconfig=False) assert 'text/bar' in config['serializers'] assert config['serializers']['text/bar'] == ['bar', 'type'] assert 'text/html' in config['serializers'] assert 'html' in config['serializers']['text/html'] assert 'default_serializer' in config assert config['default_serializer'] == 'text/html'
def test_merge_sub_replace(): config = deepcopy(global_config) new_config = { 'serializers': { 'text/html': ['bar', 'type'], } } merge_config(config, new_config, reconfig=False) assert 'text/html' in config['serializers'] assert config['serializers']['text/html'] == ['bar', 'type'] assert 'application/json' in config['serializers'] assert 'json' in config['serializers']['application/json'] assert 'default_serializer' in config assert config['default_serializer'] == 'text/html'
def init(config): """ merge custom config with config """ import tiddlywebwiki tiddlywebwiki.init(config) import tiddlywebplugins.virtualhosting # calling init on virtualhosting not required merge_config(config, space_config) # XXX: we probably don't wanna do this here if 'selector' in config: replace_handler(config['selector'], '/', dict(GET=home)) config['selector'].add('/dashboard[/]', GET=dashboard) config['selector'].add('/spaces[/]', POST=post_space_handler) config['selector'].add('/users', GET=list_users, POST=post_user) config['selector'].add('/users/{usersign}', GET=get_user, PUT=put_user)
def _external_load(args, config): """ Load a module from by request of the command line. """ module = args[2] args = [args[0]] + args[3:] if module.endswith('.py'): path, module = os.path.split(module) module = module.replace('.py', '') sys.path.insert(0, path) imported_config = _import_module_config(module) sys.path.pop(0) else: imported_config = _import_module_config(module) merge_config(config, imported_config) return args
def _external_load(args, config): """ Load a module from ``args[2]`` to adjust configuration. """ module = args[2] args = [args[0]] + args[3:] if module.endswith('.py'): path, module = os.path.split(module) module = module.replace('.py', '') sys.path.insert(0, path) imported_config = _import_module_config(module) sys.path.pop(0) else: imported_config = _import_module_config(module) merge_config(config, imported_config) return args
def _external_load(args, config): """ Load a module from by request of the command line. """ module = args[2] args = [args[0]] + args[3:] if module.endswith('.py'): path, module = os.path.split(module) module = module.replace('.py', '') sys.path.insert(0, path) imported_config = _import_module_config(module) sys.path.pop(0) else: imported_config = _import_module_config(module) merge_config(config, imported_config) return args
def init(config): # These imports must be in init otherwise getting # the version number causes cyclic imports to happen. import tiddlywebwiki.manage import tiddlywebplugins.status import tiddlywebplugins.atom import tiddlywebplugins.differ import tiddlywebplugins.twimport import tiddlywebplugins.console from tiddlyweb.util import merge_config from tiddlywebwiki.config import config as twwconfig merge_config(config, twwconfig) tiddlywebwiki.manage.init(config) tiddlywebplugins.status.init(config) tiddlywebplugins.atom.init(config) tiddlywebplugins.differ.init(config) tiddlywebplugins.twimport.init(config) tiddlywebplugins.console.init(config)
def init(config): # These imports must be in init otherwise getting # the version number causes cyclic imports to happen. import tiddlywebplugins.imaker import tiddlywebplugins.status import tiddlywebplugins.atom import tiddlywebplugins.differ import tiddlywebplugins.console from tiddlyweb.util import merge_config from tiddlywebwiki.config import config as twwconfig merge_config(config, twwconfig) tiddlywebplugins.imaker.init(config) tiddlywebplugins.status.init(config) tiddlywebplugins.atom.init(config) tiddlywebplugins.differ.init(config) tiddlywebplugins.console.init(config) if 'selector' in config: if config.get('tiddlywebwiki.friendlywiki', True): config['selector'].add('/{recipe_name:segment}', GET=friendlywiki)
def test_merge_addition_double_over_no_twc(): config = deepcopy(global_config) custom_config = { 'nextra': { 'show': ['three', 'four'], 'stuff': ['five', 'six'], } } plugin_config = { 'nextra': { 'show': ['seven', 'eight'] } } merge_config(config, custom_config, reconfig=False) assert 'nextra' in config assert 'stuff' in config['nextra'] assert 'five' in config['nextra']['stuff'] assert 'show' in config['nextra'] assert 'three' in config['nextra']['show'] merge_config(config, plugin_config, reconfig=False) assert 'nextra' in config assert 'stuff' in config['nextra'] assert 'five' in config['nextra']['stuff'] assert 'show' in config['nextra'] assert 'seven' in config['nextra']['show'] merge_config(config, custom_config, reconfig=False) assert 'show' in config['nextra'] assert 'seven' not in config['nextra']['show']
def test_merge_addition_double_over_no_twc(): config = deepcopy(global_config) custom_config = { 'nextra': { 'show': ['three', 'four'], 'stuff': ['five', 'six'], } } plugin_config = { 'nextra': { 'show': ['seven', 'eight'] } } merge_config(config, custom_config, reconfig=False) assert 'nextra' in config assert 'stuff' in config['nextra'] assert 'five' in config['nextra']['stuff'] assert 'show' in config['nextra'] assert 'three' in config['nextra']['show'] merge_config(config, plugin_config, reconfig=False) assert 'nextra' in config assert 'stuff' in config['nextra'] assert 'five' in config['nextra']['stuff'] assert 'show' in config['nextra'] assert 'seven' in config['nextra']['show'] merge_config(config, custom_config, reconfig=False) assert 'show' in config['nextra'] assert 'seven' not in config['nextra']['show']
def init(config): merge_config(config, bfwconfig) try: selector = config['selector'] except KeyError: # twanager mode return config['server_response_filters'].insert(0, middleware.FriendlyError) # XXX: position arbitrary!? selector.status404 = _error_handler('404 Not Found', 'not found') selector.status405 = _error_handler('405 Method Not Allowed', 'method not allowed') replace_handler(selector, '/', GET=web.frontpage) selector.add('/~', GET=web.user_home) selector.add('/register', POST=web.register_user) # XXX: verb as URI selector.add('/wikis', POST=web.create_wiki) # XXX: bad URI? selector.add('/pages', POST=web.put_page) # XXX: bad URI? selector.add('/editor', GET=web.editor) # XXX: bad URI? selector.add('/logout', POST=web.logout) selector.add('/{wiki_name:segment}', GET=web.wiki_home) selector.add('/{wiki_name:segment}/{page_name:segment}', GET=web.wiki_page)
def setup_module(module): csv_config = merge_config(config, { 'serializers': { 'text/csv': ['tiddlywebplugins.csv', 'text/csv; charset=UTF-8'] }, 'extension_types': { 'csv': 'text/csv' } }) module.environ = { 'tiddlyweb.config': csv_config } serializer = Serializer('json') module.tiddlers = Tiddlers() for title, json in test_tiddlers: tiddler = Tiddler(title) serializer.object = tiddler serializer.from_string(json) module.tiddlers.add(tiddler)
def init(config): """ Establish required plugins and HTTP routes. """ import tiddlywebwiki import tiddlywebplugins.logout import tiddlywebplugins.virtualhosting # calling init not required import tiddlywebplugins.magicuser import tiddlywebplugins.socialusers import tiddlywebplugins.mselect import tiddlywebplugins.oom import tiddlywebplugins.cookiedomain import tiddlywebplugins.tiddlyspace.validator import tiddlywebplugins.prettyerror import tiddlywebplugins.pathinfohack import tiddlywebplugins.hashmaker import tiddlywebplugins.form import tiddlywebplugins.reflector import tiddlywebplugins.privateer import tiddlywebplugins.relativetime import tiddlywebplugins.jsonp # Only load and run dispatcher if we are specifically configured # to use it. if config.get('use_dispatcher', False): import tiddlywebplugins.dispatcher import tiddlywebplugins.dispatcher.listener @make_command() def addmember(args): """Add a member to a space: <space name> <user name>""" store = get_store(config) space_name, username = args change_space_member(store, space_name, add=username) return True @make_command() def delmember(args): """Delete a member from a space: <space name> <user name>""" store = get_store(config) space_name, username = args change_space_member(store, space_name, remove=username) return True @make_command() def deltiddler(args): """Delete a tiddler from a bag: <bag> <title>""" from tiddlyweb.model.tiddler import Tiddler from tiddlyweb.store import NoTiddlerError from tiddlyweb.util import std_error_message bag, title = args prompt = 'deleting tiddler %s from bag %s - enter "yes" to confirm' % ( title, bag) if raw_input('%s\n' % prompt) == 'yes': store = get_store(config) tiddler = Tiddler(title, bag) try: store.delete(tiddler) except NoTiddlerError: std_error_message('error deleting tiddler %s from bag %s: %s' % (title, bag, 'no such tiddler')) return True else: std_error_message('aborted') return False merge_config(config, space_config) tiddlywebwiki.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.magicuser.init(config) tiddlywebplugins.socialusers.init(config) tiddlywebplugins.mselect.init(config) tiddlywebplugins.oom.init(config) tiddlywebplugins.cookiedomain.init(config) tiddlywebplugins.prettyerror.init(config) tiddlywebplugins.pathinfohack.init(config) tiddlywebplugins.hashmaker.init(config) tiddlywebplugins.form.init(config) tiddlywebplugins.reflector.init(config) tiddlywebplugins.privateer.init(config) tiddlywebplugins.jsonp.init(config) if config.get('use_dispatcher', False): tiddlywebplugins.dispatcher.init(config) tiddlywebplugins.dispatcher.listener.init(config) # XXX: The following is required to work around issues with twp.instancer. # Without this, config settings from tiddlywebwiki take precedence. config['serializers']['text/x-tiddlywiki'] = space_config['serializers'][ 'text/x-tiddlywiki'] # This only fixes 'twanager update', instance creation still does not have # the right information, thus requiring a twanager update after instance # creation. Presumably the instance script needs to do something similar. config['instance_tiddlers'] = get_tiddler_locations( store_contents, 'tiddlywebplugins.tiddlyspace') # inject lazy serialization information config['extension_types'].update({'lwiki': 'text/x-ltiddlywiki'}) config['serializers'].update({ 'text/x-ltiddlywiki': [ 'tiddlywebplugins.tiddlyspace.betalazyserialization', 'text/html; charset=UTF-8' ] }) if 'selector' in config: # system plugin replace_handler(config['selector'], '/', dict(GET=home)) config['selector'].add('/_safe', GET=safe_mode, POST=safe_mode) add_spaces_routes(config['selector']) add_profile_routes(config['selector']) config['selector'].add('/{tiddler_name:segment}', GET=friendly_uri) config['selector'].add('/users/{username}/identities', GET=get_identities) if ControlView not in config['server_request_filters']: config['server_request_filters'].insert( config['server_request_filters'].index(UserExtract) + 1, ControlView) if DropPrivs not in config['server_request_filters']: config['server_request_filters'].insert( config['server_request_filters'].index(ControlView) + 1, DropPrivs) if CSRFProtector not in config['server_request_filters']: config['server_request_filters'].append(CSRFProtector) if AllowOrigin not in config['server_response_filters']: config['server_response_filters'].insert( config['server_response_filters'].index(PrettyHTTPExceptor) + 1, AllowOrigin) new_serializer = [ 'tiddlywebplugins.tiddlyspace.htmlserialization', 'text/html; charset=UTF-8' ] config['serializers']['text/html'] = new_serializer config['serializers']['default'] = new_serializer
def init(config): """ Establish required plugins and HTTP routes. """ import tiddlywebwiki import tiddlywebplugins.logout import tiddlywebplugins.virtualhosting # calling init not required import tiddlywebplugins.magicuser import tiddlywebplugins.socialusers import tiddlywebplugins.mselect import tiddlywebplugins.oom import tiddlywebplugins.cookiedomain import tiddlywebplugins.tiddlyspace.validator import tiddlywebplugins.prettyerror import tiddlywebplugins.pathinfohack import tiddlywebplugins.hashmaker import tiddlywebplugins.form import tiddlywebplugins.reflector import tiddlywebplugins.lazy import tiddlywebplugins.privateer import tiddlywebplugins.relativetime import tiddlywebplugins.jsonp @make_command() def addmember(args): """Add a member to a space: <space name> <user name>""" store = get_store(config) space_name, username = args change_space_member(store, space_name, add=username) return True @make_command() def delmember(args): """Delete a member from a space: <space name> <user name>""" store = get_store(config) space_name, username = args change_space_member(store, space_name, remove=username) return True @make_command() def deltiddler(args): """Delete a tiddler from a bag: <bag> <title>""" from tiddlyweb.model.tiddler import Tiddler from tiddlyweb.store import NoTiddlerError from tiddlyweb.util import std_error_message bag, title = args prompt = 'deleting tiddler %s from bag %s - enter "yes" to confirm' % ( title, bag) if raw_input('%s\n' % prompt) == 'yes': store = get_store(config) tiddler = Tiddler(title, bag) try: store.delete(tiddler) except NoTiddlerError: std_error_message( 'error deleting tiddler %s from bag %s: %s' % ( title, bag, 'no such tiddler')) return True else: std_error_message('aborted') return False merge_config(config, space_config) tiddlywebwiki.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.magicuser.init(config) tiddlywebplugins.socialusers.init(config) tiddlywebplugins.mselect.init(config) tiddlywebplugins.oom.init(config) tiddlywebplugins.cookiedomain.init(config) tiddlywebplugins.prettyerror.init(config) tiddlywebplugins.pathinfohack.init(config) tiddlywebplugins.hashmaker.init(config) tiddlywebplugins.form.init(config) tiddlywebplugins.reflector.init(config) tiddlywebplugins.lazy.init(config) tiddlywebplugins.privateer.init(config) tiddlywebplugins.jsonp.init(config) # XXX: The following is required to work around issues with twp.instancer. # Without this, config settings from tiddlywebwiki take precedence. config['serializers']['text/x-tiddlywiki'] = space_config[ 'serializers']['text/x-tiddlywiki'] # This only fixes 'twanager update', instance creation still does not have # the right information, thus requiring a twanager update after instance # creation. Presumably the instance script needs to do something similar. config['instance_tiddlers'] = get_tiddler_locations(store_contents, 'tiddlywebplugins.tiddlyspace') if 'selector' in config: # system plugin replace_handler(config['selector'], '/', dict(GET=home)) config['selector'].add('/_safe', GET=safe_mode, POST=safe_mode) add_spaces_routes(config['selector']) config['selector'].add('/{tiddler_name:segment}', GET=friendly_uri) config['selector'].add('/users/{username}/identities', GET=get_identities) if ControlView not in config['server_request_filters']: config['server_request_filters'].insert( config['server_request_filters']. index(UserExtract) + 1, ControlView) if DropPrivs not in config['server_request_filters']: config['server_request_filters'].insert( config['server_request_filters']. index(ControlView) + 1, DropPrivs) if CSRFProtector not in config['server_request_filters']: config['server_request_filters'].append(CSRFProtector) if AllowOrigin not in config['server_response_filters']: config['server_response_filters'].insert( config['server_response_filters']. index(PrettyHTTPExceptor) + 1, AllowOrigin) new_serializer = ['tiddlywebplugins.tiddlyspace.htmlserialization', 'text/html; charset=UTF-8'] config['serializers']['text/html'] = new_serializer config['serializers']['default'] = new_serializer
def init(config): merge_config(config, NEW_CONFIG)
def main(server, user, spaces): merge_config(config, twconfig) store = get_store(config) for space in spaces: make_space(space, user, store) import_tiddlers(server, store, space)
def init(config): from tiddlyweb.util import merge_config from tiddlywebplugins.tiddlywebwikii.config import config as lconfig merge_config(config, lconfig)
def init_plugin(config): import tiddlywebwiki import tiddlywebplugins.logout import tiddlywebplugins.virtualhosting # calling init not required import tiddlywebplugins.magicuser import tiddlywebplugins.socialusers import tiddlywebplugins.mselect import tiddlywebplugins.oom import tiddlywebplugins.cookiedomain import tiddlywebplugins.tiddlyspace.validator import tiddlywebplugins.prettyerror import tiddlywebplugins.pathinfohack import tiddlywebplugins.hashmaker import tiddlywebplugins.form import tiddlywebplugins.reflector import tiddlywebplugins.privateer import tiddlywebplugins.relativetime import tiddlywebplugins.jsonp # Only load and run dispatcher if we are specifically configured # to use it. if config.get('use_dispatcher', False): import tiddlywebplugins.dispatcher import tiddlywebplugins.dispatcher.listener establish_commands(config) merge_config(config, space_config) if config.get('tiddlyspace.enable_profile', False): from werkzeug.contrib.profiler import ProfilerMiddleware config['server_request_filters'].insert(0, ProfilerMiddleware) tiddlywebwiki.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.magicuser.init(config) tiddlywebplugins.socialusers.init(config) tiddlywebplugins.mselect.init(config) tiddlywebplugins.oom.init(config) tiddlywebplugins.cookiedomain.init(config) tiddlywebplugins.prettyerror.init(config) tiddlywebplugins.pathinfohack.init(config) tiddlywebplugins.hashmaker.init(config) tiddlywebplugins.form.init(config) tiddlywebplugins.reflector.init(config) tiddlywebplugins.privateer.init(config) tiddlywebplugins.jsonp.init(config) if config.get('use_dispatcher', False): tiddlywebplugins.dispatcher.init(config) tiddlywebplugins.dispatcher.listener.init(config) # XXX: The following is required to work around issues with twp.instancer. # Without this, config settings from tiddlywebwiki take precedence. config['serializers']['text/x-tiddlywiki'] = space_config['serializers'][ 'text/x-tiddlywiki'] # This only fixes 'twanager update', instance creation still does not have # the right information, thus requiring a twanager update after instance # creation. Presumably the instance script needs to do something similar. config['instance_tiddlers'] = get_tiddler_locations( store_contents, 'tiddlywebplugins.tiddlyspace') # inject lazy serialization information config['extension_types'].update({'lwiki': 'text/x-ltiddlywiki'}) config['serializers'].update({ 'text/x-ltiddlywiki': [ 'tiddlywebplugins.tiddlyspace.betalazyserialization', 'text/html; charset=UTF-8' ] }) if 'selector' in config: # system plugin establish_www(config) # update html serialization new_serializer = [ 'tiddlywebplugins.tiddlyspace.htmlserialization', 'text/html; charset=UTF-8' ] config['serializers']['text/html'] = new_serializer
def init(config): merge_config(config,{"mselect.separator":"|"}) FILTER_PARSERS['mselect'] = mselect_parse
def init(config): """ Establish required plugins and HTTP routes. """ import tiddlywebwiki import tiddlywebplugins.logout import tiddlywebplugins.virtualhosting # calling init not required import tiddlywebplugins.magicuser import tiddlywebplugins.socialusers import tiddlywebplugins.mselect import tiddlywebplugins.oom import tiddlywebplugins.cookiedomain import tiddlywebplugins.tiddlyspace.validator import tiddlywebplugins.prettyerror import tiddlywebplugins.pathinfohack import tiddlywebplugins.hashmaker import tiddlywebplugins.form import tiddlywebplugins.reflector import tiddlywebplugins.privateer import tiddlywebplugins.relativetime import tiddlywebplugins.jsonp # Only load and run dispatcher if we are specifically configured # to use it. if config.get('use_dispatcher', False): import tiddlywebplugins.dispatcher import tiddlywebplugins.dispatcher.listener establish_commands(config) merge_config(config, space_config) tiddlywebwiki.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.magicuser.init(config) tiddlywebplugins.socialusers.init(config) tiddlywebplugins.mselect.init(config) tiddlywebplugins.oom.init(config) tiddlywebplugins.cookiedomain.init(config) tiddlywebplugins.prettyerror.init(config) tiddlywebplugins.pathinfohack.init(config) tiddlywebplugins.hashmaker.init(config) tiddlywebplugins.form.init(config) tiddlywebplugins.reflector.init(config) tiddlywebplugins.privateer.init(config) tiddlywebplugins.jsonp.init(config) if config.get('use_dispatcher', False): tiddlywebplugins.dispatcher.init(config) tiddlywebplugins.dispatcher.listener.init(config) # XXX: The following is required to work around issues with twp.instancer. # Without this, config settings from tiddlywebwiki take precedence. config['serializers']['text/x-tiddlywiki'] = space_config[ 'serializers']['text/x-tiddlywiki'] # This only fixes 'twanager update', instance creation still does not have # the right information, thus requiring a twanager update after instance # creation. Presumably the instance script needs to do something similar. config['instance_tiddlers'] = get_tiddler_locations(store_contents, 'tiddlywebplugins.tiddlyspace') # inject lazy serialization information config['extension_types'].update({'lwiki': 'text/x-ltiddlywiki'}) config['serializers'].update({'text/x-ltiddlywiki': ['tiddlywebplugins.tiddlyspace.betalazyserialization', 'text/html; charset=UTF-8']}) if 'selector' in config: # system plugin establish_www(config) # update html serialization new_serializer = ['tiddlywebplugins.tiddlyspace.htmlserialization', 'text/html; charset=UTF-8'] config['serializers']['text/html'] = new_serializer config['serializers']['default'] = new_serializer
def init(config): import tiddlywebwiki import tiddlywebplugins.virtualhosting # calling init not required merge_config(config, space_config) tiddlywebwiki.init(config)
from tiddlywebplugins.twimport import import_one from tiddlyweb.model.bag import Bag from tiddlyweb.model.collections import Tiddlers from tiddlyweb.model.tiddler import Tiddler from tiddlyweb.store import Store from tiddlyweb.serializer import Serializer from tiddlyweb.config import config from tiddlywebwiki.config import config as twwconfig from tiddlyweb.util import merge_config from tiddlyweb.control import get_tiddlers_from_bag merge_config(config, twwconfig) IMAGE = 'test/data/peermore.png' ZERO = 'test/data/zero.bin' HTML = 'test/data/index.html' def setup_module(module): bag = Bag('holder') store = Store(config['server_store'][0], config['server_store'][1], {'tiddlyweb.config': config}) store.put(bag) import_one('holder', IMAGE, store) import_one('holder', ZERO, store) tiddler = Tiddler('index', 'holder') tiddler.text = open(HTML).read().decode('UTF-8') tiddler.type = 'text/html' store.put(tiddler)
def main(server, user, spaces): merge_config(config, twconfig) store = get_store(config) for space in spaces: make_space(space, user, store) import_tiddlers(server, store, space)
def init_plugin(config): import tiddlywebplugins.whoosher import tiddlywebwiki import tiddlywebplugins.logout import tiddlywebplugins.virtualhosting # calling init not required import tiddlywebplugins.magicuser import tiddlywebplugins.socialusers import tiddlywebplugins.mselect import tiddlywebplugins.oom import tiddlywebplugins.cookiedomain import tiddlywebplugins.tiddlyspace.validator import tiddlywebplugins.prettyerror import tiddlywebplugins.hashmaker import tiddlywebplugins.form import tiddlywebplugins.reflector import tiddlywebplugins.privateer import tiddlywebplugins.relativetime import tiddlywebplugins.jsonp # Only load and run dispatcher if we are specifically configured # to use it. if config.get('use_dispatcher', False): import tiddlywebplugins.dispatcher import tiddlywebplugins.dispatcher.listener establish_commands(config) merge_config(config, space_config) if config.get('tiddlyspace.enable_profile', False): from werkzeug.contrib.profiler import ProfilerMiddleware config['server_request_filters'].insert(0, ProfilerMiddleware) tiddlywebplugins.whoosher.init(config) tiddlywebwiki.init(config) tiddlywebplugins.logout.init(config) tiddlywebplugins.magicuser.init(config) tiddlywebplugins.socialusers.init(config) tiddlywebplugins.mselect.init(config) tiddlywebplugins.oom.init(config) tiddlywebplugins.cookiedomain.init(config) tiddlywebplugins.prettyerror.init(config) tiddlywebplugins.hashmaker.init(config) tiddlywebplugins.form.init(config) tiddlywebplugins.reflector.init(config) tiddlywebplugins.privateer.init(config) tiddlywebplugins.jsonp.init(config) if config.get('use_dispatcher', False): tiddlywebplugins.dispatcher.init(config) tiddlywebplugins.dispatcher.listener.init(config) # reset config _again_ to deal with any adjustments from the # above init calls merge_config(config, space_config) # When tiddlyspace.frontpage_installed is True, don't update # the frontpage_public bag, thus not overwriting what's there. if config.get('tiddlyspace.frontpage_installed', False): config['pkgstore.skip_bags'] = ['frontpage_public'] if 'selector' in config: # system plugin # remove friendlywiki remove_handler(config['selector'], '/{recipe_name:segment}') establish_www(config) # update html serialization new_serializer = ['tiddlywebplugins.tiddlyspace.htmlserialization', 'text/html; charset=UTF-8'] config['serializers']['text/html'] = new_serializer