Made JS permalink regexp more generic for non–latin languages.
Fixed specs for permalinks generated by stringex.
This commit is contained in:
parent
ad9bd5f5f3
commit
2798e15481
@ -62,6 +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)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
@ -297,6 +298,7 @@ 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)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
String.prototype.slugify = function(sep) {
|
String.prototype.slugify = function(sep) {
|
||||||
if (typeof sep == 'undefined') sep = '_';
|
if (typeof sep == 'undefined') sep = '_';
|
||||||
var alphaNumRegexp = new RegExp('[^a-zA-Z0-9а-яА-Я\\' + sep + ']', 'g');
|
var alphaNumRegexp = new RegExp('[^\w\\' + sep + ']', 'g');
|
||||||
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
|
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
|
||||||
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase()
|
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase()
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,12 @@ describe Locomotive::ContentEntry do
|
|||||||
|
|
||||||
it 'removes dots' do
|
it 'removes dots' do
|
||||||
@content_entry.title = "my.test"; @content_entry.send(:set_slug)
|
@content_entry.title = "my.test"; @content_entry.send(:set_slug)
|
||||||
@content_entry._permalink.should == 'my-test'
|
@content_entry._permalink.should == 'my-dot-test'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'accepts non-latin chars' do
|
||||||
|
@content_entry.title = "абракадабра"; @content_entry.send(:set_slug)
|
||||||
|
@content_entry._permalink.should == 'abrakadabra'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'also accepts a file field as the highlighted field' do
|
it 'also accepts a file field as the highlighted field' do
|
||||||
|
@ -102,11 +102,11 @@ describe Locomotive::Page do
|
|||||||
it 'should have normalized slug' do
|
it 'should have normalized slug' do
|
||||||
page = FactoryGirl.build(:page, :slug => ' Valid ité.html ')
|
page = FactoryGirl.build(:page, :slug => ' Valid ité.html ')
|
||||||
page.valid?
|
page.valid?
|
||||||
page.slug.should == 'valid-ite-html'
|
page.slug.should == 'valid-ite-dot-html'
|
||||||
|
|
||||||
page = FactoryGirl.build(:page, :title => ' Valid ité.html ', :slug => nil, :site => page.site)
|
page = FactoryGirl.build(:page, :title => ' Valid ité.html ', :slug => nil, :site => page.site)
|
||||||
page.should be_valid
|
page.should be_valid
|
||||||
page.slug.should == 'valid-ite-html'
|
page.slug.should == 'valid-ite-dot-html'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has no cache strategy' do
|
it 'has no cache strategy' do
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user