[DRE-commits] r4751 - trunk/redmine/debian/patches

Jérémy Lal kapouer-guest at alioth.debian.org
Sat Feb 20 02:39:48 UTC 2010


Author: kapouer-guest
Date: 2010-02-20 02:39:47 +0000 (Sat, 20 Feb 2010)
New Revision: 4751

Added:
   trunk/redmine/debian/patches/0019-engines-rails2.2.patch
Modified:
   trunk/redmine/debian/patches/series
Log:
Use engines for rails 2.2.3, and fix redmine.

This big patch mainly comes from redmine 0.8.7 code, but since it was only rails 2.1 compatible, several fixes had to be done.

Added: trunk/redmine/debian/patches/0019-engines-rails2.2.patch
===================================================================
--- trunk/redmine/debian/patches/0019-engines-rails2.2.patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0019-engines-rails2.2.patch	2010-02-20 02:39:47 UTC (rev 4751)
@@ -0,0 +1,243 @@
+Description: Backport of Engines plugin for rails 2.2, and redmine compatibility fix.
+ The engines plugin provided upstream is rails 2.3 compatible.
+ Several fixes taken from an earlier engines version and earlier redmine version
+ have been used to make it work with rails 2.2.3
+Author: Jérémy Lal <kapouer at melix.org>
+
+---
+
+--- redmine-0.9.2.orig/vendor/plugins/engines/tasks/engines.rake
++++ redmine-0.9.2/vendor/plugins/engines/tasks/engines.rake
+@@ -153,8 +153,8 @@ end
+ 
+ # this is just a modification of the original task in railties/lib/tasks/documentation.rake, 
+ # because the default task doesn't support subdirectories like <plugin>/app or
+-# <plugin>/component. These tasks now include every file under a plugin's load paths (see
+-# Plugin#load_paths).
++# <plugin>/component. These tasks now include every file under a plugin's code paths (see
++# Plugin#code_paths).
+ namespace :doc do
+ 
+   plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
+@@ -173,9 +173,9 @@ namespace :doc do
+         options << '--line-numbers' << '--inline-source'
+         options << '-T html'
+ 
+-        # Include every file in the plugin's load_paths (see Plugin#load_paths)
++        # Include every file in the plugin's code_paths (see Plugin#code_paths)
+         if Engines.plugins[plugin]
+-          files.include("#{plugin_base}/{#{Engines.plugins[plugin].load_paths.join(",")}}/**/*.rb")
++          files.include("#{plugin_base}/{#{Engines.plugins[plugin].code_paths.join(",")}}/**/*.rb")
+         end
+         if File.exists?("#{plugin_base}/README")
+           files.include("#{plugin_base}/README")    
+--- redmine-0.9.2.orig/vendor/plugins/engines/lib/engines.rb
++++ redmine-0.9.2/vendor/plugins/engines/lib/engines.rb
+@@ -43,7 +43,7 @@ module Engines
+   
+   # List of extensions to load, can be changed in init.rb before calling Engines.init
+   mattr_accessor :rails_extensions
+-  self.rails_extensions = %w(asset_helpers form_tag_helpers migrations dependencies)
++  self.rails_extensions = %w(asset_helpers routing form_tag_helpers migrations dependencies)
+   
+   # The name of the public directory to mirror public engine assets into.
+   # Defaults to <tt>RAILS_ROOT/public/plugin_assets</tt>.
+--- redmine-0.9.2.orig/vendor/plugins/engines/lib/engines/plugin.rb
++++ redmine-0.9.2/vendor/plugins/engines/lib/engines/plugin.rb
+@@ -4,9 +4,23 @@
+ #
+ #   Engines.plugins[:plugin_name]
+ #
++# If this plugin contains paths in directories other than <tt>app/controllers</tt>,
++# <tt>app/helpers</tt>, <tt>app/models</tt> and <tt>components</tt>, authors can
++# declare this by adding extra paths to #code_paths:
++#
++#    Rails.plugin[:my_plugin].code_paths << "app/sweepers" << "vendor/my_lib"
++#
+ # Other properties of the Plugin instance can also be set.
+ module Engines
+   class Plugin < Rails::Plugin    
++    # Plugins can add code paths to this attribute in init.rb if they 
++    # need plugin directories to be added to the load path, i.e.
++    #
++    #   plugin.code_paths << 'app/other_classes'
++    #
++    # Defaults to ["app/controllers", "app/helpers", "app/models", "components"]
++    attr_accessor :code_paths
++
+     # Plugins can add paths to this attribute in init.rb if they need
+     # controllers loaded from additional locations. 
+     attr_accessor :controller_paths
+@@ -18,6 +32,16 @@ module Engines
+     attr_accessor :public_directory   
+     
+     protected
++  
++      # The default set of code paths which will be added to $LOAD_PATH
++      # and Dependencies.load_paths
++      def default_code_paths
++        # lib will actually be removed from the load paths when we call
++        # uniq! in #inject_into_load_paths, but it's important to keep it
++        # around (for the documentation tasks, for instance).
++        %w(app/controllers app/helpers app/models components lib)
++      end
++    
+       # The default set of code paths which will be added to the routing system
+       def default_controller_paths
+         %w(app/controllers components)
+@@ -34,15 +58,25 @@ module Engines
+   
+     def initialize(directory)
+       super directory
++      @code_paths = default_code_paths
+       @controller_paths = default_controller_paths
+       @public_directory = default_public_directory
+     end
+   
++    # Returns a list of paths this plugin wishes to make available in $LOAD_PATH
++    #
++    # Overwrites the correspondend method in the superclass  
++    def load_paths
++      report_nonexistant_or_empty_plugin! unless valid?
++      select_existing_paths :code_paths
++    end
++  
+     # Extends the superclass' load method to additionally mirror public assets
+     def load(initializer)
+       return if loaded?
+       super initializer
+       add_plugin_locale_paths
++      add_plugin_view_paths
+       Assets.mirror_files_for(self)
+     end    
+   
+@@ -65,11 +99,25 @@ module Engines
+       I18n.load_path.insert(app_index, *locale_files)
+     end
+ 
++    def add_plugin_view_paths
++      view_path = File.join(directory, 'app', 'views')
++      if File.exist?(view_path)
++        ActionController::Base.prepend_view_path(view_path) # push it just underneath the app
++        # ActionView::TemplateFinder.process_view_paths(view_path)
++	ActionView::Base.process_view_paths(view_path)
++      end
++    end
++
+     # The path to this plugin's public files
+     def public_asset_directory
+       "#{File.basename(Engines.public_directory)}/#{name}"
+     end
+     
++    # The path to this plugin's routes file
++    def routes_path
++      File.join(directory, "config/routes.rb")
++    end
++    
+     # The directory containing this plugin's migrations (<tt>plugin/db/migrate</tt>)
+     def migration_directory
+       File.join(self.directory, 'db', 'migrate')
+--- /dev/null
++++ redmine-0.9.2/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb
+@@ -0,0 +1,87 @@
++# Effective use of Rails' routes can help create a tidy and elegant set of URLs,
++# and is a significant part of creating an external API for your web application.
++# 
++# When developing plugins which contain controllers, it seems obvious that including
++# the corresponding routes would be extremely useful. This is particularly true
++# when exposing RESTful resources using the new REST-ian features of Rails.
++#
++# == Including routes in your plugin
++#
++# The engines plugin makes it possible to include a set of routes within your plugin
++# very simply, as it turns out. In your plugin, you simply include a <tt>routes.rb</tt> 
++# file like the one below at the root of your plugin:
++# 
++#   connect "/login", :controller => "my_plugin/account", :action => "login"
++#
++#   # add a named route
++#   logout "/logout", :controller => "my_plugin/account", :action => "logout"
++#
++#   # some restful stuff
++#   resources :things do |t|
++#     t.resources :other_things
++#   end
++# 
++# Everywhere in a normal <tt>RAILS_ROOT/config/routes.rb</tt> file 
++# where you might have <tt>map.connect</tt>, you just use <tt>connect</tt> in your 
++# plugin's <tt>routes.rb</tt>.
++# 
++# === Hooking it up in your application
++#
++# While it would be possible to have each plugin's routes automagically included into
++# the application's route set, to do so would actually be a stunningly bad idea. Route
++# priority is the key issue here. You, the application developer, needs to be in complete
++# control when it comes to specifying the priority of routes in your application, since 
++# the ordering of your routes directly affects how Rails will interpret incoming requests.
++# 
++# To add plugin routes into your application's <tt>routes.rb</tt> file, you need to explicitly 
++# map them in using the Engines::RailsExtensions::Routing#from_plugin method:
++# 
++#   ApplicationController::Routing::Routes.draw do |map|
++#
++#     map.connect "/app_stuff", :controller => "application_thing" # etc...
++#
++#     # This line includes the routes from the given plugin at this point, giving you
++#     # control over the priority of your application routes 
++#     map.from_plugin :your_plugin
++#
++#     map.connect ":controller/:action/:id"
++#   end
++# 
++# By including routes in plugins which have controllers, you can now share in a simple way 
++# a compact and elegant URL scheme which corresponds to those controllers.
++#
++# ---
++#
++# The Engines::RailsExtensions::Routing module defines extensions to Rails' 
++# routing (ActionController::Routing) mechanism such that routes can be loaded 
++# from a given plugin.
++#
++# The key method is Engines::RailsExtensions::Routing#from_plugin, which can be called 
++# within your application's <tt>config/routes.rb</tt> file to load plugin routes at that point.
++#
++module Engines::RailsExtensions::Routing
++  # Loads the set of routes from within a plugin and evaluates them at this
++  # point within an application's main <tt>routes.rb</tt> file.
++  #
++  # Plugin routes are loaded from <tt><plugin_root>/routes.rb</tt>.
++  def from_plugin(name)
++    map = self # to make 'map' available within the plugin route file
++    begin
++      routes_path = Engines.plugins[name].routes_path
++      Engines.logger.debug "loading routes from #{routes_path}"
++      eval(IO.read(routes_path), binding, routes_path) if File.file?(routes_path)
++    rescue
++    end
++  end
++end
++
++  
++module ::ActionController #:nodoc:
++  module Routing #:nodoc:
++    class RouteSet #:nodoc:
++      class Mapper #:nodoc:
++        include Engines::RailsExtensions::Routing
++      end
++    end
++  end
++end
+--- redmine-0.9.2.orig/config/routes.rb
++++ redmine-0.9.2/config/routes.rb
+@@ -6,6 +6,11 @@ ActionController::Routing::Routes.draw d
+   # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
+   # Keep in mind you can assign values other than :controller and :action
+ 
++  # Allow Redmine plugins to map routes and potentially override them
++  Rails.plugins.each do |plugin|
++    map.from_plugin plugin.name.to_sym
++  end
++
+   map.home '', :controller => 'welcome'
+   
+   map.signin 'login', :controller => 'account', :action => 'login'

Modified: trunk/redmine/debian/patches/series
===================================================================
--- trunk/redmine/debian/patches/series	2010-02-20 02:39:44 UTC (rev 4750)
+++ trunk/redmine/debian/patches/series	2010-02-20 02:39:47 UTC (rev 4751)
@@ -16,3 +16,4 @@
 0016-Request-forgery-protection-allow-XHR.patch
 0017-plugin_assets_in_var_dir.patch
 0018-dump_schema_to_cache_dir.patch
+0019-engines-rails2.2.patch




More information about the Pkg-ruby-extras-commits mailing list