releaf-core 1.0.10 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca323310f4d59facd1e6408a4eb506971b5cc276
4
- data.tar.gz: 81a3f6d2d484930fb106606b032eb85968ee910b
3
+ metadata.gz: b20117c8f011eeb352f897d424a54c9aca0da121
4
+ data.tar.gz: f350cbf3d9c4c8428b023457e0ad705c633f9af0
5
5
  SHA512:
6
- metadata.gz: 9a46e111961604581a9bde9e10866cabe2c1dfc6f7c58ffee02780308146e9cce844cb2f44c7b6d4d47d7721cfe43ffc3dcf51f8f770205bd83360769b218dcc
7
- data.tar.gz: b7c436977a939f69a28e6af94c1441c7224276f86ce906f3d590a3761e11bde626e90f375c6acabb6259ee18a492323ef5c93786a477ee5bae0c81049afaccde
6
+ metadata.gz: fe61243ff475a95c0fea93023b5a3e83f212e981c3ad2871315d411cf9f396affbb4f3bb3ca7f46ce97edf7b1aa71da887270283e7550017d80a4427da97f1fb
7
+ data.tar.gz: aa0c250c7a029ef6dbee115b458ed1135eda3ea7571c70ee13f4aad45a62fb84ba6d19a59a0a143a41929ecdaf9a9a2c1e917ca296d70575f0528bda5a13c32a
@@ -84,9 +84,17 @@ jQuery(function()
84
84
  textarea.attr( 'id', 'richtext_' + String((new Date()).getTime()).replace(/\D/gi,'') );
85
85
  }
86
86
 
87
- if (textarea.data('attachment-upload-url'))
87
+ if (textarea.data('attachment-upload-url') || textarea.data('attachment-browse-url'))
88
88
  {
89
- config.filebrowserUploadUrl = textarea.data('attachment-upload-url');
89
+ if (textarea.data('attachment-browse-url'))
90
+ {
91
+ config.filebrowserBrowseUrl = textarea.data('attachment-browse-url');
92
+ }
93
+
94
+ if (textarea.data('attachment-upload-url'))
95
+ {
96
+ config.filebrowserUploadUrl = textarea.data('attachment-upload-url');
97
+ }
90
98
  }
91
99
  else
92
100
  {
@@ -12,12 +12,16 @@ main
12
12
  position: relative;
13
13
  min-height: 100%;
14
14
  }
15
+ body[data-layout-features~="sidebar"] > main
16
+ {
17
+ padding-left: steps(20 + 3);
18
+ }
15
19
 
16
20
  main
