lookbook 2.0.0.rc.1 → 2.0.0.rc.2
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/lookbook/with_preview_controller_concern.rb +16 -5
- data/app/views/lookbook/previews/preview.html.erb +5 -1
- data/config/app.yml +1 -1
- data/lib/lookbook/helpers/preview_helper.rb +0 -4
- data/lib/lookbook/preview_controller_actions.rb +42 -41
- data/lib/lookbook/version.rb +1 -1
- data/public/lookbook-assets/js/index.js +57 -57
- data/public/lookbook-assets/js/index.js.map +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e65ff18c2a7f112552e6b9a7ef3936628b84690a03123736bfbd2d69734319a
|
4
|
+
data.tar.gz: 841ccc4584b2b66bf165f822a3be984370d9bc0df0095ded20ef9800e5f76877
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e67bf7cf970cfb18166050d582b8daf29a9d13ceec465ce7e9ad49c3fdd12f04b9d5a72bba7786cb62be56a8be29464e34602f9758d68660b1f38bf0f2cddec
|
7
|
+
data.tar.gz: 50b18c05c31bd207acc07f40a07a564926aae7865f0770fe1612bab661a8342418fe3662f50a2fbfa13f105c48b66786e8ed67c261eb96962182b7abf63357ea
|
@@ -3,12 +3,23 @@ module Lookbook
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def preview_controller
|
6
|
-
|
6
|
+
@_preview_controller ||= begin
|
7
|
+
# In order to get URL helpers working correctly in the preview,
|
8
|
+
# the request needs to look like it's coming from the host app,
|
9
|
+
# not the Lookbook engine. So we try to get the controller and action
|
10
|
+
# for the root path and use that as the 'fake' request context instead.
|
11
|
+
request_path = main_app.respond_to?(:root_path) ? main_app.root_path : "/"
|
12
|
+
path_parameters = Rails.application.routes.recognize_path(request_path)
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
preview_request = request.clone
|
15
|
+
preview_request.path_parameters = path_parameters if path_parameters.present?
|
16
|
+
|
17
|
+
controller = Engine.preview_controller.new
|
18
|
+
controller.request = preview_request
|
19
|
+
controller.response = response
|
20
|
+
|
21
|
+
controller
|
22
|
+
end
|
12
23
|
end
|
13
24
|
end
|
14
25
|
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
<% if @render_args[:component] %>
|
2
|
-
|
2
|
+
<% if defined?(Phlex::SGML) && @render_args[:component].is_a?(Phlex::SGML) %>
|
3
|
+
<%= raw(@render_args[:component].call(view_context: self, &@render_args[:block])) %>
|
4
|
+
<% else %>
|
5
|
+
<%= render(@render_args[:component], @render_args[:args], &@render_args[:block]) %>
|
6
|
+
<% end %>
|
3
7
|
<% else %>
|
4
8
|
<%= render(@render_args[:template], **@render_args[:locals], &@render_args[:block]) %>
|
5
9
|
<% end %>
|
data/config/app.yml
CHANGED
@@ -4,57 +4,58 @@ module Lookbook
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
helper PreviewHelper
|
7
|
+
helper Rails.application.routes.url_helpers
|
7
8
|
prepend_view_path Engine.root.join("app/views")
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
11
|
+
def render_scenario_to_string(preview, scenario)
|
12
|
+
prepend_application_view_paths
|
13
|
+
prepend_preview_examples_view_path
|
14
|
+
|
15
|
+
@preview = preview
|
16
|
+
@scenario_name = scenario.name
|
17
|
+
@render_args = @preview.render_args(@scenario_name, params: params.permit!)
|
18
|
+
template = @render_args[:template]
|
19
|
+
locals = @render_args[:locals]
|
20
|
+
opts = {}
|
21
|
+
opts[:layout] = nil
|
22
|
+
opts[:locals] = locals if locals.present?
|
23
|
+
|
24
|
+
rendered = render_to_string(template, **opts)
|
25
|
+
|
26
|
+
if scenario.after_render_method.present?
|
27
|
+
render_context = Store.new({
|
28
|
+
preview: preview,
|
29
|
+
scenario: scenario,
|
30
|
+
params: user_request_parameters
|
31
|
+
})
|
32
|
+
rendered = @preview.after_render(method: scenario.after_render_method, html: rendered, context: render_context)
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
35
|
+
with_optional_action_view_annotations do
|
36
|
+
render html: rendered
|
36
37
|
end
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
render html: html
|
40
|
+
def render_in_layout_to_string(template, locals, opts = {})
|
41
|
+
with_optional_action_view_annotations do
|
42
|
+
html = render_to_string(template, locals: locals, **determine_layout(opts[:layout]))
|
43
|
+
if opts[:append_html].present?
|
44
|
+
html += opts[:append_html]
|
45
45
|
end
|
46
|
+
render html: html
|
46
47
|
end
|
48
|
+
end
|
47
49
|
|
48
|
-
|
50
|
+
protected
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
def with_optional_action_view_annotations(&block)
|
53
|
+
disable = Lookbook.config.preview_disable_action_view_annotations
|
54
|
+
ActionViewAnnotationsHandler.call(disable_annotations: disable, &block)
|
55
|
+
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
57
|
+
def user_request_parameters
|
58
|
+
request.query_parameters.to_h.filter { |k, v| !k.start_with?("_") }
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
data/lib/lookbook/version.rb
CHANGED
@@ -7815,7 +7815,49 @@ function $12b7aa006b8a97e1$var$toCamel(s) {
|
|
7815
7815
|
}
|
7816
7816
|
|
7817
7817
|
|
7818
|
-
var $
|
7818
|
+
var $57df4ec1d6bb80f5$exports = {};
|
7819
|
+
var $47a1c62621be0c54$exports = {};
|
7820
|
+
|
7821
|
+
$parcel$defineInteropFlag($47a1c62621be0c54$exports);
|
7822
|
+
|
7823
|
+
$parcel$export($47a1c62621be0c54$exports, "default", () => $47a1c62621be0c54$export$2e2bcd8739ae039);
|
7824
|
+
var $4e31c85e11272811$exports = {};
|
7825
|
+
|
7826
|
+
$parcel$defineInteropFlag($4e31c85e11272811$exports);
|
7827
|
+
|
7828
|
+
$parcel$export($4e31c85e11272811$exports, "initClipboard", () => $4e31c85e11272811$export$c6684e6159b21de3);
|
7829
|
+
$parcel$export($4e31c85e11272811$exports, "default", () => $4e31c85e11272811$export$2e2bcd8739ae039);
|
7830
|
+
|
7831
|
+
function $4e31c85e11272811$export$c6684e6159b21de3(context = {}) {
|
7832
|
+
let copyTimeout = null;
|
7833
|
+
return Object.assign(context, {
|
7834
|
+
copied: false,
|
7835
|
+
async copyToClipboard (target = null) {
|
7836
|
+
let targetEl;
|
7837
|
+
if (this.$refs.copyTarget) targetEl = this.$refs.copyTarget;
|
7838
|
+
else if (typeof target === "string") targetEl = document.querySelector(target);
|
7839
|
+
if (!targetEl) {
|
7840
|
+
this.warn("Could not find copy target");
|
7841
|
+
return false;
|
7842
|
+
}
|
7843
|
+
const content = (0, $fb8f79f7dd40b68f$export$6cb344a21ca18aec)(targetEl.innerHTML.trim());
|
7844
|
+
await window.navigator.clipboard.writeText(content);
|
7845
|
+
this.copied = true;
|
7846
|
+
if (copyTimeout) clearTimeout(copyTimeout);
|
7847
|
+
copyTimeout = setTimeout(()=>{
|
7848
|
+
this.copied = false;
|
7849
|
+
this.onCopyComplete();
|
7850
|
+
}, 1000);
|
7851
|
+
return content;
|
7852
|
+
},
|
7853
|
+
onCopyComplete () {}
|
7854
|
+
});
|
7855
|
+
}
|
7856
|
+
function $4e31c85e11272811$export$2e2bcd8739ae039() {
|
7857
|
+
return $4e31c85e11272811$export$c6684e6159b21de3({});
|
7858
|
+
}
|
7859
|
+
|
7860
|
+
|
7819
7861
|
var $cbd28b10fa9798c7$exports = {};
|
7820
7862
|
|
7821
7863
|
$parcel$defineInteropFlag($cbd28b10fa9798c7$exports);
|
@@ -11346,59 +11388,6 @@ function $cbd28b10fa9798c7$export$2e2bcd8739ae039() {
|
|
11346
11388
|
}
|
11347
11389
|
|
11348
11390
|
|
11349
|
-
var $99486586f6691564$exports = {};
|
11350
|
-
|
11351
|
-
$parcel$defineInteropFlag($99486586f6691564$exports);
|
11352
|
-
|
11353
|
-
$parcel$export($99486586f6691564$exports, "default", () => $99486586f6691564$export$2e2bcd8739ae039);
|
11354
|
-
function $99486586f6691564$export$2e2bcd8739ae039() {
|
11355
|
-
return {};
|
11356
|
-
}
|
11357
|
-
|
11358
|
-
|
11359
|
-
var $47a1c62621be0c54$exports = {};
|
11360
|
-
|
11361
|
-
$parcel$defineInteropFlag($47a1c62621be0c54$exports);
|
11362
|
-
|
11363
|
-
$parcel$export($47a1c62621be0c54$exports, "default", () => $47a1c62621be0c54$export$2e2bcd8739ae039);
|
11364
|
-
var $4e31c85e11272811$exports = {};
|
11365
|
-
|
11366
|
-
$parcel$defineInteropFlag($4e31c85e11272811$exports);
|
11367
|
-
|
11368
|
-
$parcel$export($4e31c85e11272811$exports, "initClipboard", () => $4e31c85e11272811$export$c6684e6159b21de3);
|
11369
|
-
$parcel$export($4e31c85e11272811$exports, "default", () => $4e31c85e11272811$export$2e2bcd8739ae039);
|
11370
|
-
|
11371
|
-
function $4e31c85e11272811$export$c6684e6159b21de3(context = {}) {
|
11372
|
-
let copyTimeout = null;
|
11373
|
-
return Object.assign(context, {
|
11374
|
-
copied: false,
|
11375
|
-
async copyToClipboard (target = null) {
|
11376
|
-
let targetEl;
|
11377
|
-
if (this.$refs.copyTarget) targetEl = this.$refs.copyTarget;
|
11378
|
-
else if (typeof target === "string") targetEl = document.querySelector(target);
|
11379
|
-
if (!targetEl) {
|
11380
|
-
this.warn("Could not find copy target");
|
11381
|
-
return false;
|
11382
|
-
}
|
11383
|
-
const content = (0, $fb8f79f7dd40b68f$export$6cb344a21ca18aec)(targetEl.innerHTML.trim());
|
11384
|
-
await window.navigator.clipboard.writeText(content);
|
11385
|
-
this.copied = true;
|
11386
|
-
if (copyTimeout) clearTimeout(copyTimeout);
|
11387
|
-
copyTimeout = setTimeout(()=>{
|
11388
|
-
this.copied = false;
|
11389
|
-
this.onCopyComplete();
|
11390
|
-
}, 1000);
|
11391
|
-
return content;
|
11392
|
-
},
|
11393
|
-
onCopyComplete () {}
|
11394
|
-
});
|
11395
|
-
}
|
11396
|
-
function $4e31c85e11272811$export$2e2bcd8739ae039() {
|
11397
|
-
return $4e31c85e11272811$export$c6684e6159b21de3({});
|
11398
|
-
}
|
11399
|
-
|
11400
|
-
|
11401
|
-
|
11402
11391
|
function $47a1c62621be0c54$export$2e2bcd8739ae039() {
|
11403
11392
|
const button = (0, $cbd28b10fa9798c7$export$2e2bcd8739ae039)();
|
11404
11393
|
return {
|
@@ -11412,6 +11401,17 @@ function $47a1c62621be0c54$export$2e2bcd8739ae039() {
|
|
11412
11401
|
}
|
11413
11402
|
|
11414
11403
|
|
11404
|
+
|
11405
|
+
var $99486586f6691564$exports = {};
|
11406
|
+
|
11407
|
+
$parcel$defineInteropFlag($99486586f6691564$exports);
|
11408
|
+
|
11409
|
+
$parcel$export($99486586f6691564$exports, "default", () => $99486586f6691564$export$2e2bcd8739ae039);
|
11410
|
+
function $99486586f6691564$export$2e2bcd8739ae039() {
|
11411
|
+
return {};
|
11412
|
+
}
|
11413
|
+
|
11414
|
+
|
11415
11415
|
var $e398acaded942bbe$exports = {};
|
11416
11416
|
|
11417
11417
|
$parcel$defineInteropFlag($e398acaded942bbe$exports);
|
@@ -12336,10 +12336,10 @@ function $6d64716f0b34fdf4$export$2e2bcd8739ae039(store) {
|
|
12336
12336
|
}
|
12337
12337
|
|
12338
12338
|
|
12339
|
-
$
|
12339
|
+
$57df4ec1d6bb80f5$exports = {
|
12340
|
+
"copy_button": $47a1c62621be0c54$exports,
|
12340
12341
|
"button": $cbd28b10fa9798c7$exports,
|
12341
12342
|
"code": $99486586f6691564$exports,
|
12342
|
-
"copy_button": $47a1c62621be0c54$exports,
|
12343
12343
|
"dimensions_display": $e398acaded942bbe$exports,
|
12344
12344
|
"embed_code_dropdown": $216ef7001f59f21d$exports,
|
12345
12345
|
"filter": $e9904a14dabf652d$exports,
|
@@ -13521,7 +13521,7 @@ const $22969b543678f572$var$prefix = window.APP_NAME;
|
|
13521
13521
|
// Components
|
13522
13522
|
(0, $caa9439642c6336c$export$2e2bcd8739ae039).data("app", (0, $5792afa4170ed552$export$2e2bcd8739ae039));
|
13523
13523
|
[
|
13524
|
-
$
|
13524
|
+
$57df4ec1d6bb80f5$exports,
|
13525
13525
|
$3b154185c6273749$exports,
|
13526
13526
|
$338da9a25bc5c332$exports
|
13527
13527
|
].forEach((scripts)=>{
|