Exemple #1
0
def make_map():
    """Create, configure and return the routes Mapper"""
    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    map.minimization = False
    map.explicit = True

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE
    # Map the /admin url to FA's AdminController
    maps.admin_map(map, controller='admin', url='/admin')
    # now main shakespeare routes
    map.connect('pdf', 'pdf/*url')
    if bool(config.get('deliverance.enabled', '')):
        map.connect('home', '/', controller='template', action='view', url='/')
        map.connect('about', '/about', controller='template', action='view',
                url='/about')
    else:
        map.connect('home', '/', controller='site', action='index')
        map.connect('about', '/about', controller='index', action='about')
    map.connect('/resource/{action}/{id}', controller='our_resource')
    map.connect('/material/{action}/{id}', controller='text')

    map.redirect("/word/read/{id}", "/word/{id}")
    map.connect('/word', controller='word', action='index')
    map.connect('/word/{id}', controller='word', action='read')

    map.connect('/work', controller='work', action='index')
    map.connect('/work/info/{id}', controller='work', action='info')
    map.connect('/work/annotate/{id}', controller='work', action='annotate')
    map.connect('/work/{id}', controller='work', action='view')

    map.connect('/__authtoken__', controller='token', action='token')

    map.connect('/{controller}', action='index')
    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')
    map.redirect('/*(url)/', '/{url}',
                 _redirect_code='301 Moved Permanently')
    # make sure we do not match repoze.who.openid urls
    def exclude(environ, result):
        if environ.get('PATH_INFO') in ['/login_openid', '/logout_openid']:
            return False
        else:
            return True
    map.connect('/*url', controller='template', action='view',
            conditions=dict(function=exclude))
    return map
Exemple #2
0
def make_map():
    """Create, configure and return the routes Mapper"""
    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    map.minimization = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE
    map.connect('home', '/', controller='home', action='index')
    map.connect('about', '/about/', controller='home', action='guide')
    map.connect('guide', '/guide/', controller='home', action='guide')
    map.connect('start',
                '/enquiry/start/',
                controller='enquiry',
                action='start')
    map.connect('browse',
                '/enquiry/list/',
                controller='enquiry',
                action='list')
    map.connect('register',
                '/account/register/',
                controller='account',
                action='register')
    map.connect('login-handler', '/account/login/handler/')
    map.connect('logout-handler', '/account/logout/')
    map.connect('confirm-account',
                '/account/confirm/',
                controller='account',
                action='confirm')
    # Map the /admin url to FA's AdminController
    maps.admin_map(map, controller='admin', url='/admin')
    # standard controllers
    map.connect('/{controller}/', action='index')
    map.connect('/{controller}/{action}/')
    map.connect('/{controller}/{action}/{id}/')
    # standardize on trailing slash
    map.redirect('/*(url)',
                 '/{url}/',
                 requirements=dict(url='.*[^/]$'),
                 _redirect_code='301 Moved Permanently')

    return map
def make_map():
    """Create, configure and return the routes Mapper"""
    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    map.minimization = False
    
    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE
    # Map the /admin url to FA's AdminController
    maps.admin_map(map, controller='admin', url='/admin')

    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')

    return map
