[DRE-commits] r4622 - in trunk/redmine/debian: . patches

Jérémy Lal kapouer-guest at alioth.debian.org
Fri Feb 12 18:25:12 UTC 2010


Author: kapouer-guest
Date: 2010-02-12 18:25:11 +0000 (Fri, 12 Feb 2010)
New Revision: 4622

Added:
   trunk/redmine/debian/patches/0010-Duplicate-name-value-in-request.patch
   trunk/redmine/debian/patches/0011-REST-API-for-my-account.patch
   trunk/redmine/debian/patches/0012-Sanitize-textarea-id-for-rails2.2.patch
   trunk/redmine/debian/patches/0013-OrderedHash-to-Hash.patch
   trunk/redmine/debian/patches/0014-Monkey-patches-for-group-support-taken-from-rails-2..patch
   trunk/redmine/debian/patches/0015-Move-session-configuration-to-YML-file-next-to-datab.patch
Modified:
   trunk/redmine/debian/changelog
   trunk/redmine/debian/patches/series
Log:
generate_session_store task was not properly declared, it would execute on require. Refreshed patches.

Modified: trunk/redmine/debian/changelog
===================================================================
--- trunk/redmine/debian/changelog	2010-02-12 17:38:06 UTC (rev 4621)
+++ trunk/redmine/debian/changelog	2010-02-12 18:25:11 UTC (rev 4622)
@@ -1,7 +1,8 @@
 redmine (0.9.2-2) unstable; urgency=low
 
   * Fix forms select helper, another rails 2.2 incompatibility.
-    (Closes: #569080) 
+    (Closes: #569080)
+  * Correctly declare generate_session_store task. (Closes: #569555)
 
  -- Jérémy Lal <kapouer at melix.org>  Wed, 10 Feb 2010 01:42:02 +0100
 

Added: trunk/redmine/debian/patches/0010-Duplicate-name-value-in-request.patch
===================================================================
--- trunk/redmine/debian/patches/0010-Duplicate-name-value-in-request.patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0010-Duplicate-name-value-in-request.patch	2010-02-12 18:25:11 UTC (rev 4622)
@@ -0,0 +1,42 @@
+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer at melix.org>
+Date: Sat, 16 Jan 2010 17:16:40 +0100
+Subject: [PATCH] Duplicate name value in request
+
+In rails 2.2, when two inputs have the same name, only the first one's value will be considered. It's best if the hidden input is rejected after the main input, and ignored by rails 2.2.
+---
+ app/helpers/settings_helper.rb |    8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
+index e57b75f..a5d8355 100644
+--- a/app/helpers/settings_helper.rb
++++ b/app/helpers/settings_helper.rb
+@@ -41,14 +41,14 @@ module SettingsHelper
+     setting_values = [] unless setting_values.is_a?(Array)
+       
+     setting_label(setting, options) +
+-      hidden_field_tag("settings[#{setting}][]", '') +
+       choices.collect do |choice|
+         text, value = (choice.is_a?(Array) ? choice : [choice, choice]) 
+         content_tag('label',
+           check_box_tag("settings[#{setting}][]", value, Setting.send(setting).include?(value)) + text.to_s,
+           :class => 'block'
+         )
+-      end.join
++      end.join +
++      hidden_field_tag("settings[#{setting}][]", '')
+   end
+   
+   def setting_text_field(setting, options={})
+@@ -63,8 +63,8 @@ module SettingsHelper
+   
+   def setting_check_box(setting, options={})
+     setting_label(setting, options) +
+-      hidden_field_tag("settings[#{setting}]", 0) +
+-      check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options)
++      check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options) +
++      hidden_field_tag("settings[#{setting}]", 0)
+   end
+   
+   def setting_label(setting, options={})
+-- 

Added: trunk/redmine/debian/patches/0011-REST-API-for-my-account.patch
===================================================================
--- trunk/redmine/debian/patches/0011-REST-API-for-my-account.patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0011-REST-API-for-my-account.patch	2010-02-12 18:25:11 UTC (rev 4622)
@@ -0,0 +1,54 @@
+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer at melix.org>
+Date: Sat, 16 Jan 2010 18:21:50 +0100
+Subject: [PATCH] REST API for my/account
+
+This allows my/account.(json|xml) to return User.current.
+---
+ app/controllers/my_controller.rb |    8 ++++++--
+ config/routes.rb                 |    6 ++++++
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
+index f686759..f960951 100644
+--- a/app/controllers/my_controller.rb
++++ b/app/controllers/my_controller.rb
+@@ -17,7 +17,7 @@
+ 
+ class MyController < ApplicationController
+   before_filter :require_login
+-
++  accept_key_auth :index
+   helper :issues
+   helper :custom_fields
+ 
+@@ -39,7 +39,11 @@ class MyController < ApplicationController
+ 
+   def index
+     page
+-    render :action => 'page'
++    respond_to do |format|
++      format.html { render :action => 'page' }
++      format.xml { render :xml => @user.to_xml }
++      format.json { render :json => @user.to_json }
++    end
+   end
+ 
+   # Show user's page
+diff --git a/config/routes.rb b/config/routes.rb
+index e2560c1..4bca52e 100644
+--- a/config/routes.rb
++++ b/config/routes.rb
+@@ -17,6 +17,12 @@ ActionController::Routing::Routes.draw do |map|
+   map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
+   map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
+   map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
++
++  map.with_options :controller => 'my' do |my_routes|
++    my_routes.with_options :conditions => {:method => :get} do |my_views|
++      my_views.connect 'my/account.:format', :action => 'index'
++    end
++  end
+   
+   map.with_options :controller => 'timelog' do |timelog|
+     timelog.connect 'projects/:project_id/time_entries', :action => 'details'
+-- 

Added: trunk/redmine/debian/patches/0012-Sanitize-textarea-id-for-rails2.2.patch
===================================================================
--- trunk/redmine/debian/patches/0012-Sanitize-textarea-id-for-rails2.2.patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0012-Sanitize-textarea-id-for-rails2.2.patch	2010-02-12 18:25:11 UTC (rev 4622)
@@ -0,0 +1,66 @@
+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer at melix.org>
+Date: Sun, 17 Jan 2010 15:18:41 +0100
+Subject: [PATCH] Sanitize textarea id for rails2.2
+
+In rails 2.2, the id attribute of a textarea is not sanitized as it is for other form tags. Fix this using a minimal monkey patch from rails 2.3.
+---
+ .../initializers/text_field_helper_santitize_id.rb |   49 ++++++++++++++++++++
+ 1 files changed, 49 insertions(+), 0 deletions(-)
+ create mode 100644 config/initializers/text_field_helper_santitize_id.rb
+
+diff --git a/config/initializers/text_field_helper_santitize_id.rb b/config/initializers/text_field_helper_santitize_id.rb
+new file mode 100644
+index 0000000..429c806
+--- /dev/null
++++ b/config/initializers/text_field_helper_santitize_id.rb
+@@ -0,0 +1,49 @@
++require 'action_view/helpers/tag_helper'
++
++module ActionView
++  module Helpers
++    module FormTagHelper
++      # Creates a text input area; use a textarea for longer text inputs such as blog posts or descriptions.
++      #
++      # ==== Options
++      # * <tt>:size</tt> - A string specifying the dimensions (columns by rows) of the textarea (e.g., "25x10").
++      # * <tt>:rows</tt> - Specify the number of rows in the textarea
++      # * <tt>:cols</tt> - Specify the number of columns in the textarea
++      # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
++      # * <tt>:escape</tt> - By default, the contents of the text input are HTML escaped.
++      #   If you need unescaped contents, set this to false.
++      # * Any other key creates standard HTML attributes for the tag.
++      #
++      # ==== Examples
++      #   text_area_tag 'post'
++      #   # => <textarea id="post" name="post"></textarea>
++      #
++      #   text_area_tag 'bio', @user.bio
++      #   # => <textarea id="bio" name="bio">This is my biography.</textarea>
++      #
++      #   text_area_tag 'body', nil, :rows => 10, :cols => 25
++      #   # => <textarea cols="25" id="body" name="body" rows="10"></textarea>
++      #
++      #   text_area_tag 'body', nil, :size => "25x10"
++      #   # => <textarea name="body" id="body" cols="25" rows="10"></textarea>
++      #
++      #   text_area_tag 'description', "Description goes here.", :disabled => true
++      #   # => <textarea disabled="disabled" id="description" name="description">Description goes here.</textarea>
++      #
++      #   text_area_tag 'comment', nil, :class => 'comment_input'
++      #   # => <textarea class="comment_input" id="comment" name="comment"></textarea>
++      def text_area_tag(name, content = nil, options = {})
++        options.stringify_keys!
++
++        if size = options.delete("size")
++          options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
++        end
++
++        escape = options.key?("escape") ? options.delete("escape") : true
++        content = html_escape(content) if escape
++
++        content_tag :textarea, content, { "name" => name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
++      end
++    end
++  end
++end
+-- 

Added: trunk/redmine/debian/patches/0013-OrderedHash-to-Hash.patch
===================================================================
--- trunk/redmine/debian/patches/0013-OrderedHash-to-Hash.patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0013-OrderedHash-to-Hash.patch	2010-02-12 18:25:11 UTC (rev 4622)
@@ -0,0 +1,23 @@
+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer at melix.org>
+Date: Thu, 21 Jan 2010 09:38:43 +0100
+Subject: [PATCH] OrderedHash to Hash
+
+Since in rails 2.2 OrderedHash < Array, not < Hash.
+---
+ app/models/issue.rb |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/app/models/issue.rb b/app/models/issue.rb
+index f4ebb29..4146547 100644
+--- a/app/models/issue.rb
++++ b/app/models/issue.rb
+@@ -157,7 +157,7 @@ class Issue < ActiveRecord::Base
+     if new_tracker_id
+       self.tracker_id = new_tracker_id
+     end
+-    send :attributes_without_tracker_first=, new_attributes, *args
++    send :attributes_without_tracker_first=, new_attributes.to_hash, *args
+   end
+   alias_method_chain :attributes=, :tracker_first
+   
+-- 

Added: trunk/redmine/debian/patches/0014-Monkey-patches-for-group-support-taken-from-rails-2..patch
===================================================================
--- trunk/redmine/debian/patches/0014-Monkey-patches-for-group-support-taken-from-rails-2..patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0014-Monkey-patches-for-group-support-taken-from-rails-2..patch	2010-02-12 18:25:11 UTC (rev 4622)
@@ -0,0 +1,85 @@
+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer at melix.org>
+Date: Sat, 9 Jan 2010 23:30:15 +0100
+Subject: [PATCH] Monkey patches for group support, taken from rails 2.3.
+
+---
+ config/initializers/action_group.rb |   69 +++++++++++++++++++++++++++++++++++
+ 1 files changed, 69 insertions(+), 0 deletions(-)
+ create mode 100644 config/initializers/action_group.rb
+
+diff --git a/config/initializers/action_group.rb b/config/initializers/action_group.rb
+new file mode 100644
+index 0000000..0adfd78
+--- /dev/null
++++ b/config/initializers/action_group.rb
+@@ -0,0 +1,69 @@
++module ActionView
++  module Helpers
++    module FormOptionsHelper
++      def options_for_select(container, selected = nil)
++        return container if String === container
++
++        container = container.to_a if Hash === container
++        selected, disabled = extract_selected_and_disabled(selected)
++
++        options_for_select = container.inject([]) do |options, element|
++          text, value = option_text_and_value(element)
++          selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
++          disabled_attribute = ' disabled="disabled"' if disabled && option_value_selected?(value, disabled)
++          options << %(<option value="#{html_escape(value.to_s)}"#{selected_attribute}#{disabled_attribute}>#{html_escape(text.to_s)}</option>)
++        end
++
++        options_for_select.join("\n")
++      end
++      def extract_selected_and_disabled(selected)
++          if selected.is_a?(Hash)
++            [selected[:selected], selected[:disabled]]
++          else
++            [selected, nil]
++          end
++        end
++      def grouped_options_for_select(grouped_options, selected_key = nil, prompt = nil)
++        body = ''
++        body << content_tag(:option, prompt, :value => "") if prompt
++        grouped_options = grouped_options.sort if grouped_options.is_a?(Hash)
++        grouped_options.each do |group|
++          body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0])
++        end
++        body
++      end
++    end
++  end
++
++  require 'action_view/test_case'
++  require 'action_controller/test_process'
++  class FormOptionsHelperTest < ActionView::TestCase
++    def test_grouped_options_for_select_with_array
++      assert_dom_equal(
++            "<optgroup label=\"North America\"><option value=\"US\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"GB\">Great Britain</option>\n<option value=\"Germany\">Germany</option></optgroup>",
++            grouped_options_for_select([
++               ["North America",
++                       [['United States','US'],"Canada"]],
++               ["Europe",
++                       [["Great Britain","GB"], "Germany"]]
++             ])
++      )
++    end
++
++    def test_grouped_options_for_select_with_selected_and_prompt
++      assert_dom_equal(
++              "<option value=\"\">Choose a product...</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option selected=\"selected\" value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>",
++              grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], "Cowboy Hat", "Choose a product...")
++      )
++    end
++
++    def test_optgroups_with_with_options_with_hash
++      assert_dom_equal(
++             "<optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup><optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup>",
++             grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']})
++      )
++    end
++  end
++end
++
++
+-- 

