X-Git-Url: http://git.veekun.com/zzz-spline-forum.git/blobdiff_plain/e50129eabfd1aeb25bcfce911546699b89b0019c..eda83e616ace71957edf96a49a6e80ea3ae27b2a:/splinext/forum/__init__.py?ds=sidebyside diff --git a/splinext/forum/__init__.py b/splinext/forum/__init__.py index 98ad4af..974e29e 100644 --- a/splinext/forum/__init__.py +++ b/splinext/forum/__init__.py @@ -1,6 +1,6 @@ from pkg_resources import resource_filename -from pylons import c, session +from pylons import session, tmpl_context as c from spline.lib.plugin import PluginBase from spline.lib.plugin import PluginBase, PluginLink, Priority @@ -9,9 +9,14 @@ import splinext.forum.controllers.forum def add_routes_hook(map, *args, **kwargs): """Hook to inject some of our behavior into the routes configuration.""" + require_POST = dict(conditions=dict(method=['POST'])) + map.connect('/forums', controller='forum', action='forums') - map.connect('/forums/{forum_id}', controller='forum', action='threads') - map.connect('/forums/{forum_id}/threads/{thread_id}', controller='forum', action='posts') + map.connect(r'/forums/{forum_id:\d+}', controller='forum', action='threads') + map.connect(r'/forums/{forum_id:\d+}/threads/{thread_id:\d+}', controller='forum', action='posts') + + map.connect(r'/forums/{forum_id:\d+}/write', controller='forum', action='write_thread') + map.connect(r'/forums/{forum_id:\d+}/threads/{thread_id:\d+}/write', controller='forum', action='write') class ForumPlugin(PluginBase): @@ -21,6 +26,16 @@ class ForumPlugin(PluginBase): ) def hooks(self): - return [ + hooks = [ ('routes_mapping', Priority.NORMAL, add_routes_hook), ] + + # frontpage plugin may or may not be installed + try: + from splinext.forum.frontpage_sources import ForumSource + hooks.append( + ('frontpage_updates_forum', Priority.NORMAL, ForumSource)) + except ImportError: + pass + + return hooks