Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lifo/docrails
Browse files Browse the repository at this point in the history
  • Loading branch information
MMSequeira committed Oct 5, 2011
2 parents 8d775d5 + d6c7185 commit 07343d2
Show file tree
Hide file tree
Showing 75 changed files with 677 additions and 247 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -99,3 +99,6 @@ if ENV['ORACLE_ENHANCED_PATH'] || ENV['ORACLE_ENHANCED']
gem "activerecord-oracle_enhanced-adapter", :git => "git://github.com/rsim/oracle-enhanced.git" gem "activerecord-oracle_enhanced-adapter", :git => "git://github.com/rsim/oracle-enhanced.git"
end end
end end

# A gem necessary for ActiveRecord tests with IBM DB
gem "ibm_db" if ENV['IBM_DB']
40 changes: 40 additions & 0 deletions actionpack/CHANGELOG
Expand Up @@ -56,6 +56,46 @@


*Rails 3.1.1 (unreleased)* *Rails 3.1.1 (unreleased)*


* javascript_path and stylesheet_path now refer to /assets if asset pipelining
is on. [Santiago Pastorino]

* button_to support form option. Now you're able to pass for example
'data-type' => 'json'. [ihower]

* image_path and image_tag should use /assets if asset pipelining is turned
on. Closes #3126 [Santiago Pastorino and christos]

* Avoid use of existing precompiled assets during rake assets:precompile run.
Closes #3119 [Guillermo Iguaran]

* Copy assets to nondigested filenames too [Santiago Pastorino]

* Give precedence to `config.digest = false` over the existence of
manifest.yml asset digests [christos]

* escape options for the stylesheet_link_tag method [Alexey Vakhov]

* Re-launch assets:precompile task using (Rake.)ruby instead of Kernel.exec so
it works on Windows [cablegram]

* env var passed to process shouldn't be modified in process method. [Santiago
Pastorino]

* `rake assets:precompile` loads the application but does not initialize
it.

