Skip to content

Instantly share code, notes, and snippets.

@cdent
Last active December 11, 2015 21:39
Show Gist options
  • Select an option

  • Save cdent/4664082 to your computer and use it in GitHub Desktop.

Select an option

Save cdent/4664082 to your computer and use it in GitHub Desktop.
"""
Basic way to load a recipe at /<name>.
Add 'friendlywiki' to system_plugins in tiddlywebconfig.py:
config = {
'system_plugins': ['tiddlywebwiki','friendlywiki'],
'secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'twanager_plugins': ['tiddlywebwiki'],
}
"""
from tiddlyweb.web.handler.recipe import get_tiddlers
def friendlywiki(environ, start_response):
"""
Reframe the WSGI environment before internally redirecting
to a recipe.
"""
environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
return get_tiddlers(environ, start_response)
def init(config):
"""
Add a handler at /{something} to load a recipe.
"""
if 'selector' in config:
config['selector'].add('/{recipe_name:segment}', GET=friendlywiki)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment