Added a full-blown login page with a description of OpenID.
[zzz-floof.git] / floof / config / routing.py
1 """Routes configuration
2
3 The more specific and detailed routes should be defined first so they
4 may take precedent over the more generic routes. For more information
5 refer to the routes manual at http://routes.groovie.org/docs/
6 """
7 from pylons import config
8 from routes import Mapper
9
10 def make_map():
11 """Create, configure and return the routes Mapper"""
12 map = Mapper(directory=config['pylons.paths']['controllers'],
13 always_scan=config['debug'], explicit=True)
14 map.minimization = False
15
16 # explicit = True disables a broken feature called "route memory",
17 # where it adds everything matched in the current request as default variables
18 # for the next one. This is wrong because it doesn't invalidate things lower down in
19 # the hierarchy when higher up things change. Rails port failure.
20 # NOTE: this also disables actions defaulting to index, sorry.
21
22 require_POST = dict(conditions={'method': ['POST']})
23
24 # get rid of trailing slashes
25 map.redirect('/*(url)/', '/{url}',
26 _redirect_code='301 Moved Permanently')
27
28
29 # The ErrorController route (handles 404/500 error pages); it should
30 # likely stay at the top, ensuring it can always be resolved
31 map.connect('/error/{action}', controller='error')
32 map.connect('/error/{action}/{id}', controller='error')
33
34 map.connect('home', '/', controller='main', action='index')
35
36 # Account stuff
37 with map.submapper(controller="account") as sub:
38 sub.connect('login', '/account/login', action='login')
39 sub.connect('login_begin', '/account/login_begin', action='login_begin', **require_POST)
40 sub.connect('login_finish', '/account/login_finish', action='login_finish')
41 sub.connect('logout', '/account/logout', action='logout', **require_POST)
42 sub.connect('register', '/account/register', action='register')
43 sub.connect('register_finish', '/account/register_finish', action='register_finish', **require_POST)
44
45 # Specific user stuff
46 with map.submapper(controller='users') as sub:
47 sub.connect( '/users', action='list')
48 sub.connect('user_page', '/users/{name}', action='view')
49 with map.submapper(controller='user_settings') as sub:
50 sub.connect( '/users/{name}/settings/relationships/toggle',
51 action='rel_toggle', **require_POST)
52
53 # Comments
54 with map.submapper(controller='comments') as sub:
55 sub.connect('/*owner_url/comments', action='thread')
56 sub.connect('/*owner_url/comments/reply', action='reply')
57 sub.connect('/*owner_url/comments/reply_done', action='reply_done', **require_POST)
58 sub.connect('/*owner_url/comments/{id}', action='thread')
59 sub.connect('/*owner_url/comments/{id}/reply', action='reply')
60 sub.connect('/*owner_url/comments/{id}/reply_done', action='reply_done', **require_POST)
61
62 # Art
63 with map.submapper(controller="art") as sub:
64 sub.connect('new_art', '/art/new', action="new")
65 sub.connect('create_art', '/art/create', action="create")
66 sub.connect('rate_art', '/art/{id}/rate', action="rate")
67 sub.connect('show_art', '/art/{id}', action="show")
68
69 # Some art pages pertain to a specific user, but still belong in the art
70 # controller
71 map.connect('/users/{name}/watchstream', controller='art', action='watchstream')
72
73 with map.submapper(controller='tag') as sub:
74 sub.connect('delete_tag', '/art/{art_id}/tag/{id}')
75 sub.connect('create_tag', '/art/{art_id}/tag')
76
77 map.resource('tag','tags', controller="tag",
78 parent_resource=dict(member_name='art', collection_name='art'))
79 # Yeah, parent resources are specified kinda dumb-ly. Would be better if you could pass in the
80 # real parent resource instead of mocking it up with a silly dict. We should file a feature request.
81
82 # I think resources is the right way to go for most things. It ensures all of our actions have the right
83 # methods on them, at least. It does require the use of silly _method="delete" post parameters though.
84
85 # One sticking point though is, it'll happily allow you to add any formatting string you want, like art/1.json
86 # I wonder if there's a way to place requirements on that, or disable it until we actually have formats.
87 # It just serves the same action as usual but with a format argument in the context.
88
89 # map.connect('/art/new', controller='art', action='new')
90 # map.connect('/art/upload', controller='art', action='upload')
91 # map.connect('show_art', '/art/{id}', controller='art', action='show')
92 # map.connect('/art/{id}/tag', controller='art', action='tag')
93
94 # map.connect('/tag/{id}/delete', controller='tag', action='delete')
95
96 map.connect('search', '/search', controller='search', action='index')
97 # map.connect( '/search/{query}', controller='search', action='index')
98 map.connect('saved_searches', '/search/list', controller='search', action='list')
99
100
101 # default routing is back so we can test stuff.
102 # please don't take it away until we have some more core features in.
103 map.connect('/{controller}/{action}')
104 map.connect('/{controller}/{action}/{id}')
105
106 return map