Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'version1'

  • Loading branch information...
commit a5e5ad2aaf4e1302cba86295f55d240ee61ece74 2 parents 501add5 + 17e01ff
@saturnflyer saturnflyer authored
View
4 Gemfile
@@ -8,7 +8,7 @@ source :rubygems
# dependency mentioned in radiant.gemspec.
gem "rails", "2.3.14"
-gem "sqlite3", "1.3.4", :group => [:development, :test], :platform => :ruby
+gem "sqlite3", "1.3.5", :group => [:development, :test], :platform => :ruby
# When radiant is installed as a gem you can run all of
# its tests and specs from an instance. If you're working
@@ -20,7 +20,7 @@ gem "sqlite3", "1.3.4", :group => [:development, :test], :platform => :ruby
# gem "compass-rails", "~> 1.0.3"
# gem "radiant-archive-extension", "~> 1.0.7"
-# gem "radiant-clipped-extension", "~> 1.0.16"
+# gem "radiant-clipped-extension", "~> 1.1.0"
# gem "radiant-debug-extension", "~> 1.0.2"
# gem "radiant-exporter-extension", "~> 1.1.0"
# gem "radiant-markdown_filter-extension", "~> 1.0.2"
View
26 app/controllers/application_controller.rb
@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base
before_filter :set_timezone
before_filter :set_user_locale
before_filter :set_javascripts_and_stylesheets
+ before_filter :force_utf8_params if RUBY_VERSION =~ /1\.9/
before_filter :set_standard_body_style, :only => [:new, :edit, :update, :create]
attr_accessor :config, :cache
@@ -84,4 +85,29 @@ def set_standard_body_style
@body_classes.concat(%w(reversed))
end
+ # When using Radiant with Ruby 1.9, the strings that come in from forms are ASCII-8BIT encoded.
+ # That causes problems, especially when using special chars and with certain DBs, like DB2
+ # That's why we force the encoding of the params to UTF-8
+ # That's what's happening in Rails 3, too: https://github.com/rails/rails/commit/25215d7285db10e2c04d903f251b791342e4dd6a
+ #
+ # See http://stackoverflow.com/questions/8268778/rails-2-3-9-encoding-of-query-parameters
+ # See https://rails.lighthouseapp.com/projects/8994/tickets/4807
+ # See http://jasoncodes.com/posts/ruby19-rails2-encodings (thanks for the following code, Jason!)
+ def force_utf8_params
+ traverse = lambda do |object, block|
+ if object.kind_of?(Hash)
+ object.each_value { |o| traverse.call(o, block) }
+ elsif object.kind_of?(Array)
+ object.each { |o| traverse.call(o, block) }
+ else
+ block.call(object)
+ end
+ object
+ end
+ force_encoding = lambda do |o|
+ o.force_encoding(Encoding::UTF_8) if o.respond_to?(:force_encoding)
+ end
+ traverse.call(params, force_encoding)
+ end
+
end
View
6 app/helpers/application_helper.rb
@@ -191,9 +191,9 @@ def gravatar_url(email, options={})
unless email.blank?
# Build the Gravatar url.
- url = 'http://www.gravatar.com/avatar.php?'
- url << "gravatar_id=#{Digest::MD5.new.update(email)}"
- url << "&rating=#{options[:rating]}" if options[:rating]
+ url = '//gravatar.com/avatar/'
+ url << "#{Digest::MD5.new.update(email)}?"
+ url << "rating=#{options[:rating]}" if options[:rating]
url << "&size=#{options[:size]}" if options[:size]
url << "&default=#{options[:default]}" if options[:default]
url
View
6 app/models/standard_tags.rb
@@ -734,9 +734,9 @@ class RequiredAttributeError < StandardError; end
email = User.find_by_name(name).email
default = "#{request.protocol}#{request.host_with_port}/images/admin/avatar_#{([size.to_i] * 2).join('x')}.png"
unless email.blank?
- url = 'http://www.gravatar.com/avatar.php?'
- url << "gravatar_id=#{Digest::MD5.new.update(email)}"
- url << "&rating=#{rating}"
+ url = '//gravatar.com/avatar/'
+ url << "#{Digest::MD5.new.update(email)}?"
+ url << "rating=#{rating}"
url << "&size=#{size.to_i}"
url << "&default=#{default}"
url
View
6 config/locales/en_available_tags.yml
@@ -320,13 +320,13 @@ attributes to the @<r:javascript>@ tag.
*Usage:*
-<pre><code><r:javascript slug=\"site.css\" as=\"inline\"
+<pre><code><r:javascript slug=\"site.js\" as=\"inline\"
type=\"text/custom\" id=\"my_id\" />
<r:javascript slug=\"other.js\" as=\"link\" /></code></pre>
The above example will produce the following:
-<pre><code> <script type=\"text/custom\" id=\"my_id\">
+<pre><code><script type=\"text/custom\" id=\"my_id\">
//<![CDATA[
var your_script = 'this content';
//]]>
@@ -514,7 +514,7 @@ attributes to the @<r:stylesheet>@ tag.
The above example will produce the following:
-<pre><code> <style type=\"text/custom\" id=\"my_id\">
+<pre><code><style type=\"text/custom\" id=\"my_id\">
/*<![CDATA[*/
.your_stylesheet { content: 'here' }
/*]]>*/
View
5 lib/generators/instance/templates/instance_gemfile
@@ -18,7 +18,7 @@ gem "compass-rails", "~> 1.0.3"
# gem "johnson" # Mozilla SpiderMonkey for Ruby
# SQLite is the default database connection but only suitable for local use
-<%= '# ' unless db == 'sqlite3' %>gem "sqlite3", "~> 1.3.4"
+<%= '# ' unless db == 'sqlite3' %>gem "sqlite3", "~> 1.3.5"
# To use MySQL
<%= '# ' unless db == 'mysql' %>gem "mysql", "~> 2.8.1"
@@ -34,8 +34,9 @@ gem "compass-rails", "~> 1.0.3"
<%= '# ' unless db == 'sqlserver' %>gem "activerecord-sqlserver-adapter", "~> 3.1.0"
# Default Extensions
+gem "radiant-snippets-extension", "~> 1.0.1"
gem "radiant-archive-extension", "~> 1.0.7"
-gem "radiant-clipped-extension", "~> 1.0.16"
+gem "radiant-clipped-extension", "~> 1.1.0"
gem "radiant-debug-extension", "~> 1.0.2"
gem "radiant-exporter-extension", "~> 1.0.2"
gem "radiant-markdown_filter-extension", "~> 1.0.2"
View
17 spec/controllers/admin/pages_controller_spec.rb
@@ -1,3 +1,5 @@
+#encoding: utf-8
+
require File.dirname(__FILE__) + '/../../spec_helper'
describe Admin::PagesController do
@@ -291,6 +293,21 @@
final_updated_at = pages(:home).updated_at
lambda{ next_updated_at <=> final_updated_at }.should be_true
end
+
+ if RUBY_VERSION =~ /1\.9/
+ it 'should convert form input to UTF-8' do
+ # When using Radiant with Ruby 1.9, the strings that come in from forms are ASCII-8BIT encoded.
+ # That causes problems, especially when using special chars and with certain DBs, like DB2
+ #
+ # See http://stackoverflow.com/questions/8268778/rails-2-3-9-encoding-of-query-parameters
+ # See https://rails.lighthouseapp.com/projects/8994/tickets/4807
+ # See http://jasoncodes.com/posts/ruby19-rails2-encodings
+
+ put :update, :id => page_id(:home), :page => {:breadcrumb => 'Homepage', :parts_attributes => {'0' => {:id => pages(:home).parts[0].id, :content => 'Ümlautö'.force_encoding('ASCII-8BIT')}}} and sleep(1)
+ params['page']['parts_attributes']['0']['content'].encoding.to_s.should == 'UTF-8'
+ params['page']['parts_attributes']['0']['content'].should == 'Ümlautö'
+ end
+ end
end
it "should initialize meta and buttons_partials in edit action" do
View
6 spec/models/standard_tags_spec.rb
@@ -580,11 +580,11 @@
describe "<r:gravatar>" do
it "should render the Gravatar URL of author of the current page" do
- page.should render('<r:gravatar />').as('http://www.gravatar.com/avatar.php?gravatar_id=e64c7d89f26bd1972efa854d13d7dd61&rating=G&size=32&default=http://testhost.tld/images/admin/avatar_32x32.png')
+ page.should render('<r:gravatar />').as('//gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?rating=G&size=32&default=http://testhost.tld/images/admin/avatar_32x32.png')
end
it "should render the Gravatar URL of the name user" do
- page.should render('<r:gravatar name="Admin" />').as('http://www.gravatar.com/avatar.php?gravatar_id=e64c7d89f26bd1972efa854d13d7dd61&rating=G&size=32&default=http://testhost.tld/images/admin/avatar_32x32.png')
+ page.should render('<r:gravatar name="Admin" />').as('//gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?rating=G&size=32&default=http://testhost.tld/images/admin/avatar_32x32.png')
end
it "should render the default avatar when the user has not set an email address" do
@@ -596,7 +596,7 @@
end
it "should render the specified rating" do
- page.should render('<r:gravatar rating="X" />').as('http://www.gravatar.com/avatar.php?gravatar_id=e64c7d89f26bd1972efa854d13d7dd61&rating=X&size=32&default=http://testhost.tld/images/admin/avatar_32x32.png')
+ page.should render('<r:gravatar rating="X" />').as('//gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?rating=X&size=32&default=http://testhost.tld/images/admin/avatar_32x32.png')
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.