Added: trunk/redmine/debian/patches/0015-Move-session-configuration-to-YML-file-next-to-datab.patch
===================================================================
--- trunk/redmine/debian/patches/0015-Move-session-configuration-to-YML-file-next-to-datab.patch	                        (rev 0)
+++ trunk/redmine/debian/patches/0015-Move-session-configuration-to-YML-file-next-to-datab.patch	2010-02-12 18:25:11 UTC (rev 4622)
@@ -0,0 +1,80 @@
+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer at melix.org>
+Date: Sun, 10 Jan 2010 00:30:02 +0100
+Subject: [PATCH] Move session configuration to YML file, next to database.yml path.
+
+---
+ config/initializers/50-session.rb |   11 +++++++++++
+ lib/tasks/initializers.rake       |   36 ++++++++++++++++++++++--------------
+ 2 files changed, 33 insertions(+), 14 deletions(-)
+ create mode 100644 config/initializers/50-session.rb
+
+diff --git a/config/initializers/50-session.rb b/config/initializers/50-session.rb
+new file mode 100644
+index 0000000..34707c5
+--- /dev/null
++++ b/config/initializers/50-session.rb
+@@ -0,0 +1,11 @@
++# loads cookie based session session and secret keys
++# crash if file not found
++
++filename = ENV['RAILS_ETC'] ? File.join(ENV['RAILS_ETC'], 'session.yml') : File.join(File.dirname(__FILE__), '..', 'session.yml')
++sessionconfig = YAML::load_file(filename)
++
++ActionController::Base.session = {
++  :session_key => sessionconfig[Rails.env]['session_key'],
++  :secret => sessionconfig[Rails.env]['secret'],
++  :session_path => ENV['RAILS_RELATIVE_URL_ROOT'] ? ENV['RAILS_RELATIVE_URL_ROOT'] : '/'
++}
+diff --git a/lib/tasks/initializers.rake b/lib/tasks/initializers.rake
+index ce87475..a108204 100644
+--- a/lib/tasks/initializers.rake
++++ b/lib/tasks/initializers.rake
+@@ -1,11 +1,14 @@
+ desc 'Generates a configuration file for cookie store sessions.'
++task :generate_session_store do
+ 
+-file 'config/initializers/session_store.rb' do
+-  path = File.join(RAILS_ROOT, 'config', 'initializers', 'session_store.rb')
+-  secret = ActiveSupport::SecureRandom.hex(40)
+-  File.open(path, 'w') do |f|
+-    f.write <<"EOF"
+-# This file was generated by 'rake config/initializers/session_store.rb',
++ENV['X_DEBIAN_SITEID'] ||= 'default'
++ENV['RAILS_ETC'] ||= "/etc/redmine/#{ENV['X_DEBIAN_SITEID']}"
++filename = ENV['YML_SESSION_FILENAME'] ? ENV['YML_SESSION_FILENAME'] : 'session.yml'
++path = File.join(ENV['RAILS_ETC'] ? ENV['RAILS_ETC'] : File.join(RAILS_ROOT, 'config'), filename)
++secret = ActiveSupport::SecureRandom.hex(40)
++File.open(path, 'w') do |f|
++  f.write <<"EOF"
++# This file was generated by 'rake generate_session_store',
+ # and should not be made visible to public.
+ # If you have a load-balancing Redmine cluster, you will need to use the
+ # same version of this file on each machine. And be sure to restart your
+@@ -15,13 +18,18 @@ file 'config/initializers/session_store.rb' do
+ # change this key, all old sessions will become invalid! Make sure the
+ # secret is at least 30 characters and all random, no regular words or
+ # you'll be exposed to dictionary attacks.
+-ActionController::Base.session = {
+-  :session_key => '_redmine_session',
+-  :secret => '#{secret}'
+-}
++production:
++  session_key: _redmine_#{ENV['X_DEBIAN_SITEID']}
++  secret: #{secret}
++
++development:
++  session_key: _redmine_#{ENV['X_DEBIAN_SITEID']}
++  secret: #{secret}
++
++test:
++  session_key: _redmine_#{ENV['X_DEBIAN_SITEID']}
++  secret: #{secret}
++
+ EOF
+-  end
+ end
+-
+-desc 'Generates a configuration file for cookie store sessions.'
+-task :generate_session_store => ['config/initializers/session_store.rb']
++end
+-- 

Modified: trunk/redmine/debian/patches/series
===================================================================
--- trunk/redmine/debian/patches/series	2010-02-12 17:38:06 UTC (rev 4621)
+++ trunk/redmine/debian/patches/series	2010-02-12 18:25:11 UTC (rev 4622)
@@ -7,9 +7,9 @@
 0007-Revert-this-rails-2.3-plugin.patch
 0008-Wrong-path-for-interpreter.patch
 0009-Allows-environment-variables-to-setup-debian-paths.patch
-0010-Move-session-configuration-to-YML-file-next-to-datab.patch
-0011-Duplicate-name-value-in-request.patch
-0012-REST-API-for-my-account.patch
-0013-Sanitize-textarea-id-for-rails2.2.patch
-0014-OrderedHash-to-Hash.patch
-0015-Monkey-patches-for-group-support-taken-from-rails-2..patch
+0010-Duplicate-name-value-in-request.patch
+0011-REST-API-for-my-account.patch
+0012-Sanitize-textarea-id-for-rails2.2.patch
+0013-OrderedHash-to-Hash.patch
+0014-Monkey-patches-for-group-support-taken-from-rails-2..patch
+0015-Move-session-configuration-to-YML-file-next-to-datab.patch




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