To the app developer, this means configuration add in
config/initializers/* will not be executed.

Plugins developers need to special case their initializers that are
meant to be run in the assets group by adding :group => :assets. [José Valim]

* Sprockets uses config.assets.prefix for asset_path [asee]

* FileStore key_file_path properly limit filenames to 255 characters. [phuibonhoa]

* Fix Hash#to_query edge case with html_safe strings. [brainopia]

* Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation. * Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation.
Useful for linking assets from static html files or from emails when the user Useful for linking assets from static html files or from emails when the user
could probably look at an older html email with an older asset. [Santiago Pastorino] could probably look at an older html email with an older asset. [Santiago Pastorino]
Expand Down
22 changes: 11 additions & 11 deletions actionpack/actionpack.gemspec
Expand Up @@ -16,16 +16,16 @@ Gem::Specification.new do |s|
s.require_path = 'lib' s.require_path = 'lib'
s.requirements << 'none' s.requirements << 'none'


s.add_dependency('activesupport', version) s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version) s.add_dependency('activemodel', version)
s.add_dependency('rack-cache', '~> 1.0.3') s.add_dependency('rack-cache', '~> 1.1')
s.add_dependency('builder', '~> 3.0.0') s.add_dependency('builder', '~> 3.0.0')
s.add_dependency('i18n', '~> 0.6') s.add_dependency('i18n', '~> 0.6')
s.add_dependency('rack', '~> 1.3.2') s.add_dependency('rack', '~> 1.3.2')
s.add_dependency('rack-test', '~> 0.6.1') s.add_dependency('rack-test', '~> 0.6.1')
s.add_dependency('journey', '~> 1.0.0') s.add_dependency('journey', '~> 1.0.0')
s.add_dependency('sprockets', '~> 2.0.0') s.add_dependency('sprockets', '~> 2.0.2')
s.add_dependency('erubis', '~> 2.7.0') s.add_dependency('erubis', '~> 2.7.0')


s.add_development_dependency('tzinfo', '~> 0.3.29') s.add_development_dependency('tzinfo', '~> 0.3.29')
end end
3 changes: 2 additions & 1 deletion actionpack/lib/abstract_controller/asset_paths.rb
Expand Up @@ -3,7 +3,8 @@ module AssetPaths
extend ActiveSupport::Concern extend ActiveSupport::Concern


included do included do
config_accessor :asset_host, :asset_path, :assets_dir, :javascripts_dir, :stylesheets_dir config_accessor :asset_host, :asset_path, :assets_dir, :javascripts_dir,
:stylesheets_dir, :default_asset_host_protocol
end end
end end
end end
4 changes: 2 additions & 2 deletions actionpack/lib/abstract_controller/rendering.rb
Expand Up @@ -120,8 +120,6 @@ def _render_template(options) #:nodoc:
view_renderer.render(view_context, options) view_renderer.render(view_context, options)
end end


private

DEFAULT_PROTECTED_INSTANCE_VARIABLES = %w( DEFAULT_PROTECTED_INSTANCE_VARIABLES = %w(
@_action_name @_response_body @_formats @_prefixes @_config @_action_name @_response_body @_formats @_prefixes @_config
@_view_context_class @_view_renderer @_lookup_context @_view_context_class @_view_renderer @_lookup_context
Expand All @@ -139,6 +137,8 @@ def view_assigns
hash hash
end end


private

# Normalize args and options. # Normalize args and options.
# :api: private # :api: private
def _normalize_render(*args, &block) def _normalize_render(*args, &block)
Expand Down
20 changes: 15 additions & 5 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -333,9 +333,21 @@ module Behavior
module ClassMethods module ClassMethods


# Sets the controller class name. Useful if the name can't be inferred from test class. # Sets the controller class name. Useful if the name can't be inferred from test class.
# Expects +controller_class+ as a constant. Example: <tt>tests WidgetController</tt>. # Normalizes +controller_class+ before using. Examples:
#
# tests WidgetController
# tests :widget
# tests 'widget'
#
def tests(controller_class) def tests(controller_class)
self.controller_class = controller_class case controller_class
when String, Symbol
self.controller_class = "#{controller_class.to_s.underscore}_controller".camelize.constantize
when Class
self.controller_class = controller_class
else
raise ArgumentError, "controller class must be a String, Symbol, or Class"
end
end end


def controller_class=(new_class) def controller_class=(new_class)
Expand All @@ -352,9 +364,7 @@ def controller_class
end end


def determine_default_controller_class(name) def determine_default_controller_class(name)
name.sub(/Test$/, '').constantize name.sub(/Test$/, '').safe_constantize
rescue NameError
nil
end end


def prepare_controller_class(new_class) def prepare_controller_class(new_class)
Expand Down
@@ -1,4 +1,5 @@
require 'set' require 'set'
require 'cgi'
require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/class/attribute'


module HTML module HTML
Expand Down
10 changes: 6 additions & 4 deletions actionpack/lib/action_dispatch/http/url.rb
Expand Up @@ -64,14 +64,16 @@ def rewrite_authentication(options)
end end


def host_or_subdomain_and_domain(options) def host_or_subdomain_and_domain(options)
return options[:host] unless options[:subdomain] || options[:domain] return options[:host] if options[:subdomain].nil? && options[:domain].nil?


tld_length = options[:tld_length] || @@tld_length tld_length = options[:tld_length] || @@tld_length


host = "" host = ""
host << (options[:subdomain] || extract_subdomain(options[:host], tld_length)) unless options[:subdomain] == false
host << "." host << (options[:subdomain] || extract_subdomain(options[:host], tld_length))
host << (options[:domain] || extract_domain(options[:host], tld_length)) host << "."
end
host << (options[:domain] || extract_domain(options[:host], tld_length))
host host
end end
end end
Expand Down
5 changes: 3 additions & 2 deletions actionpack/lib/action_dispatch/routing/url_for.rb
Expand Up @@ -116,9 +116,10 @@ def url_options
# If <tt>:only_path</tt> is false, this option must be # If <tt>:only_path</tt> is false, this option must be
# provided either explicitly, or via +default_url_options+. # provided either explicitly, or via +default_url_options+.
# * <tt>:subdomain</tt> - Specifies the subdomain of the link, using the +tld_length+ # * <tt>:subdomain</tt> - Specifies the subdomain of the link, using the +tld_length+
# to split the domain from the host.
# * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+
# to split the subdomain from the host. # to split the subdomain from the host.
# If false, removes all subdomains from the host part of the link.
# * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+
# to split the domain from the host.
# * <tt>:tld_length</tt> - Number of labels the TLD id composed of, only used if # * <tt>:tld_length</tt> - Number of labels the TLD id composed of, only used if
# <tt>:subdomain</tt> or <tt>:domain</tt> are supplied. Defaults to # <tt>:subdomain</tt> or <tt>:domain</tt> are supplied. Defaults to
# <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1. # <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1.
Expand Down
7 changes: 1 addition & 6 deletions actionpack/lib/action_dispatch/testing/test_process.rb
Expand Up @@ -5,12 +5,7 @@
module ActionDispatch module ActionDispatch
module TestProcess module TestProcess
def assigns(key = nil) def assigns(key = nil)
assigns = {}.with_indifferent_access assigns = @controller.view_assigns.with_indifferent_access
@controller.instance_variable_names.each do |ivar|
next if ActionController::Base.protected_instance_variables.include?(ivar)
assigns[ivar[1..-1]] = @controller.instance_variable_get(ivar)
end

key.nil? ? assigns : assigns[key] key.nil? ? assigns : assigns[key]
end end


Expand Down
21 changes: 4 additions & 17 deletions actionpack/lib/action_view/asset_paths.rb
Expand Up @@ -16,20 +16,17 @@ def initialize(config, controller = nil)
# roots. Rewrite the asset path for cache-busting asset ids. Include # roots. Rewrite the asset path for cache-busting asset ids. Include
# asset host, if configured, with the correct request protocol. # asset host, if configured, with the correct request protocol.
# #
# When include_host is true and the asset host does not specify the protocol
# the protocol parameter specifies how the protocol will be added.
# When :relative (default), the protocol will be determined by the client using current protocol # When :relative (default), the protocol will be determined by the client using current protocol
# When :request, the protocol will be the request protocol # When :request, the protocol will be the request protocol
# Otherwise, the protocol is used (E.g. :http, :https, etc) # Otherwise, the protocol is used (E.g. :http, :https, etc)
def compute_public_path(source, dir, options = {}) def compute_public_path(source, dir, options = {})
source = source.to_s source = source.to_s
return source if is_uri?(source) return source if is_uri?(source)


options[:include_host] ||= true
source = rewrite_extension(source, dir, options[:ext]) if options[:ext] source = rewrite_extension(source, dir, options[:ext]) if options[:ext]
source = rewrite_asset_path(source, dir, options) source = rewrite_asset_path(source, dir, options)
source = rewrite_relative_url_root(source, relative_url_root) source = rewrite_relative_url_root(source, relative_url_root)
source = rewrite_host_and_protocol(source, options[:protocol]) if options[:include_host] source = rewrite_host_and_protocol(source, options[:protocol])
source source
end end


Expand Down Expand Up @@ -89,9 +86,7 @@ def compute_protocol(protocol)
end end


def default_protocol def default_protocol
protocol = @config.action_controller.default_asset_host_protocol if @config.action_controller.present? @config.default_asset_host_protocol || (has_request? ? :request : :relative)
protocol ||= @config.default_asset_host_protocol
protocol || (has_request? ? :request : :relative)
end end


def invalid_asset_host!(help_message) def invalid_asset_host!(help_message)
Expand Down Expand Up @@ -120,19 +115,11 @@ def compute_asset_host(source)
end end


def relative_url_root def relative_url_root
if config.action_controller.present? config.relative_url_root
config.action_controller.relative_url_root
else
config.relative_url_root
end
end end


def asset_host_config def asset_host_config
if config.action_controller.present? config.asset_host
config.action_controller.asset_host
else
config.asset_host
end
end end


# Returns the current request if one exists. # Returns the current request if one exists.
Expand Down
20 changes: 15 additions & 5 deletions actionpack/lib/action_view/helpers/url_helper.rb
Expand Up @@ -279,6 +279,7 @@ def link_to(*args, &block)
# processed normally, otherwise no action is taken. # processed normally, otherwise no action is taken.
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the # * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
# submit behavior. By default this behavior is an ajax submit. # submit behavior. By default this behavior is an ajax submit.
# * <tt>:form</tt> - This hash will be form attributes
# * <tt>:form_class</tt> - This controls the class of the form within which the submit button will # * <tt>:form_class</tt> - This controls the class of the form within which the submit button will
# be placed # be placed
# #
Expand All @@ -295,6 +296,12 @@ def link_to(*args, &block)
# # </form>" # # </form>"
# #
# #
# <%= button_to "Create", :action => "create", :remote => true, :form => { "data-type" => "json" } %>
# # => "<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
# # <div><input value="Create" type="submit" /></div>
# # </form>"
#
#
# <%= button_to "Delete Image", { :action => "delete", :id => @image.id }, # <%= button_to "Delete Image", { :action => "delete", :id => @image.id },
# :confirm => "Are you sure?", :method => :delete %> # :confirm => "Are you sure?", :method => :delete %>
# # => "<form method="post" action="/images/delete/1" class="button_to"> # # => "<form method="post" action="/images/delete/1" class="button_to">
Expand Down Expand Up @@ -324,10 +331,11 @@ def button_to(name, options = {}, html_options = {})
end end


form_method = method.to_s == 'get' ? 'get' : 'post' form_method = method.to_s == 'get' ? 'get' : 'post'
form_class = html_options.delete('form_class') || 'button_to' form_options = html_options.delete('form') || {}

form_options[:class] ||= html_options.delete('form_class') || 'button_to'

remote = html_options.delete('remote') remote = html_options.delete('remote')

request_token_tag = '' request_token_tag = ''
if form_method == 'post' && protect_against_forgery? if form_method == 'post' && protect_against_forgery?
request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token)
Expand All @@ -340,8 +348,10 @@ def button_to(name, options = {}, html_options = {})


html_options.merge!("type" => "submit", "value" => name) html_options.merge!("type" => "submit", "value" => name)


("<form method=\"#{form_method}\" action=\"#{ERB::Util.html_escape(url)}\" #{"data-remote=\"true\"" if remote} class=\"#{ERB::Util.html_escape(form_class)}\"><div>" + form_options.merge!(:method => form_method, :action => url)
method_tag + tag("input", html_options) + request_token_tag + "</div></form>").html_safe form_options.merge!("data-remote" => "true") if remote

"#{tag(:form, form_options, true)}<div>#{method_tag}#{tag("input", html_options)}#{request_token_tag}</div></form>".html_safe
end end




Expand Down

0 comments on commit 07343d2

Please sign in to comment.