kuhsaft 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ class Kuhsaft::LocalizedPage < ActiveRecord::Base
|
|
9
9
|
|
10
10
|
validates :title, :presence => true
|
11
11
|
validates :locale, :presence => true
|
12
|
-
validates :slug, :presence => true
|
12
|
+
validates :slug, :presence => true, :unless => :allow_empty_slug
|
13
13
|
|
14
14
|
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
15
15
|
|
@@ -22,21 +22,20 @@ class Kuhsaft::LocalizedPage < ActiveRecord::Base
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_url
|
25
|
-
return if self.page_type ==
|
25
|
+
return if self.page_type == Kuhsaft::PageType::REDIRECT
|
26
26
|
complete_slug = ''
|
27
27
|
if page.present? && page.parent.present?
|
28
28
|
complete_slug << page.parent.url.to_s
|
29
29
|
else
|
30
30
|
complete_slug = "#{self.locale}"
|
31
31
|
end
|
32
|
-
complete_slug << "/#{self.slug}"
|
32
|
+
complete_slug << "/#{self.slug}" unless self.page_type == Kuhsaft::PageType::NAVIGATION
|
33
33
|
self.url = complete_slug
|
34
34
|
end
|
35
35
|
|
36
36
|
def create_slug
|
37
|
-
|
38
|
-
|
39
|
-
end
|
37
|
+
has_slug = title.present? && slug.blank?
|
38
|
+
write_attribute(:slug, read_attribute(:title).downcase.parameterize) if has_slug
|
40
39
|
end
|
41
40
|
|
42
41
|
def collect_fulltext
|
@@ -49,4 +48,8 @@ class Kuhsaft::LocalizedPage < ActiveRecord::Base
|
|
49
48
|
end
|
50
49
|
self.fulltext << [title.to_s, keywords.to_s, description.to_s].join(' ')
|
51
50
|
end
|
51
|
+
|
52
|
+
def allow_empty_slug
|
53
|
+
self.page_type == Kuhsaft::PageType::NAVIGATION
|
54
|
+
end
|
52
55
|
end
|
data/app/models/kuhsaft/page.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
= page.fields_for :localized_pages, @localized_page do |localized|
|
3
3
|
= localized.input :title
|
4
4
|
= localized.input :slug, :required => false
|
5
|
-
= localized.input :page_type, :as => :radio, :collection =>
|
5
|
+
= localized.input :page_type, :as => :radio, :collection => Kuhsaft::PageType.all
|
6
6
|
= localized.input :published, :collection => Kuhsaft::PublishState.all, :label_method => :human_name, :value_method => :value
|
7
7
|
.clear
|
8
|
-
- unless localized.object.page_type ==
|
8
|
+
- unless localized.object.page_type == Kuhsaft::PageType::REDIRECT
|
9
9
|
- if localized.object.published == Kuhsaft::PublishState::PUBLISHED_AT
|
10
10
|
= localized.input :published_at, :as => :datetime
|
11
11
|
= localized.input :keywords
|
data/lib/kuhsaft/version.rb
CHANGED
@@ -57,18 +57,27 @@ describe Kuhsaft::LocalizedPage do
|
|
57
57
|
@localized_page.should respond_to(:page_type)
|
58
58
|
end
|
59
59
|
|
60
|
-
it 'should generate the url
|
60
|
+
it 'should just generate the url when the page_type is empty' do
|
61
61
|
page = Factory.create :page
|
62
62
|
page.translation.url.should eq('en/english-title')
|
63
63
|
end
|
64
64
|
|
65
|
-
it 'should
|
65
|
+
it 'should save the users url with a "REDIRECT" page_type' do
|
66
66
|
page = Factory.create :page
|
67
|
-
page.translation.page_type =
|
67
|
+
page.translation.page_type = Kuhsaft::PageType::REDIRECT
|
68
68
|
page.translation.url = '/en/news'
|
69
69
|
page.save
|
70
70
|
page.translation.url.should eq('/en/news')
|
71
71
|
end
|
72
|
+
|
73
|
+
it 'should not use the slug in the url when the page_type is "NAVIGATION"' do
|
74
|
+
page = Factory.create :page
|
75
|
+
child_page = Factory.create :page
|
76
|
+
page.childs << child_page
|
77
|
+
page.translation.page_type = Kuhsaft::PageType::NAVIGATION
|
78
|
+
page.save
|
79
|
+
child_page.translation.url.should eq('en/english-title')
|
80
|
+
end
|
72
81
|
end
|
73
82
|
|
74
83
|
describe 'validations' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuhsaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.8
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Immanuel H\xC3\xA4ussermann"
|
@@ -284,6 +284,7 @@ files:
|
|
284
284
|
- app/models/kuhsaft/page_part.rb
|
285
285
|
- app/models/kuhsaft/page_part/content.rb
|
286
286
|
- app/models/kuhsaft/page_part/markdown.rb
|
287
|
+
- app/models/kuhsaft/page_type.rb
|
287
288
|
- app/models/kuhsaft/publish_state.rb
|
288
289
|
- app/stylesheets/kuhsaft/admin/ie.sass
|
289
290
|
- app/stylesheets/kuhsaft/admin/partials/_assets.sass
|