Ejemplo n.º 1
0
def serve_frontpage(environ, start_response):
    """
    Serve TiddlySpace front page from the special frontpage_public recipe.
    """
    environ['wsgiorg.routing_args'][1]['recipe_name'] = 'frontpage_public'
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 2
0
def home(environ, start_response):
    """
    If we have a user with role EDITOR_ROLE,
    go one place, otherwise go another,
    by way of recipe injection.
    """
    recipe_name = DEFAULT_RECIPE
    if EDITOR_ROLE in environ['tiddlyweb.usersign'].get('roles', []):
        recipe_name = EDITOR_RECIPE

    if_none_match = environ.get('HTTP_IF_NONE_MATCH', None)
    saved_headers = {}
    def our_start_response(status, headers, exc_info=None):
        etag = _header_value(headers, 'etag')
        saved_headers['etag'] = etag
        logging.debug('response has etag of %s' % etag)
        start_response(status, headers)

    cache_file_name = '%s:%s' % (recipe_name, environ['tiddlyweb.usersign']['name'])

    try:
        _validate_cache(environ, if_none_match, cache_file_name)
        output, out_etag = _read_cache(environ, cache_file_name)
        start_response('200 OK', [
            ('Content-Type', 'text/html; charset=UTF-8'),
            ('Etag', out_etag),
            ])
    except (IOError, OSError), exc:
        logging.debug('cache miss for %s: %s' % (cache_file_name, exc))
        environ['wsgiorg.routing_args'][1]['recipe_name'] = recipe_name
        environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
        output = get_tiddlers(environ, our_start_response)
        _write_cache(environ, cache_file_name, saved_headers.get('etag', None), output)
Ejemplo n.º 3
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    _setup_friendly_environ(environ)
    _extra_query_update(environ)

    ext = environ.get('tiddlyweb.extension')
    types = environ['tiddlyweb.config']['extension_types']

    # If not a wiki, limit the tiddlers
    if 'text/x-tiddlywiki' not in environ['tiddlyweb.type']:
        # If sort filter not set, sort by -modified
        filter_types = [
            filter[1][0] for filter in environ['tiddlyweb.filters']
        ]
        if 'sort' not in filter_types:
            environ['tiddlyweb.filters'] = parse_for_filters(
                'sort=-modified', environ)[0] + environ['tiddlyweb.filters']

        # Filter out core bags.
        core_bag_filters = []
        for bag in Space.core_bags():
            core_bag_filters.append('select=bag:!%s' % bag)
        core_bag_filters = parse_for_filters(';'.join(core_bag_filters),
                                             environ)[0]
        environ['tiddlyweb.filters'] = (core_bag_filters +
                                        environ['tiddlyweb.filters'])

    if ext and ext not in types:
        environ['wsgiorg.routing_args'][1]['recipe_name'] += '.%s' % ext
    return get_tiddlers(environ, start_response)
Ejemplo n.º 4
0
def dashboard(environ, start_response):
    """
    serves the dashboard wiki, from the dashboard recipe.
    """
    environ['wsgiorg.routing_args'][1]['recipe_name'] = '_dashboard'
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 5
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    _setup_friendly_environ(environ)
    _extra_query_update(environ)

    ext = environ.get('tiddlyweb.extension')
    types = environ['tiddlyweb.config']['extension_types']

    # If not a wiki, limit the tiddlers
    if 'text/x-tiddlywiki' not in environ['tiddlyweb.type']:
        # If filters not set, sort by -modified.
        if not environ['tiddlyweb.filters']:
            environ['tiddlyweb.filters'] = parse_for_filters(
                    'sort=-modified', environ)[0]

        # Filter out core bags.
        core_bag_filters = []
        for bag in Space.core_bags():
            core_bag_filters.append('select=bag:!%s' % bag)
        core_bag_filters = parse_for_filters(';'.join(core_bag_filters),
                environ)[0]
        environ['tiddlyweb.filters'].extend(core_bag_filters)

    if ext and ext not in types:
        environ['wsgiorg.routing_args'][1]['recipe_name'] += '.%s' % ext
    return get_tiddlers(environ, start_response)
Ejemplo n.º 6
0
def home(environ, start_response):
    # look at the server_host information to compare with
    # HTTP_HOST
    port = int(environ['tiddlyweb.config']['server_host']['port'])
    logging.debug('port is %s', port)
    if port != 80 and port != 443:
        host_url = '%s:%s' % (
                environ['tiddlyweb.config']['server_host']['host'],
                port
                )
    else:
        host_url = '%s' % (
                environ['tiddlyweb.config']['server_host']['host']
                )
    http_host = environ.get('HTTP_HOST', host_url)
    logging.debug('host and url: %s, %s', http_host, host_url)
    if http_host == host_url:
        return intro(environ, start_response)

    username = _determine_username_from_host(environ, http_host)

    type = 'public'
    if username == environ['tiddlyweb.usersign']['name']:
        type = 'private'

    recipe_name = '%s_%s' % (username, type)
    environ['wsgiorg.routing_args'][1]['recipe_name'] = recipe_name
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'

    return get_tiddlers(environ, start_response)
Ejemplo n.º 7
0
def serve_frontpage(environ, start_response):
    """
    Serve TiddlySpace front page from the special frontpage_public recipe.
    """
    environ['wsgiorg.routing_args'][1]['recipe_name'] = 'frontpage_public'
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 8
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    _setup_friendly_environ(environ)
    return get_tiddlers(environ, start_response)
