Paging for threads and posts! #314
[zzz-spline-forum.git] / splinext / forum / __init__.py
1 from pkg_resources import resource_filename
2
3 from pylons import session, tmpl_context as c
4
5 from spline.lib.plugin import PluginBase
6 from spline.lib.plugin import PluginBase, PluginLink, Priority
7
8 import splinext.forum.controllers.forum
9
10 def add_routes_hook(map, *args, **kwargs):
11 """Hook to inject some of our behavior into the routes configuration."""
12 require_POST = dict(conditions=dict(method=['POST']))
13
14 map.connect('/forums', controller='forum', action='forums')
15 map.connect(r'/forums/{forum_id:\d+}', controller='forum', action='threads')
16 map.connect(r'/forums/{forum_id:\d+}/threads/{thread_id:\d+}', controller='forum', action='posts')
17
18 map.connect(r'/forums/{forum_id:\d+}/write', controller='forum', action='write_thread')
19 map.connect(r'/forums/{forum_id:\d+}/threads/{thread_id:\d+}/write', controller='forum', action='write')
20
21
22 class ForumPlugin(PluginBase):
23 def controllers(self):
24 return dict(
25 forum = splinext.forum.controllers.forum.ForumController,
26 )
27
28 def hooks(self):
29 hooks = [
30 ('routes_mapping', Priority.NORMAL, add_routes_hook),
31 ]
32
33 # frontpage plugin may or may not be installed
34 try:
35 from splinext.forum.frontpage_sources import ForumSource
36 hooks.append(
37 ('frontpage_updates_forum', Priority.NORMAL, ForumSource))
38 except ImportError:
39 pass
40
41 return hooks