Exemple #4
0
def make_map():
    """Create, configure and return the routes Mapper"""
    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    map.minimization = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')
    
    # CUSTOM ROUTES HERE
    
    map.connect('home', '/', controller='index', action='index')
    
    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/*path')    
    map.connect('/{controller}/{action}/{id}')

    admin_maps.admin_map(map, controller='admin', url='/admin')

    map.redirect('/*(url)/', '/{url}', _redirect_code='301 Moved Permanently')
    
    return map
def make_map():
    """Create, configure and return the routes Mapper"""
    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    map.minimization = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE
    maps.admin_map(map, controller='admin', url='/admin')

    # force trigger an error page
    map.connect('500', '/500', controller='error', action='show_500')

    map.connect('home', '/', controller='homesweethome', action='home')
    map.connect('about', '/about', controller='static', action='about')
    map.connect('badges', '/site-badges', controller='static', action='badges')
    map.connect('badges_slash', '/site-badges/', controller='static', action='badges')
    map.connect('contact', '/contact', controller='contact', action='contact')
    map.connect('almanacs_kml', '/api/kml/almanacs.kml', controller='homesweethome', action='almanacs_kml')
    map.connect('almanacs_kml_link', '/api/kml/almanacs_link.kml', controller='homesweethome', action='almanacs_kml_link')
    map.connect('all_pages_kml_search', '/api/kml/pages/*query.kml', controller='page', action='all_pages_kml')
    map.connect('all_pages_kml_search_link', '/api/kml/pages_link/*query.kml', controller='page', action='all_pages_kml_link')
    map.connect('pages_kml', '/api/kml/:almanac_slug/pages.kml', controller='almanac', action='pages_kml', query=None, _filter=almanac_expand)
    map.connect('pages_kml_search', '/api/kml/:almanac_slug/pages/*query.kml', controller='almanac', action='pages_kml', _filter=almanac_expand)
    map.connect('pages_kml_link', '/api/kml/:almanac_slug/pages_link.kml', controller='almanac', action='pages_kml_link', query=None, _filter=almanac_expand)
    map.connect('pages_kml_search_link', '/api/kml/:almanac_slug/pages_link/*query.kml', controller='almanac', action='pages_kml_link', _filter=almanac_expand)
    map.connect('pages_atom', '/api/feeds/:almanac_slug/pages.atom', controller='almanac', action='pages_atom', query=None, _filter=almanac_expand)
    map.connect('pages_atom_search', '/api/feeds/:almanac_slug/pages/*query.atom', controller='almanac', action='pages_atom', _filter=almanac_expand)
    # FIXME not sure if we should keep this url scheme
    map.connect('login', '/login', controller='user', action='login')
    map.connect('user_register', '/signup', controller='user', action='register')
    map.connect('user_requestreset', '/forgot', controller='user', action='request_reset')
    map.connect('user_performreset', '/reset/{username}/{key}', controller='user', action='perform_reset')
    map.connect('behalf-form', '/on-behalf-of-form/:page_id', controller="page", action="on_behalf_of_form")
    map.connect('behalf', '/on-behalf-of/:page_id', controller="page", action="on_behalf_of")
    map.connect('test', '/test', controller='user', action='test')
    map.connect('media_item_sort', '/api/sort/:almanac_slug/:page_slug', controller='media', action='sort', conditions=dict(method=['POST']), _filter=page_expand)
    map.connect('media_item_temppage_sort', '/api/sort/:almanac_slug', controller='media', action='sort', page_slug=None, conditions=dict(method=['POST']), _filter=almanac_expand)
    map.connect('almanac_center', '/api/center/:almanac_slug', controller='almanac', action='center', _filter=almanac_expand)
    map.connect('geocode', '/api/geocode', controller='geocoder', action='geocode')
    map.connect('almanac_search', '/search/:almanac_slug/*query', controller='almanac', action='search', query='', _filter=almanac_expand)
    map.connect('site_search', '/search_all/*query', controller='page', action='all_pages', query='')
    map.connect('page_create', '/:almanac_slug/+page', controller='page', action='create', _filter=almanac_expand)
    map.connect('page_view', '/:almanac_slug/:page_slug', controller='page', action='view', _filter=page_expand)
    map.connect('page_edit', '/:almanac_slug/:page_slug/edit', controller='page', action='edit', _filter=page_expand)
    map.connect('page_save_name', '/api/page/save/:page_id', controller='page', action='save_page_name', conditions=dict(method=['POST']))
    map.connect('almanac_create', '/+almanac', controller='almanac', action='create')
    map.connect('almanac_view', '/:almanac_slug', controller='almanac', action='view', _filter=almanac_expand)

    # media item routes
    map.connect('media_story_existing_new', '/media/text/:almanac_slug/:page_slug/new', controller='media', action='new_form_text', _filter=page_expand)
    map.connect('media_story_new', '/media/text/:almanac_slug/new', controller='media', action='new_form_text', _filter=almanac_expand)
    map.connect('media_story_view', '/media/text/:media_id', controller='media', action='text_view', _filter=media_expand)
    map.connect('media_story_edit', '/media/text/edit/:media_id', controller='media', action='edit_form_text', _filter=media_expand)
    map.connect('media_story_delete', '/media/text/delete/:media_id', controller='media', action='delete_text', conditions=dict(method=['POST']), _filter=media_expand)

    map.connect('media_map_existing_new', '/media/map/:almanac_slug/:page_slug/new', controller='media', action='new_form_map', _filter=page_expand)
    map.connect('media_map_new', '/media/map/:almanac_slug/new', controller='media', action='new_form_map', _filter=almanac_expand)
    map.connect('media_map_view', '/media/map/:media_id', controller='media', action='map_view', _filter=media_expand)
    map.connect('media_map_edit', '/media/map/edit/:media_id', controller='media', action='edit_form_map', _filter=media_expand)
    map.connect('media_map_delete', '/media/map/delete/:media_id', controller='media', action='delete_map', conditions=dict(method=['POST']), _filter=media_expand)

    map.connect('media_image_existing_new', '/media/image/:almanac_slug/:page_slug/new', controller='media', action='new_form_image', _filter=page_expand)
    map.connect('media_image_new', '/media/image/:almanac_slug/new', controller='media', action='new_form_image', _filter=almanac_expand)
    map.connect('media_image_view', '/media/image/:media_id', controller='media', action='image_view', _filter=media_expand)
    map.connect('media_image_edit', '/media/image/edit/:media_id', controller='media', action='edit_form_image', _filter=media_expand)
    map.connect('media_image_delete', '/media/image/delete/:media_id', controller='media', action='delete_image', conditions=dict(method=['POST']), _filter=media_expand)

    map.connect('media_pdf_existing_new', '/media/pdf/:almanac_slug/:page_slug/new', controller='media', action='new_form_pdf', _filter=page_expand)
    map.connect('media_pdf_new', '/media/pdf/:almanac_slug/new', controller='media', action='new_form_pdf', _filter=almanac_expand)
    map.connect('media_pdf_view', '/media/pdf/:media_id', controller='media', action='pdf_view', _filter=media_expand)
    map.connect('media_pdf_edit', '/media/pdf/edit/:media_id', controller='media', action='edit_form_pdf', _filter=media_expand)
    map.connect('media_pdf_delete', '/media/pdf/delete/:media_id', controller='media', action='delete_pdf', conditions=dict(method=['POST']), _filter=media_expand)

    map.connect('media_audio_existing_new', '/media/audio/:almanac_slug/:page_slug/new', controller='media', action='new_form_audio', _filter=page_expand)
    map.connect('media_audio_new', '/media/audio/:almanac_slug/new', controller='media', action='new_form_audio', _filter=almanac_expand)
    map.connect('media_audio_view', '/media/audio/:media_id', controller='media', action='audio_view', _filter=media_expand)
    map.connect('media_audio_edit', '/media/audio/edit/:media_id', controller='media', action='edit_form_audio', _filter=media_expand)
    map.connect('media_audio_delete', '/media/audio/delete/:media_id', controller='media', action='delete_audio', conditions=dict(method=['POST']), _filter=media_expand)

    map.connect('media_video_existing_new', '/media/video/:almanac_slug/:page_slug/new', controller='media', action='new_form_video', _filter=page_expand)
    map.connect('media_video_new', '/media/video/:almanac_slug/new', controller='media', action='new_form_video', _filter=almanac_expand)
    map.connect('media_video_view', '/media/video/:media_id', controller='media', action='video_view', _filter=media_expand)
    map.connect('media_video_edit', '/media/video/edit/:media_id', controller='media', action='edit_form_video', _filter=media_expand)
    map.connect('media_video_delete', '/media/video/delete/:media_id', controller='media', action='delete_video', conditions=dict(method=['POST']), _filter=media_expand)

    # add special routes to the media items themselves, so we can use nice names
    map.connect('view_media_image_large', '/media/view/image/large/:media_id/:filename', controller='media', action='view_image_large', _filter=media_expand)
    map.connect('view_media_image_small', '/media/view/image/small/:media_id/:filename', controller='media', action='view_image_small', _filter=media_expand)
    map.connect('view_media_image', '/media/view/image/:media_id/:filename', controller='media', action='view_image', _filter=media_expand)
    map.connect('view_media_audio', '/media/view/audio/:media_id/:filename', controller='media', action='view_audio', _filter=media_expand)
    map.connect('view_media_pdf', '/media/view/pdf/:media_id/:filename', controller='media', action='view_pdf', _filter=media_expand)
    return map