Use unidecoder for converting non ascii charcters for page slugs. Fixes #340

This commit is contained in:
Mario Visic 2012-04-08 15:13:07 +08:00
parent 22d55cf0e0
commit f74306503b
7 changed files with 12 additions and 10 deletions

View File

@ -62,7 +62,7 @@ PATH
responders (~> 0.6.4) responders (~> 0.6.4)
rmagick (~> 2.12.2) rmagick (~> 2.12.2)
sanitize (~> 2.0.3) sanitize (~> 2.0.3)
stringex (~> 1.3.2) unidecoder (~> 1.1.1)
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
@ -298,7 +298,6 @@ GEM
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
stringex (1.3.2)
term-ansicolor (1.0.7) term-ansicolor (1.0.7)
thor (0.14.6) thor (0.14.6)
tilt (1.3.3) tilt (1.3.3)
@ -313,6 +312,7 @@ GEM
kgio (~> 2.6) kgio (~> 2.6)
rack rack
raindrops (~> 0.7) raindrops (~> 0.7)
unidecoder (1.1.1)
warden (1.1.1) warden (1.1.1)
rack (>= 1.0) rack (>= 1.0)
xpath (0.1.4) xpath (0.1.4)

View File

@ -5,7 +5,7 @@
class String #:nodoc class String #:nodoc
def permalink def permalink
self.parameterize('-') self.to_ascii.parameterize('-')
end end
def permalink! def permalink!

View File

@ -19,6 +19,7 @@ require 'cancan'
require 'RMagick' require 'RMagick'
require 'cells' require 'cells'
require 'sanitize' require 'sanitize'
require 'unidecoder'
require 'compass' require 'compass'
require 'codemirror/rails' require 'codemirror/rails'

View File

@ -49,6 +49,7 @@ Gem::Specification.new do |s|
s.add_dependency 'RedCloth', '~> 4.2.8' s.add_dependency 'RedCloth', '~> 4.2.8'
s.add_dependency 'sanitize', '~> 2.0.3' s.add_dependency 'sanitize', '~> 2.0.3'
s.add_dependency 'highline', '~> 1.6.2' s.add_dependency 'highline', '~> 1.6.2'
s.add_dependency 'unidecoder', '~> 1.1.1'
s.add_dependency 'rmagick', '~> 2.12.2' s.add_dependency 'rmagick', '~> 2.12.2'
s.add_dependency 'carrierwave-mongoid', '~> 0.1.3' s.add_dependency 'carrierwave-mongoid', '~> 0.1.3'

View File

@ -235,7 +235,7 @@ describe Locomotive::Page do
it 'fills in the slug field' do it 'fills in the slug field' do
@page.valid? @page.valid?
@page.slug.should == 'content-type-template' @page.slug.should == 'content_type_template'
end end
it 'returns the target klass' do it 'returns the target klass' do

View File

@ -20,13 +20,13 @@ describe Locomotive::Snippet do
before :each do before :each do
@site = FactoryGirl.create(:site, :subdomain => 'omg') @site = FactoryGirl.create(:site, :subdomain => 'omg')
@snippet = FactoryGirl.create(:snippet, :site => @site, :slug => 'my-test-snippet', :template => 'a testing template') @snippet = FactoryGirl.create(:snippet, :site => @site, :slug => 'my_test_snippet', :template => 'a testing template')
end end
context 'with a normal top level snippet' do context 'with a normal top level snippet' do
before :each do before :each do
@page = FactoryGirl.create(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% include 'my-test-snippet' %}") @page = FactoryGirl.create(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% include 'my_test_snippet' %}")
end end
it 'updates templates with the new snippet template' do it 'updates templates with the new snippet template' do
@ -39,7 +39,7 @@ describe Locomotive::Snippet do
context 'for snippets inside of a block' do context 'for snippets inside of a block' do
before :each do before :each do
@page = FactoryGirl.create(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% block main %}{% include 'my-test-snippet' %}{% endblock %}") @page = FactoryGirl.create(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% block main %}{% include 'my_test_snippet' %}{% endblock %}")
end end
it 'updates templates with the new snippet template' do it 'updates templates with the new snippet template' do
@ -54,7 +54,7 @@ describe Locomotive::Snippet do
before :each do before :each do
Mongoid::Fields::I18n.with_locale(:fr) do Mongoid::Fields::I18n.with_locale(:fr) do
@snippet = FactoryGirl.create(:snippet, :site => @site, :slug => 'my_localized_test_snippet', :template => 'a testing template') @snippet = FactoryGirl.create(:snippet, :site => @site, :slug => 'my_localized_test_snippet', :template => 'a testing template')
@page = FactoryGirl.create(:page, :site => @site, :slug => 'my_localized_test_snippet', :raw_template => "{% block main %}{% include 'my-localized-test-snippet' %}{% endblock %}") @page = FactoryGirl.create(:page, :site => @site, :slug => 'my_localized_test_snippet', :raw_template => "{% block main %}{% include 'my_localized_test_snippet' %}{% endblock %}")
end end
end end