iron-cms 0.18.0 → 0.18.1
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.
- checksums.yaml +4 -4
- data/app/controllers/concerns/iron/web_page.rb +3 -1
- data/app/models/iron/entry/presentable.rb +1 -1
- data/app/models/iron/entry/web_publishable.rb +17 -3
- data/lib/generators/iron/pages/templates/pages_controller.rb +1 -1
- data/lib/iron/published_page_constraint.rb +33 -0
- data/lib/iron/routing.rb +2 -26
- data/lib/iron/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9abaa273ecae6889ecd0cef2c07e13acd8f114fcb837c1d1a258b3b3fcafba0
|
|
4
|
+
data.tar.gz: c53c056bb26a8008e997e511271861eaccf4201cea3fef1cc7ebfb078fc9c9ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 707eff365a47620389245b3e52afb2b5a6595aa2b3f625d3bda7adb0babc12005cdc5f46d3c23f057b19f1aed2a74930627b980f62cccfc4cd9eca3acbe6d553
|
|
7
|
+
data.tar.gz: f37858c8de836880cbbe9af192cf28aed93986bb245e397f98428ef6201da3682c049e2f29738cb1e4b4c94000fb77395683efc75503f29c69d59d172f62d94e
|
|
@@ -12,7 +12,9 @@ module Iron
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def set_entry
|
|
15
|
-
@entry = @content_type.entries.find_by
|
|
15
|
+
@entry = @content_type.entries.find_by(route: params[:route])
|
|
16
|
+
|
|
17
|
+
raise ActiveRecord::RecordNotFound unless @entry&.published_in?(Current.locale)
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
end
|
|
@@ -19,26 +19,40 @@ module Iron
|
|
|
19
19
|
route == ""
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def web_title
|
|
22
|
+
def web_title(locale: Locale.default)
|
|
23
23
|
return nil unless content_type.web_page_title_field_definition
|
|
24
24
|
|
|
25
25
|
title_field = fields.find_by(
|
|
26
26
|
definition: content_type.web_page_title_field_definition,
|
|
27
|
-
locale:
|
|
27
|
+
locale: locale
|
|
28
28
|
) || fields.detect { |f|
|
|
29
29
|
f.definition_id == content_type.web_page_title_field_definition_id &&
|
|
30
|
-
f.
|
|
30
|
+
f.locale_id == locale&.id
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
title_field&.value
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def published_in?(locale)
|
|
37
|
+
return false unless content_type.web_publishing_enabled?
|
|
38
|
+
|
|
39
|
+
if content_type.web_page_title_field_definition
|
|
40
|
+
web_title(locale: locale).present?
|
|
41
|
+
else
|
|
42
|
+
translated_in?(locale)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
36
46
|
def path
|
|
37
47
|
content_type.path_for(self) if content_type.web_publishing_enabled?
|
|
38
48
|
end
|
|
39
49
|
|
|
40
50
|
private
|
|
41
51
|
|
|
52
|
+
def translated_in?(locale)
|
|
53
|
+
fields.where(locale: locale, parent: nil).exists?
|
|
54
|
+
end
|
|
55
|
+
|
|
42
56
|
def should_generate_route?
|
|
43
57
|
content_type.web_publishing_enabled? && route.nil?
|
|
44
58
|
end
|
|
@@ -5,7 +5,7 @@ class PagesController < ApplicationController
|
|
|
5
5
|
@content_type = Iron::ContentType.web_published.find_by_handle!(params[:content_type])
|
|
6
6
|
@entry = @content_type.entries.find_by(route: params[:route])
|
|
7
7
|
|
|
8
|
-
raise ActiveRecord::RecordNotFound unless @entry
|
|
8
|
+
raise ActiveRecord::RecordNotFound unless @entry&.published_in?(Iron::Current.locale)
|
|
9
9
|
|
|
10
10
|
render "templates/#{@content_type.handle}"
|
|
11
11
|
rescue ActionView::MissingTemplate
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Iron
|
|
2
|
+
class PublishedPageConstraint
|
|
3
|
+
def matches?(request)
|
|
4
|
+
matches_locale?(request) && has_published_entry?(request)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def matches_locale?(request)
|
|
10
|
+
locale = request.params[:locale]
|
|
11
|
+
return true if locale.blank?
|
|
12
|
+
return false if locale.start_with?("rails")
|
|
13
|
+
Iron::Locale.pluck(:code).include?(locale)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def has_published_entry?(request)
|
|
17
|
+
content_type_handle = request.params[:content_type]
|
|
18
|
+
route = request.params[:route].presence || ""
|
|
19
|
+
|
|
20
|
+
content_type = Iron::ContentType.find_by!(handle: content_type_handle)
|
|
21
|
+
|
|
22
|
+
if entry = content_type.entries.find_by(route: route)
|
|
23
|
+
entry.published_in?(requested_locale(request))
|
|
24
|
+
else
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def requested_locale(request)
|
|
30
|
+
Iron::Locale.detect(request) || Iron::Locale.default
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/iron/routing.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "iron/published_page_constraint"
|
|
2
|
+
|
|
1
3
|
module Iron
|
|
2
4
|
module Routing
|
|
3
5
|
def iron_pages
|
|
@@ -37,30 +39,4 @@ module Iron
|
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class PublishedPageConstraint
|
|
43
|
-
def matches?(request)
|
|
44
|
-
matches_locale?(request) && has_published_entry?(request)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
def matches_locale?(request)
|
|
50
|
-
locale = request.params[:locale]
|
|
51
|
-
return true if locale.blank?
|
|
52
|
-
return false if locale.start_with?("rails")
|
|
53
|
-
Iron::Locale.pluck(:code).include?(locale)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def has_published_entry?(request)
|
|
57
|
-
content_type_handle = request.params[:content_type]
|
|
58
|
-
route = request.params[:route].presence || ""
|
|
59
|
-
# For v1 we won't handle localization, we need to figure out how to localize routes
|
|
60
|
-
# locale = Iron::Locale.detect(request) || Iron::Locale.default
|
|
61
|
-
|
|
62
|
-
content_type = Iron::ContentType.find_by!(handle: content_type_handle)
|
|
63
|
-
content_type.entries.exists?(route: route)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
42
|
end
|
data/lib/iron/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iron-cms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.18.
|
|
4
|
+
version: 0.18.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Massimo De Marchi
|
|
@@ -686,6 +686,7 @@ files:
|
|
|
686
686
|
- lib/iron/lexorank/rankable.rb
|
|
687
687
|
- lib/iron/lexorank/rebalance_rank_job.rb
|
|
688
688
|
- lib/iron/lexorank/utils.rb
|
|
689
|
+
- lib/iron/published_page_constraint.rb
|
|
689
690
|
- lib/iron/routing.rb
|
|
690
691
|
- lib/iron/sdk.rb
|
|
691
692
|
- lib/iron/version.rb
|