プロジェクト

全般

プロフィール

Vote #64101

完了

Change the way plugin routes are integrated

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
対象バージョン:
開始日:
2008/11/07
期日:
進捗率:

100%

予定工数:
category_id:
20
version_id:
2
issue_org_id:
2142
author_id:
1188
assigned_to_id:
5
comments:
3
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Plugin's routes can today ( r1977 ) be handled thanks to a hook in the config/routes.rb :

Redmine::Hook.call_hook :routes, :map => map
The developper has to define his routes in vendor/plugins/redmine_myplugin/init.rb (in the register block) :
    class MyRoutes < Redmine::Hook::Listener
      def routes(context)
        context[:map].resources :mymodel
        context[:map].connect 'mypath/:blah', :controller => 'mycontroller'
        #etc.
      end
    end
    Redmine::Hook.add_listener(MyRoutes)

Maybe it is possible to use Engines system to handle each plugin's routes, with "map.from_plugin" method :

  • in config/routes.rb
    Rails.plugins.each do |plugin|
      map.from_plugin plugin.name.to_sym
    end
    
    - in vendor/plugins/redmine_myplugin/routes.rb
    resources :mymodel
    connect 'mypath/:blah', :controller => 'mycontroller'
    

It has been discussed "here":http://www.redmine.org/boards/1/topics/show/2885 in the forum. Maybe it would be easier to use for plugin developpers, but I'm not 100% sure routes overriding will produce the same effect.


journals

I really like your suggestion and changed the way plugin routing works in r1991. Plugins' @routes.rb@ are now added automatically to Redmine's routing, including the ability to override Redmine's default routing.

Here's an example I put in a plugin to override the home page with the project list.

<pre><code class="ruby"># vendor/plugins/redmine_test_plugin/routes.rb
map.home '', :controller => 'projects', :action => 'index'
</code></pre>
--------------------------------------------------------------------------------
FYI: for documentation, the @map@ object in my example isn't required, this will also work

<pre><code># vendor/plugins/redmine_test_plugin/routes.rb
home '', :controller => 'projects', :action => 'index'
</code></pre>

--------------------------------------------------------------------------------
Just a quick note here since I may not be the only one to miss that : this way to configure routes in plugins has changed with r2887. You should have a look at "this thread":http://www.redmine.org/boards/3/topics/8406 where Eric explains how to update your plugins.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリPlugin API_20 にセット
  • 対象バージョン0.8_2 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0