trusty-cms 3.1.2 → 3.1.3
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/Gemfile.lock +8 -6
- data/app/models/haml_filter.rb +5 -0
- data/app/models/rails_page.rb +39 -0
- data/app/views/layouts/trusty.html.haml +1 -0
- data/lib/nested_layouts/tags/core.rb +150 -0
- data/lib/trusty_cms.rb +1 -1
- data/vendor/extensions/layouts-extension/layouts_extension.rb +19 -0
- data/vendor/extensions/layouts-extension/lib/haml_layouts/models/layout.rb +33 -0
- data/vendor/extensions/layouts-extension/lib/haml_layouts/models/page.rb +33 -0
- data/vendor/extensions/layouts-extension/lib/layouts/engine.rb +5 -0
- data/vendor/extensions/layouts-extension/lib/nested_layouts/tags/core.rb +150 -0
- data/vendor/extensions/layouts-extension/lib/share_layouts/controllers/action_controller.rb +26 -0
- data/vendor/extensions/layouts-extension/lib/share_layouts/helpers/action_view.rb +48 -0
- data/vendor/extensions/layouts-extension/lib/tasks/layouts_extension_tasks.rake +55 -0
- data/vendor/extensions/layouts-extension/lib/trusty-layouts-extension.rb +1 -0
- metadata +39 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3f140dbe502e3d9232850abc0288b799b89190
|
4
|
+
data.tar.gz: d70dadc2a0feb66013f73da7ad59818ebc6c8dd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ee4c8a1da236230788d026e2f37ee9466966587719f033b1050050c0970528b04dc48d21ff44b1b8c684434977b7858bfeb175172b9ec3114cfaac1e2970f29
|
7
|
+
data.tar.gz: f05dc81ae9744dd1c651f16a1fe5aba045902fce8440dce542837c092c3e618aab5fa50299974282f7d51f8d69d7699d9d8ee69d5929e0d224d259db117a40d2
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
trusty-cms (3.1.
|
11
|
+
trusty-cms (3.1.3)
|
12
12
|
RedCloth (~> 4.3.2)
|
13
13
|
acts_as_tree (~> 2.6.1)
|
14
14
|
bundler (~> 1.7)
|
@@ -118,6 +118,7 @@ GEM
|
|
118
118
|
sass-rails (< 5.1)
|
119
119
|
sprockets (< 4.0)
|
120
120
|
concurrent-ruby (1.0.5)
|
121
|
+
crass (1.0.2)
|
121
122
|
css_parser (1.6.0)
|
122
123
|
addressable
|
123
124
|
database_cleaner (1.5.3)
|
@@ -136,7 +137,7 @@ GEM
|
|
136
137
|
ffi (1.9.18)
|
137
138
|
globalid (0.4.0)
|
138
139
|
activesupport (>= 4.2.0)
|
139
|
-
haml (5.0.
|
140
|
+
haml (5.0.4)
|
140
141
|
temple (>= 0.8.0)
|
141
142
|
tilt
|
142
143
|
haml-rails (1.0.0)
|
@@ -160,7 +161,8 @@ GEM
|
|
160
161
|
launchy (2.4.3)
|
161
162
|
addressable (~> 2.3)
|
162
163
|
libv8 (3.16.14.19)
|
163
|
-
loofah (2.
|
164
|
+
loofah (2.1.1)
|
165
|
+
crass (~> 1.0.2)
|
164
166
|
nokogiri (>= 1.5.9)
|
165
167
|
mail (2.6.6)
|
166
168
|
mime-types (>= 1.16, < 4)
|
@@ -168,13 +170,13 @@ GEM
|
|
168
170
|
mime-types (3.1)
|
169
171
|
mime-types-data (~> 3.2015)
|
170
172
|
mime-types-data (3.2016.0521)
|
171
|
-
mini_portile2 (2.
|
173
|
+
mini_portile2 (2.3.0)
|
172
174
|
minitest (5.10.3)
|
173
175
|
multi_json (1.12.2)
|
174
176
|
mysql2 (0.4.9)
|
175
177
|
nio4r (2.1.0)
|
176
|
-
nokogiri (1.8.
|
177
|
-
mini_portile2 (~> 2.
|
178
|
+
nokogiri (1.8.1)
|
179
|
+
mini_portile2 (~> 2.3.0)
|
178
180
|
orm_adapter (0.5.0)
|
179
181
|
poltergeist (1.14.0)
|
180
182
|
capybara (~> 2.1)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class RailsPage < Page
|
2
|
+
|
3
|
+
display_name "Application"
|
4
|
+
attr_accessor :breadcrumbs
|
5
|
+
|
6
|
+
def find_by_url(url, live=true, clean=true)
|
7
|
+
found_page = super
|
8
|
+
if found_page.nil? || found_page.is_a?(FileNotFoundPage)
|
9
|
+
url = clean_url(url) if clean
|
10
|
+
self if url.starts_with?(self.url)
|
11
|
+
else
|
12
|
+
found_page
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def url=(path)
|
17
|
+
@url = path
|
18
|
+
end
|
19
|
+
|
20
|
+
def url
|
21
|
+
@url || super
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_parts_from_hash!(content)
|
25
|
+
content.each do |k,v|
|
26
|
+
(part(k) || parts.build(:name => k.to_s, :filter_id => "")).content = v
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method "tag:old_breadcrumbs", "tag:breadcrumbs"
|
31
|
+
tag 'breadcrumbs' do |tag|
|
32
|
+
if tag.locals.page.is_a?(RailsPage) && tag.locals.page.breadcrumbs
|
33
|
+
tag.locals.page.breadcrumbs
|
34
|
+
else
|
35
|
+
render_tag('old_breadcrumbs', tag)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
= trusty_layout.html_safe
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module NestedLayouts
|
2
|
+
module Tags
|
3
|
+
module Core
|
4
|
+
|
5
|
+
include TrustyCms::Taggable
|
6
|
+
|
7
|
+
class TagError < StandardError; end
|
8
|
+
|
9
|
+
desc %{
|
10
|
+
Renders the contents of the tag inside of a "parent" layout, which is selected via the +name+
|
11
|
+
attribute. The contents of this tag are placed at a corresponding <r:content_for_layout/> tag
|
12
|
+
within the parent layout. This tag is intended to be used within your layouts, and should
|
13
|
+
only appear once per layout.
|
14
|
+
|
15
|
+
*Usage:*
|
16
|
+
|
17
|
+
<r:inside_layout name="master">
|
18
|
+
<div id="main-column">
|
19
|
+
<r:content_for_layout/>
|
20
|
+
</div>
|
21
|
+
</r:inside_layout>
|
22
|
+
}
|
23
|
+
tag 'inside_layout' do |tag|
|
24
|
+
if name = tag.attr['name']
|
25
|
+
# Prepare the stacks
|
26
|
+
tag.globals.nested_layouts_content_stack ||= []
|
27
|
+
tag.globals.nested_layouts_layout_stack ||= []
|
28
|
+
|
29
|
+
# Remember the original layout to support the +layout+ tag
|
30
|
+
tag.globals.page_original_layout ||= tag.globals.page.layout # Remember the original layout
|
31
|
+
|
32
|
+
# Find the layout
|
33
|
+
name.strip!
|
34
|
+
if layout = Layout.find_by_name(name)
|
35
|
+
# Track this layout on the stack
|
36
|
+
tag.globals.nested_layouts_layout_stack << name
|
37
|
+
|
38
|
+
# Save contents of inside_layout for later insertion
|
39
|
+
tag.globals.nested_layouts_content_stack << tag.expand
|
40
|
+
|
41
|
+
# Set the page layout that Trusty should use for rendering, which is different than the actual
|
42
|
+
# page's layout when layouts are nested. The final/highest +inside_layout+ tag will set or
|
43
|
+
# overwrite this value for the last time.
|
44
|
+
tag.globals.page.layout = layout
|
45
|
+
tag.globals.page.render
|
46
|
+
else
|
47
|
+
raise TagError.new(%{Error (nested_layouts): Parent layout "#{name.strip}" not found for "inside_layout" tag})
|
48
|
+
end
|
49
|
+
else
|
50
|
+
raise TagError.new(%{Error (nested_layouts): "inside_layout" tag must contain a "name" attribute})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc %{
|
55
|
+
Allows nested layouts to target this layout. The contents of <r:inside_layout> tag blocks in another
|
56
|
+
layout will have their contents inserted at the location given by this tag (if they target this
|
57
|
+
layout). This tag also behaves like a standard <r:content/> tag if this layout is specified directly
|
58
|
+
by a page.
|
59
|
+
|
60
|
+
This tag is intended to be used inside layouts.
|
61
|
+
|
62
|
+
*Usage:*
|
63
|
+
|
64
|
+
<html>
|
65
|
+
<body>
|
66
|
+
<r:content_for_layout/>
|
67
|
+
</body>
|
68
|
+
</html>
|
69
|
+
|
70
|
+
}
|
71
|
+
tag 'content_for_layout' do |tag|
|
72
|
+
tag.globals.nested_layouts_content_stack ||= []
|
73
|
+
|
74
|
+
# return the saved content if any, or mimic a default +<r:content/>+ tag (render the body part)
|
75
|
+
tag.globals.nested_layouts_content_stack.pop || tag.globals.page.render_part('body')
|
76
|
+
end
|
77
|
+
|
78
|
+
desc %{
|
79
|
+
Return the layout name of the current page.
|
80
|
+
|
81
|
+
*Usage:*
|
82
|
+
|
83
|
+
<html>
|
84
|
+
<body id="<r:layout/>"
|
85
|
+
My body tag has an id corresponding to the layout I use. Sweet!
|
86
|
+
</body>
|
87
|
+
</html>
|
88
|
+
}
|
89
|
+
tag 'layout' do |tag|
|
90
|
+
current_layout_name(tag)
|
91
|
+
end
|
92
|
+
|
93
|
+
desc %{
|
94
|
+
output the contents of tag if layout equals name (support regex)
|
95
|
+
|
96
|
+
*Usage:*
|
97
|
+
|
98
|
+
<pre><code><r:if_layout name="(parent|parent_of_child)">
|
99
|
+
one of those layouts
|
100
|
+
</r:if_layout></code></pre>
|
101
|
+
}
|
102
|
+
tag 'if_layout' do |tag|
|
103
|
+
tag.expand if is_current_layout(tag)
|
104
|
+
end
|
105
|
+
|
106
|
+
desc %{
|
107
|
+
Output the contents of tag unless layout equals name (support regex)
|
108
|
+
|
109
|
+
*Usage:*
|
110
|
+
|
111
|
+
<pre><code><r:unless_layout name="parent">
|
112
|
+
not the parent layotu
|
113
|
+
</r:unless_layout></code></pre>
|
114
|
+
}
|
115
|
+
tag 'unless_layout' do |tag|
|
116
|
+
tag.expand unless is_current_layout(tag)
|
117
|
+
end
|
118
|
+
|
119
|
+
tag 'body' do |tag|
|
120
|
+
%{<body id="#{tag.locals.page.slug.gsub('/','')}" class="#{current_layout_name(tag)}#{tag.attr['class'].present? ? " #{tag.attr['class']}" : nil}">#{tag.expand}</body>}
|
121
|
+
end
|
122
|
+
|
123
|
+
protected
|
124
|
+
|
125
|
+
def current_layout_name(tag)
|
126
|
+
result = ''
|
127
|
+
|
128
|
+
if layout = tag.globals.page_original_layout
|
129
|
+
result = layout.name
|
130
|
+
elsif layout = tag.globals.page.layout
|
131
|
+
result = layout.name
|
132
|
+
end
|
133
|
+
|
134
|
+
result
|
135
|
+
end
|
136
|
+
|
137
|
+
def is_current_layout(tag)
|
138
|
+
if tag.attr['name'].nil?
|
139
|
+
raise TagError.new(%{Error (nested_layouts): "if_layout" tag must contain a "name" attribute})
|
140
|
+
end
|
141
|
+
|
142
|
+
layout = tag.globals.page_original_layout || tag.globals.page.layout
|
143
|
+
search = %r{#{tag.attr['name']}}
|
144
|
+
|
145
|
+
(layout.name =~ search).present?
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/lib/trusty_cms.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
class LayoutsExtension < TrustyCms::Extension
|
2
|
+
description "A set of useful extensions to standard Layouts."
|
3
|
+
|
4
|
+
def activate
|
5
|
+
# Shared Layouts
|
6
|
+
RailsPage
|
7
|
+
ApplicationController.send :include, ShareLayouts::Controllers::ActionController
|
8
|
+
ActionView::Base.send :include, ShareLayouts::Helpers::ActionView
|
9
|
+
|
10
|
+
# Nested Layouts
|
11
|
+
Page.send :include, NestedLayouts::Tags::Core
|
12
|
+
|
13
|
+
# HAML Layouts
|
14
|
+
Layout.send :include, HamlLayouts::Models::Layout
|
15
|
+
Page.send :include, HamlLayouts::Models::Page
|
16
|
+
HamlFilter
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module HamlLayouts
|
2
|
+
module Models
|
3
|
+
module Layout
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
|
8
|
+
# Will render html from haml if necessary
|
9
|
+
def rendered_content
|
10
|
+
if is_haml?
|
11
|
+
# The gsub will replace all escaped radius tags with html
|
12
|
+
HamlFilter.filter(content)
|
13
|
+
else
|
14
|
+
content
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns 'text/html' to the browser (if haml)
|
19
|
+
def content_type
|
20
|
+
self[:content_type] == 'haml' ? 'text/html' : self[:content_type]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Overwrites the standard Trusty CMS Render and pumps out haml if necessary
|
24
|
+
def is_haml?
|
25
|
+
self[:content_type] == 'haml'
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module HamlLayouts
|
2
|
+
module Models
|
3
|
+
module Page
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
|
8
|
+
def parse_object(object)
|
9
|
+
# We don't want to return the haml on a layout by default
|
10
|
+
text = object.is_a?(Layout) ? object.rendered_content : object.content
|
11
|
+
|
12
|
+
if object.respond_to? :filter_id
|
13
|
+
if object.filter_id == 'Haml'
|
14
|
+
# We want to render the tags as html/radius before passing them
|
15
|
+
text = object.filter.filter(text)
|
16
|
+
text = parse(text)
|
17
|
+
else
|
18
|
+
text = parse(text)
|
19
|
+
text = object.filter.filter(text)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
text = parse(text)
|
23
|
+
end
|
24
|
+
text
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module NestedLayouts
|
2
|
+
module Tags
|
3
|
+
module Core
|
4
|
+
|
5
|
+
include TrustyCms::Taggable
|
6
|
+
|
7
|
+
class TagError < StandardError; end
|
8
|
+
|
9
|
+
desc %{
|
10
|
+
Renders the contents of the tag inside of a "parent" layout, which is selected via the +name+
|
11
|
+
attribute. The contents of this tag are placed at a corresponding <r:content_for_layout/> tag
|
12
|
+
within the parent layout. This tag is intended to be used within your layouts, and should
|
13
|
+
only appear once per layout.
|
14
|
+
|
15
|
+
*Usage:*
|
16
|
+
|
17
|
+
<r:inside_layout name="master">
|
18
|
+
<div id="main-column">
|
19
|
+
<r:content_for_layout/>
|
20
|
+
</div>
|
21
|
+
</r:inside_layout>
|
22
|
+
}
|
23
|
+
tag 'inside_layout' do |tag|
|
24
|
+
if name = tag.attr['name']
|
25
|
+
# Prepare the stacks
|
26
|
+
tag.globals.nested_layouts_content_stack ||= []
|
27
|
+
tag.globals.nested_layouts_layout_stack ||= []
|
28
|
+
|
29
|
+
# Remember the original layout to support the +layout+ tag
|
30
|
+
tag.globals.page_original_layout ||= tag.globals.page.layout # Remember the original layout
|
31
|
+
|
32
|
+
# Find the layout
|
33
|
+
name.strip!
|
34
|
+
if layout = Layout.find_by_name(name)
|
35
|
+
# Track this layout on the stack
|
36
|
+
tag.globals.nested_layouts_layout_stack << name
|
37
|
+
|
38
|
+
# Save contents of inside_layout for later insertion
|
39
|
+
tag.globals.nested_layouts_content_stack << tag.expand
|
40
|
+
|
41
|
+
# Set the page layout that Trusty should use for rendering, which is different than the actual
|
42
|
+
# page's layout when layouts are nested. The final/highest +inside_layout+ tag will set or
|
43
|
+
# overwrite this value for the last time.
|
44
|
+
tag.globals.page.layout = layout
|
45
|
+
tag.globals.page.render
|
46
|
+
else
|
47
|
+
raise TagError.new(%{Error (nested_layouts): Parent layout "#{name.strip}" not found for "inside_layout" tag})
|
48
|
+
end
|
49
|
+
else
|
50
|
+
raise TagError.new(%{Error (nested_layouts): "inside_layout" tag must contain a "name" attribute})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc %{
|
55
|
+
Allows nested layouts to target this layout. The contents of <r:inside_layout> tag blocks in another
|
56
|
+
layout will have their contents inserted at the location given by this tag (if they target this
|
57
|
+
layout). This tag also behaves like a standard <r:content/> tag if this layout is specified directly
|
58
|
+
by a page.
|
59
|
+
|
60
|
+
This tag is intended to be used inside layouts.
|
61
|
+
|
62
|
+
*Usage:*
|
63
|
+
|
64
|
+
<html>
|
65
|
+
<body>
|
66
|
+
<r:content_for_layout/>
|
67
|
+
</body>
|
68
|
+
</html>
|
69
|
+
|
70
|
+
}
|
71
|
+
tag 'content_for_layout' do |tag|
|
72
|
+
tag.globals.nested_layouts_content_stack ||= []
|
73
|
+
|
74
|
+
# return the saved content if any, or mimic a default +<r:content/>+ tag (render the body part)
|
75
|
+
tag.globals.nested_layouts_content_stack.pop || tag.globals.page.render_part('body')
|
76
|
+
end
|
77
|
+
|
78
|
+
desc %{
|
79
|
+
Return the layout name of the current page.
|
80
|
+
|
81
|
+
*Usage:*
|
82
|
+
|
83
|
+
<html>
|
84
|
+
<body id="<r:layout/>"
|
85
|
+
My body tag has an id corresponding to the layout I use. Sweet!
|
86
|
+
</body>
|
87
|
+
</html>
|
88
|
+
}
|
89
|
+
tag 'layout' do |tag|
|
90
|
+
current_layout_name(tag)
|
91
|
+
end
|
92
|
+
|
93
|
+
desc %{
|
94
|
+
output the contents of tag if layout equals name (support regex)
|
95
|
+
|
96
|
+
*Usage:*
|
97
|
+
|
98
|
+
<pre><code><r:if_layout name="(parent|parent_of_child)">
|
99
|
+
one of those layouts
|
100
|
+
</r:if_layout></code></pre>
|
101
|
+
}
|
102
|
+
tag 'if_layout' do |tag|
|
103
|
+
tag.expand if is_current_layout(tag)
|
104
|
+
end
|
105
|
+
|
106
|
+
desc %{
|
107
|
+
Output the contents of tag unless layout equals name (support regex)
|
108
|
+
|
109
|
+
*Usage:*
|
110
|
+
|
111
|
+
<pre><code><r:unless_layout name="parent">
|
112
|
+
not the parent layotu
|
113
|
+
</r:unless_layout></code></pre>
|
114
|
+
}
|
115
|
+
tag 'unless_layout' do |tag|
|
116
|
+
tag.expand unless is_current_layout(tag)
|
117
|
+
end
|
118
|
+
|
119
|
+
tag 'body' do |tag|
|
120
|
+
%{<body id="#{tag.locals.page.slug.gsub('/','')}" class="#{current_layout_name(tag)}#{tag.attr['class'].present? ? " #{tag.attr['class']}" : nil}">#{tag.expand}</body>}
|
121
|
+
end
|
122
|
+
|
123
|
+
protected
|
124
|
+
|
125
|
+
def current_layout_name(tag)
|
126
|
+
result = ''
|
127
|
+
|
128
|
+
if layout = tag.globals.page_original_layout
|
129
|
+
result = layout.name
|
130
|
+
elsif layout = tag.globals.page.layout
|
131
|
+
result = layout.name
|
132
|
+
end
|
133
|
+
|
134
|
+
result
|
135
|
+
end
|
136
|
+
|
137
|
+
def is_current_layout(tag)
|
138
|
+
if tag.attr['name'].nil?
|
139
|
+
raise TagError.new(%{Error (nested_layouts): "if_layout" tag must contain a "name" attribute})
|
140
|
+
end
|
141
|
+
|
142
|
+
layout = tag.globals.page_original_layout || tag.globals.page.layout
|
143
|
+
search = %r{#{tag.attr['name']}}
|
144
|
+
|
145
|
+
(layout.name =~ search).present?
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ShareLayouts
|
2
|
+
module Controllers
|
3
|
+
module ActionController
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def trusty_layout(name=nil, options={}, &block)
|
11
|
+
raise ArgumentError, "A layout name or block is required!" unless name || block
|
12
|
+
class_attribute :trusty_layout
|
13
|
+
self.trusty_layout = name || block
|
14
|
+
before_action :set_trusty_layout
|
15
|
+
layout 'trusty', options
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_trusty_layout
|
20
|
+
@trusty_layout = self.class.trusty_layout
|
21
|
+
@trusty_layout = @trusty_layout.call(self) if @trusty_layout.is_a? Proc
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module ShareLayouts
|
2
|
+
module Helpers
|
3
|
+
module ActionView
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
|
8
|
+
def trusty_layout(name = @trusty_layout)
|
9
|
+
page = find_page
|
10
|
+
assign_attributes!(page, name)
|
11
|
+
page.build_parts_from_hash!(extract_captures)
|
12
|
+
page.render
|
13
|
+
end
|
14
|
+
|
15
|
+
def assign_attributes!(page, name = @trusty_layout)
|
16
|
+
page.layout = Layout.where(name: name).first || page.layout
|
17
|
+
page.title = @title || @content_for_title || page.title || ''
|
18
|
+
page.breadcrumb = @breadcrumb || @content_for_breadcrumb || page.breadcrumb || page.title
|
19
|
+
page.breadcrumbs = @breadcrumbs || @content_for_breadcrumbs || nil
|
20
|
+
page.url = request.path
|
21
|
+
page.slug = page.url.split("/").last
|
22
|
+
page.published_at ||= Time.now
|
23
|
+
page.request = request
|
24
|
+
page.response = response
|
25
|
+
end
|
26
|
+
|
27
|
+
def extract_captures
|
28
|
+
@view_flow.content.inject({}) do |h, var|
|
29
|
+
key = var[0]
|
30
|
+
key = :body if key == :layout
|
31
|
+
unless key == :title || key == :breadcrumbs
|
32
|
+
h[key] = var[1]
|
33
|
+
end
|
34
|
+
h
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_page
|
39
|
+
page = Page.find_by_url(request.path) rescue nil
|
40
|
+
page.is_a?(RailsPage) ? page : RailsPage.new(:class_name => "RailsPage")
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :trusty_cms do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :layouts do
|
4
|
+
|
5
|
+
desc "Runs the migration of the Layouts extension"
|
6
|
+
task :migrate => :environment do
|
7
|
+
require 'trusty/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
LayoutsExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
LayoutsExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies public assets of the Layouts to the instance public/ directory."
|
18
|
+
task :update => :environment do
|
19
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
20
|
+
puts "Copying assets from LayoutsExtension"
|
21
|
+
Dir[LayoutsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(LayoutsExtension.root, '')
|
23
|
+
directory = File.dirname(path)
|
24
|
+
mkdir_p Rails.root.to_s + directory, :verbose => false
|
25
|
+
cp file, Rails.root.to_s + path, :verbose => false
|
26
|
+
end
|
27
|
+
unless LayoutsExtension.root.starts_with? Rails.root.to_s # don't need to copy vendored tasks
|
28
|
+
puts "Copying rake tasks from LayoutsExtension"
|
29
|
+
local_tasks_path = File.join(Rails.root.to_s, %w(lib tasks))
|
30
|
+
mkdir_p local_tasks_path, :verbose => false
|
31
|
+
Dir[File.join LayoutsExtension.root, %w(lib tasks *.rake)].each do |file|
|
32
|
+
cp file, local_tasks_path, :verbose => false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Syncs all available translations for this ext to the English ext master"
|
38
|
+
task :sync => :environment do
|
39
|
+
# The main translation root, basically where English is kept
|
40
|
+
language_root = LayoutsExtension.root + "/config/locales"
|
41
|
+
words = TranslationSupport.get_translation_keys(language_root)
|
42
|
+
|
43
|
+
Dir["#{language_root}/*.yml"].each do |filename|
|
44
|
+
next if filename.match('_available_tags')
|
45
|
+
basename = File.basename(filename, '.yml')
|
46
|
+
puts "Syncing #{basename}"
|
47
|
+
(comments, other) = TranslationSupport.read_file(filename, basename)
|
48
|
+
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
49
|
+
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
|
50
|
+
TranslationSupport.write_file(filename, basename, comments, other)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# Nothing to see here
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trusty-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TrustyCms CMS dev team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -1293,12 +1293,14 @@ files:
|
|
1293
1293
|
- app/mailers/rad_social_mailer.rb
|
1294
1294
|
- app/models/deprecated_tags.rb
|
1295
1295
|
- app/models/file_not_found_page.rb
|
1296
|
+
- app/models/haml_filter.rb
|
1296
1297
|
- app/models/layout.rb
|
1297
1298
|
- app/models/menu_renderer.rb
|
1298
1299
|
- app/models/page.rb
|
1299
1300
|
- app/models/page_context.rb
|
1300
1301
|
- app/models/page_field.rb
|
1301
1302
|
- app/models/page_part.rb
|
1303
|
+
- app/models/rails_page.rb
|
1302
1304
|
- app/models/standard_tags.rb
|
1303
1305
|
- app/models/status.rb
|
1304
1306
|
- app/models/text_filter.rb
|
@@ -1343,6 +1345,7 @@ files:
|
|
1343
1345
|
- app/views/layouts/application.html.haml
|
1344
1346
|
- app/views/layouts/mail.html.haml
|
1345
1347
|
- app/views/layouts/mailer.text.haml
|
1348
|
+
- app/views/layouts/trusty.html.haml
|
1346
1349
|
- app/views/password_mailer/password_reset.html.haml
|
1347
1350
|
- app/views/rad_social_mailer/social_mail.html.haml
|
1348
1351
|
- app/views/rad_social_mailer/social_mail_form.html.haml
|
@@ -1401,6 +1404,30 @@ files:
|
|
1401
1404
|
- coverage/assets/0.10.1/smoothness/images/ui-icons_454545_256x240.png
|
1402
1405
|
- coverage/assets/0.10.1/smoothness/images/ui-icons_888888_256x240.png
|
1403
1406
|
- coverage/assets/0.10.1/smoothness/images/ui-icons_cd0a0a_256x240.png
|
1407
|
+
- coverage/assets/0.10.2/application.css
|
1408
|
+
- coverage/assets/0.10.2/application.js
|
1409
|
+
- coverage/assets/0.10.2/colorbox/border.png
|
1410
|
+
- coverage/assets/0.10.2/colorbox/controls.png
|
1411
|
+
- coverage/assets/0.10.2/colorbox/loading.gif
|
1412
|
+
- coverage/assets/0.10.2/colorbox/loading_background.png
|
1413
|
+
- coverage/assets/0.10.2/favicon_green.png
|
1414
|
+
- coverage/assets/0.10.2/favicon_red.png
|
1415
|
+
- coverage/assets/0.10.2/favicon_yellow.png
|
1416
|
+
- coverage/assets/0.10.2/loading.gif
|
1417
|
+
- coverage/assets/0.10.2/magnify.png
|
1418
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
1419
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
1420
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
1421
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
1422
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
1423
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
1424
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
1425
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
1426
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png
|
1427
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png
|
1428
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png
|
1429
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png
|
1430
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png
|
1404
1431
|
- coverage/index.html
|
1405
1432
|
- db/migrate/001_create_radiant_tables.rb
|
1406
1433
|
- db/migrate/002_insert_initial_data.rb
|
@@ -1534,6 +1561,7 @@ files:
|
|
1534
1561
|
- lib/local_time.rb
|
1535
1562
|
- lib/login_system.rb
|
1536
1563
|
- lib/method_observer.rb
|
1564
|
+
- lib/nested_layouts/tags/core.rb
|
1537
1565
|
- lib/ostruct.rb
|
1538
1566
|
- lib/simpleton.rb
|
1539
1567
|
- lib/string_extensions/string_extensions.rb
|
@@ -1632,6 +1660,15 @@ files:
|
|
1632
1660
|
- spec/spec_helper.rb
|
1633
1661
|
- spec/support/custom_actions.rb
|
1634
1662
|
- trusty_cms.gemspec
|
1663
|
+
- vendor/extensions/layouts-extension/layouts_extension.rb
|
1664
|
+
- vendor/extensions/layouts-extension/lib/haml_layouts/models/layout.rb
|
1665
|
+
- vendor/extensions/layouts-extension/lib/haml_layouts/models/page.rb
|
1666
|
+
- vendor/extensions/layouts-extension/lib/layouts/engine.rb
|
1667
|
+
- vendor/extensions/layouts-extension/lib/nested_layouts/tags/core.rb
|
1668
|
+
- vendor/extensions/layouts-extension/lib/share_layouts/controllers/action_controller.rb
|
1669
|
+
- vendor/extensions/layouts-extension/lib/share_layouts/helpers/action_view.rb
|
1670
|
+
- vendor/extensions/layouts-extension/lib/tasks/layouts_extension_tasks.rake
|
1671
|
+
- vendor/extensions/layouts-extension/lib/trusty-layouts-extension.rb
|
1635
1672
|
homepage: https://github.com/pgharts/trusty-cms
|
1636
1673
|
licenses:
|
1637
1674
|
- MIT
|