1 from pkg_resources
import resource_filename
3 from pylons
import session
, tmpl_context
as c
4 from routes
import url_for
as url
6 from spline
.lib
.plugin
import PluginBase
7 from spline
.lib
.plugin
import PluginBase
, PluginLink
, Priority
9 import splinext
.forum
.controllers
.forum
11 def add_routes_hook(map, *args
, **kwargs
):
12 """Hook to inject some of our behavior into the routes configuration."""
13 require_GET
= dict(conditions
=dict(method
=['GET']))
14 require_POST
= dict(conditions
=dict(method
=['POST']))
16 map.connect('/forums', controller
='forum', action
='forums')
17 map.connect(r
'/forums/{forum_id:\d+}', controller
='forum', action
='threads')
18 map.connect(r
'/forums/{forum_id:\d+}/threads/{thread_id:\d+}', controller
='forum', action
='posts')
20 map.connect(r
'/forums/{forum_id:\d+}/write', controller
='forum', action
='write_thread', **require_GET
)
21 map.connect(r
'/forums/{forum_id:\d+}/write', controller
='forum', action
='write_thread_commit', **require_POST
)
22 map.connect(r
'/forums/{forum_id:\d+}/threads/{thread_id:\d+}/write', controller
='forum', action
='write', **require_GET
)
23 map.connect(r
'/forums/{forum_id:\d+}/threads/{thread_id:\d+}/write', controller
='forum', action
='write_commit', **require_POST
)
26 class ForumPlugin(PluginBase
):
27 def controllers(self
):
29 forum
= splinext
.forum
.controllers
.forum
.ForumController
,
34 PluginLink(u
'Forums', url(controller
='forum', action
='forums')),
39 ('routes_mapping', Priority
.NORMAL
, add_routes_hook
),
42 # frontpage plugin may or may not be installed
44 from splinext
.forum
.frontpage_sources
import ForumSource
, forum_activity
46 ('frontpage_updates_forum', Priority
.NORMAL
, ForumSource
))
48 ('frontpage_extras', Priority
.NORMAL
, forum_activity
))