17
21
  {
18
22
  display: block; /* as of now, not all rendering engines recognize the main element as a block */
19
23
  position: relative;
20
- padding: 0 steps(3) steps(4) steps(20 + 3);
24
+ padding: 0 steps(3) steps(4) steps(3);
21
25
  z-index: 1;
22
26
 
23
27
  .side-compact &
@@ -21,20 +21,30 @@ module Releaf::Builders::Page
21
21
 
22
22
  def body
23
23
  tag(:body, body_atttributes) do
24
- body_content{ yield } << assets(:javascripts, :javascript_include_tag)
24
+ safe_join{ body_content_blocks{ yield } }
25
25
  end
26
26
  end
27
27
 
28
28
  def body_atttributes
29
- {class: body_classes, "data-settings-path" => settings_path}
29
+ {class: body_classes, "data-settings-path" => settings_path, "data-layout-features" => features.join(" ")}
30
30
  end
31
31
 
32
32
  def settings_path
33
33
  url_for(action: "store_settings", controller: "/releaf/root", only_path: true)
34
34
  end
35
35
 
36
- def body_content(&block)
37
- header << menu << tag(:main, id: "main", &block) << notifications
36
+ def feature_available?(feature)
37
+ features.include? feature
38
+ end
39
+
40
+ def body_content_blocks
41
+ parts = []
42
+ parts << header if feature_available?(:header)
43
+ parts << menu if feature_available?(:sidebar)
44
+ parts << tag(:main, id: :main){ yield } if feature_available?(:main)
45
+ parts << notifications
46
+ parts << assets(:javascripts, :javascript_include_tag)
47
+ parts
38
48
  end
39
49
 
40
50
  def notifications
@@ -57,6 +67,10 @@ module Releaf::Builders::Page
57
67
  Releaf::Builders::Page::MenuBuilder
58
68
  end
59
69
 
70
+ def features
71
+ controller.layout_features
72
+ end
73
+
60
74
  def assets(type, tag_method)
61
75
  safe_join do
62
76
  send(type).collect do |asset|
@@ -13,6 +13,7 @@ class Releaf::ActionController < ActionController::Base
13
13
  include Releaf::ActionController::Breadcrumbs
14
14
  include Releaf::ActionController::RichtextAttachments
15
15
  include Releaf::ActionController::Views
16
+ include Releaf::ActionController::Layout
16
17
  include Releaf::Responders
17
18
 
18
19
  helper_method :controller_scope_name, :page_title
@@ -0,0 +1,7 @@
1
+ module Releaf::ActionController::Layout
2
+ extend ActiveSupport::Concern
3
+
4
+ def layout_features
5
+ [:header, :sidebar, :main]
6
+ end
7
+ end
@@ -47,6 +47,14 @@ describe Releaf::Builders::Page::LayoutBuilder, type: :class do
47
47
  end
48
48
  end
49
49
 
50
+ describe "#features" do
51
+ it "returns controller layout features" do
52
+ allow(subject).to receive(:controller).and_return(NewRolesController.new)
53
+ allow(subject.controller).to receive(:layout_features).and_return([:a, :c])
54
+ expect(subject.features).to eq([:a, :c])
55
+ end
56
+ end
57
+
50
58
  describe "#header_builder" do
51
59
  it "returns `Releaf::Builders::Page::HeaderBuilder` class" do
52
60
  expect(subject.header_builder).to eq(Releaf::Builders::Page::HeaderBuilder)
@@ -59,6 +67,20 @@ describe Releaf::Builders::Page::LayoutBuilder, type: :class do
59
67
  end
60
68
  end
61
69
 
70
+ describe "#feature_available?" do
71
+ before do
72
+ allow(subject).to receive(:features).and_return([:a, :b])
73
+ end
74
+
75
+ it "returns true when feature is available" do
76
+ expect(subject.feature_available?(:a)).to be true
77
+ end
78
+
79
+ it "returns false when feature is not available" do
80
+ expect(subject.feature_available?(:c)).to be false
81
+ end
82
+ end
83
+
62
84
  describe "#stylesheets" do
63
85
  it "returns stylesheets from assets resolver for given controller" do
64
86
  allow(subject).to receive(:assets_resolver).and_return(DummyAssetsResolver)
@@ -111,10 +133,52 @@ describe Releaf::Builders::Page::LayoutBuilder, type: :class do
111
133
 
112
134
  describe "#body" do
113
135
  it "returns body with body attributes and" do
114
- allow(subject).to receive(:assets).with(:javascripts, :javascript_include_tag).and_return("_assets_")
115
136
  allow(subject).to receive(:body_atttributes).and_return(class: ["xx", "y"], id: "121212")
116
- allow(subject).to receive(:body_content){|*args, &block| expect(block.call).to eq("x") }.and_return("body content")
117
- expect(subject.body{ "x" }).to eq("<body class=\"xx y\" id=\"121212\">body content_assets_</body>")
137
+ allow(subject).to receive(:body_content_blocks){|*args, &block| expect(block.call).to eq("x") }
138
+ .and_return(["a<b>".html_safe, "b<i>", "c<d>".html_safe])
139
+ expect(subject.body{ "x" }).to eq("<body class=\"xx y\" id=\"121212\">a<b>b&lt;i&gt;c<d></body>")
140
+ end
141
+ end
142
+
143
+ #parts = []
144
+ #parts << header if feature_available?(:header)
145
+ #parts << menu if feature_available?(:sidebar)
146
+ #parts << tag(:main, id: "main"){ yield } if feature_available?(:main)
147
+ #parts << notifications
148
+ #parts << assets(:javascripts, :javascript_include_tag)
149
+ #parts
150
+
151
+
152
+ describe "#body_content_blocks" do
153
+ before do
154
+ allow(subject).to receive(:feature_available?).with(:header).and_return(true)
155
+ allow(subject).to receive(:feature_available?).with(:sidebar).and_return(true)
156
+ allow(subject).to receive(:feature_available?).with(:main).and_return(true)
157
+
158
+ allow(subject).to receive(:assets).with(:javascripts, :javascript_include_tag).and_return("_assets_")
159
+ allow(subject).to receive(:header).and_return("_header_")
160
+ allow(subject).to receive(:menu).and_return("_menu_")
161
+ allow(subject).to receive(:notifications).and_return("_notifications_")
162
+ allow(subject).to receive(:tag).with(:main, id: :main){|*args, &block| expect(block.call).to eq("x") }.and_return("body content")
163
+ end
164
+
165
+ it "returns body with body attributes and" do
166
+ expect(subject.body_content_blocks{ "x" }).to eq(["_header_", "_menu_", "body content", "_notifications_", "_assets_"])
167
+ end
168
+
169
+ it "skips header when header feature not available" do
170
+ allow(subject).to receive(:feature_available?).with(:header).and_return(false)
171
+ expect(subject.body_content_blocks{ "x" }).to eq(["_menu_", "body content", "_notifications_", "_assets_"])
172
+ end
173
+
174
+ it "skips menu when sidebar feature not available" do
175
+ allow(subject).to receive(:feature_available?).with(:sidebar).and_return(false)
176
+ expect(subject.body_content_blocks{ "x" }).to eq(["_header_", "body content", "_notifications_", "_assets_"])
177
+ end
178
+
179
+ it "skips main conrtent when main feature not available" do
180
+ allow(subject).to receive(:feature_available?).with(:main).and_return(false)
181
+ expect(subject.body_content_blocks{ "x" }).to eq(["_header_", "_menu_", "_notifications_", "_assets_"])
118
182
  end
119
183
  end
120
184
 
@@ -134,10 +198,13 @@ describe Releaf::Builders::Page::LayoutBuilder, type: :class do
134
198
  end
135
199
 
136
200
  describe "#body_atttributes" do
137
- it "returns hash with classes and data-settings-path" do
201
+ it "returns hash with classes, data-settings-path and data-layout-features" do
202
+ allow(subject).to receive(:features).and_return([:top, :bottom])
138
203
  allow(subject).to receive(:controller_body_classes).and_return(["a", "b"])
139
204
  allow(subject).to receive(:settings_path).and_return("/xxx/sett")
140
- expect(subject.body_atttributes).to eq(class: ["application-dummy", "a", "b"], "data-settings-path" => "/xxx/sett")
205
+ expect(subject.body_atttributes).to eq(class: ["application-dummy", "a", "b"],
206
+ "data-settings-path" => "/xxx/sett",
207
+ "data-layout-features" => "top bottom")
141
208
  end
142
209
  end
143
210
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releaf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -395,6 +395,7 @@ files:
395
395
  - app/lib/releaf/action_controller/breadcrumbs.rb
396
396
  - app/lib/releaf/action_controller/builders.rb
397
397
  - app/lib/releaf/action_controller/features.rb
398
+ - app/lib/releaf/action_controller/layout.rb
398
399
  - app/lib/releaf/action_controller/notifications.rb
399
400
  - app/lib/releaf/action_controller/resources.rb
400
401
  - app/lib/releaf/action_controller/richtext_attachments.rb