Ejemplo n.º 9
0
def friendlywiki(environ, start_response):
    """
    Reframe the WSGI environment before internally redirecting
    to a recipe.
    """
    from tiddlyweb.web.handler.recipe import get_tiddlers
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 10
0
 def challenge_get(self, environ, start_response):
     """
     Construct a wiki which will include the necessary
     bits to do a login. Those necessary bits will include
     the required client side code to post back to the
     cookie_form.
     """
     environ['wsgiorg.routing_args'][1]['recipe_name'] = self.CHALLENGER_RECIPE
     environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
     return get_tiddlers(environ, start_response)
Ejemplo n.º 11
0
def serve_space(environ, start_response, http_host):
    """
    Serve a space determined from the current virtual host and user.
    The user determines whether the recipe uses is public or private.
    """
    space_name = determine_space(environ, http_host)
    recipe_name = determine_space_recipe(environ, space_name)
    environ['wsgiorg.routing_args'][1]['recipe_name'] = recipe_name.encode(
            'UTF-8')
    _, mime_type = get_serialize_type(environ)
    if 'text/html' in mime_type:
        environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 12
0
def serve_space(environ, start_response, http_host):
    """
    Serve a space determined from the current virtual host and user.
    The user determines whether the recipe uses is public or private.
    """
    space_name = determine_space(environ, http_host)
    recipe_name = determine_space_recipe(environ, space_name)
    environ['wsgiorg.routing_args'][1]['recipe_name'] = recipe_name.encode(
        'UTF-8')
    _, mime_type = get_serialize_type(environ)
    if 'text/html' in mime_type:
        environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 13
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    _setup_friendly_environ(environ)
    _extra_query_update(environ)

    ext = environ.get('tiddlyweb.extension')
    types = environ['tiddlyweb.config']['extension_types']
    if ext and ext not in types:
        environ['wsgiorg.routing_args'][1]['recipe_name'] += '.%s' % ext
    return get_tiddlers(environ, start_response)
Ejemplo n.º 14
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    _setup_friendly_environ(environ)
    _extra_query_update(environ)

    ext = environ.get('tiddlyweb.extension')
    types = environ['tiddlyweb.config']['extension_types']
    if ext and ext not in types:
        environ['wsgiorg.routing_args'][1]['recipe_name'] += '.%s' % ext
    return get_tiddlers(environ, start_response)
Ejemplo n.º 15
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    space_name = _setup_friendly_environ(environ)
    serializer, _ = get_serialize_type(environ)
    # If we are a wiki read ServerSettings, but ignore index
    if ('betaserialization' in serializer
            or 'betalazyserialization' in serializer):
        _, lazy = update_space_settings(environ, space_name)
        if lazy:
            environ['tiddlyweb.type'] = 'text/x-ltiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 16
0
def get_space_tiddlers(environ, start_response):
    """
    Get the tiddlers that make up the current space in
    whatever the reqeusted representation is. Choose recipe
    based on membership status.
    """
    space_name = _setup_friendly_environ(environ)
    serializer, _ = get_serialize_type(environ)
    # If we are a wiki read ServerSettings, but ignore index
    if ('betaserialization' in serializer
            or 'betalazyserialization' in serializer):
        _, lazy = update_space_settings(environ, space_name)
        if lazy:
            environ['tiddlyweb.type'] = 'text/x-ltiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 17
0
def home(environ, start_response):
    """
    If we have a user with role EDITOR_ROLE,
    go one place, otherwise go another,
    by way of recipe injection.
    """
    recipe_name = DEFAULT_RECIPE
    if EDITOR_ROLE in environ['tiddlyweb.usersign'].get('roles', []):
        recipe_name = EDITOR_RECIPE

    if_none_match = environ.get('HTTP_IF_NONE_MATCH', None)
    saved_headers = {}

    def our_start_response(status, headers, exc_info=None):
        etag = _header_value(headers, 'etag')
        saved_headers['etag'] = etag
        logging.debug('response has etag of %s' % etag)
        start_response(status, headers)

    cache_file_name = '%s:%s' % (recipe_name,
                                 environ['tiddlyweb.usersign']['name'])

    try:
        _validate_cache(environ, if_none_match, cache_file_name)
        output, out_etag = _read_cache(environ, cache_file_name)
        start_response('200 OK', [
            ('Content-Type', 'text/html; charset=UTF-8'),
            ('Etag', out_etag),
        ])
    except (IOError, OSError), exc:
        logging.debug('cache miss for %s: %s' % (cache_file_name, exc))
        environ['wsgiorg.routing_args'][1]['recipe_name'] = recipe_name
        environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
        output = get_tiddlers(environ, our_start_response)
        _write_cache(environ, cache_file_name, saved_headers.get('etag', None),
                     output)
Ejemplo n.º 18
0
def wiki_handler(environ, start_response):
    environ["tiddlyweb.type"] = "text/x-tiddlywiki"
    return get_tiddlers(environ, start_response)
Ejemplo n.º 19
0
def help_page(environ, start_response):
    from tiddlyweb.web.handler.recipe import get_tiddlers
    environ['wsgiorg.routing_args'][1]['recipe_name'] = 'help'
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 20
0
def help_page(environ, start_response):
    from tiddlyweb.web.handler.recipe import get_tiddlers
    environ['wsgiorg.routing_args'][1]['recipe_name'] = 'help'
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 21
0
def wiki_handler(environ, start_response):
    environ['tiddlyweb.type'] = 'text/x-tiddlywiki'
    return get_tiddlers(environ, start_response)
Ejemplo n.º 22
0
def help_page(environ, start_response):
    from tiddlyweb.web.handler.recipe import get_tiddlers

    environ["wsgiorg.routing_args"][1]["recipe_name"] = "help"
    environ["tiddlyweb.type"] = "text/x-tiddlywiki"
    return get_tiddlers(environ, start_response)