lookbook 2.0.0.beta.2 → 2.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/lookbook/css/fonts.css +33 -0
- data/app/assets/lookbook/css/lookbook.css +7 -0
- data/app/assets/lookbook/css/themes/blue.css +4 -1
- data/app/assets/lookbook/css/themes/green.css +4 -1
- data/app/assets/lookbook/css/themes/indigo.css +4 -1
- data/app/assets/lookbook/css/themes/rose.css +4 -1
- data/app/assets/lookbook/css/themes/zinc.css +4 -1
- data/app/assets/lookbook/fonts/Inter-italic.var.woff2 +0 -0
- data/app/assets/lookbook/fonts/Inter-roman.var.woff2 +0 -0
- data/app/assets/lookbook/fonts/SourceCodeVariable-Italic.ttf.woff2 +0 -0
- data/app/assets/lookbook/fonts/SourceCodeVariable-Roman.ttf.woff2 +0 -0
- data/app/assets/lookbook/img/lucide-sprite.svg +869 -869
- data/app/assets/lookbook/js/lib/lookbook.js +12 -2
- data/app/components/lookbook/code/highlight_github.css +16 -17
- data/app/components/lookbook/dimensions_display/component.js +4 -7
- data/app/components/lookbook/file_source/component.html.erb +9 -0
- data/app/components/lookbook/file_source/component.rb +73 -0
- data/app/components/lookbook/header/component.html.erb +11 -8
- data/app/components/lookbook/icon/component.css +1 -1
- data/app/components/lookbook/icon/component.html.erb +1 -1
- data/app/components/lookbook/icon/component.rb +4 -1
- data/app/components/lookbook/logo/component.html.erb +6 -0
- data/app/components/lookbook/logo/component.rb +15 -0
- data/app/components/lookbook/message/component.css +33 -0
- data/app/components/lookbook/message/component.html.erb +26 -0
- data/app/components/lookbook/message/component.rb +13 -0
- data/app/components/lookbook/nav/entity/component.html.erb +2 -2
- data/app/components/lookbook/nav/entity/component.rb +1 -1
- data/app/components/lookbook/page_tabs/component.html.erb +2 -2
- data/app/components/lookbook/params/field/component.css +3 -3
- data/app/components/lookbook/prose/component.css +8 -1
- data/app/components/lookbook/prose/component.html.erb +6 -1
- data/app/components/lookbook/prose/component.rb +2 -2
- data/app/controllers/concerns/lookbook/targetable_concern.rb +2 -16
- data/app/controllers/lookbook/application_controller.rb +38 -14
- data/app/controllers/lookbook/embeds_controller.rb +3 -4
- data/app/controllers/lookbook/inspector_controller.rb +4 -12
- data/app/controllers/lookbook/pages_controller.rb +15 -27
- data/app/controllers/lookbook/preview_controller.rb +30 -2
- data/app/controllers/lookbook/previews_controller.rb +13 -15
- data/app/views/layouts/lookbook/application.html.erb +1 -0
- data/app/views/layouts/lookbook/skeleton.html.erb +2 -2
- data/app/views/lookbook/errors/default.html.erb +40 -0
- data/app/views/lookbook/errors/not_found.html.erb +10 -0
- data/app/views/lookbook/index.html.erb +29 -24
- data/app/views/lookbook/pages/show.html.erb +9 -8
- data/app/views/lookbook/partials/_blank_slate.html.erb +7 -0
- data/config/app.yml +8 -0
- data/config/routes.rb +2 -0
- data/lib/lookbook/engine.rb +12 -5
- data/lib/lookbook/entities/concerns/annotatable_entity.rb +26 -1
- data/lib/lookbook/entities/concerns/inspectable_entity.rb +17 -2
- data/lib/lookbook/entities/concerns/locatable_entity.rb +51 -7
- data/lib/lookbook/entities/concerns/navigable_entity.rb +14 -1
- data/lib/lookbook/entities/entity.rb +34 -12
- data/lib/lookbook/entities/page_entity.rb +68 -10
- data/lib/lookbook/entities/page_section_entity.rb +4 -0
- data/lib/lookbook/entities/preview_entity.rb +107 -17
- data/lib/lookbook/entities/renderable_entity.rb +47 -9
- data/lib/lookbook/entities/rendered_scenario_entity.rb +17 -6
- data/lib/lookbook/entities/scenario_entity.rb +77 -16
- data/lib/lookbook/entities/scenario_group_entity.rb +82 -9
- data/lib/lookbook/helpers/page_helper.rb +26 -1
- data/lib/lookbook/helpers/ui_elements_helper.rb +0 -24
- data/lib/lookbook/param.rb +1 -1
- data/lib/lookbook/services/markdown_renderer.rb +2 -4
- data/lib/lookbook/stores/config_store.rb +0 -12
- data/lib/lookbook/support/errors/config_error.rb +1 -1
- data/lib/lookbook/support/errors/error.rb +64 -0
- data/lib/lookbook/support/errors/parser_error.rb +1 -1
- data/lib/lookbook/support/errors/preview_template_error.rb +1 -1
- data/lib/lookbook/support/errors/routing_error.rb +7 -0
- data/lib/lookbook/support/errors/template_error.rb +7 -0
- data/lib/lookbook/version.rb +1 -1
- data/public/lookbook-assets/Inter-italic.var.69eb0fe1.woff2 +0 -0
- data/public/lookbook-assets/Inter-italic.var.736a7044.woff2 +0 -0
- data/public/lookbook-assets/Inter-roman.var.b695afbe.woff2 +0 -0
- data/public/lookbook-assets/Inter-roman.var.fbdd51d0.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Italic.cad97b83.otf +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Italic.ttf.09b4354a.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Italic.ttf.fcd7e9f4.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Roman.185ddb17.otf +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Roman.ttf.118e9f22.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Roman.ttf.91043609.woff2 +0 -0
- data/public/lookbook-assets/css/lookbook.css +417 -58
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/css/themes/blue.css +4 -1
- data/public/lookbook-assets/css/themes/blue.css.map +1 -1
- data/public/lookbook-assets/css/themes/green.css +4 -1
- data/public/lookbook-assets/css/themes/green.css.map +1 -1
- data/public/lookbook-assets/css/themes/indigo.css +4 -1
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
- data/public/lookbook-assets/css/themes/rose.css +4 -1
- data/public/lookbook-assets/css/themes/rose.css.map +1 -1
- data/public/lookbook-assets/css/themes/zinc.css +4 -1
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
- data/public/lookbook-assets/img/lucide-sprite.svg +869 -869
- data/public/lookbook-assets/js/index.js +173 -173
- data/public/lookbook-assets/js/index.js.map +1 -1
- data/public/lookbook-assets/js/lookbook-core.js +4 -2
- data/public/lookbook-assets/js/lookbook.js +4 -2
- metadata +31 -26
- data/app/views/layouts/lookbook/shell.html.erb +0 -25
- data/app/views/lookbook/404.html.erb +0 -15
- data/app/views/lookbook/error.html.erb +0 -46
- data/lib/lookbook/error.rb +0 -120
- data/lib/lookbook/support/errors/lookbook_error.rb +0 -21
- data/lib/tasks/lookbook_tasks.rake +0 -10
- data/public/lookbook-assets/css/app.css +0 -2341
- data/public/lookbook-assets/css/app.css.map +0 -11
- data/public/lookbook-assets/css/themes/zinc.css.map.91837.5 +0 -1
- data/public/lookbook-assets/feather-sprite.svg +0 -1
- data/public/lookbook-assets/js/app.js +0 -10862
- data/public/lookbook-assets/js/app.js.map +0 -2571
- data/public/lookbook-assets/js/embed.js +0 -1427
- data/public/lookbook-assets/js/embed.js.91837.6 +0 -0
- data/public/lookbook-assets/js/embed.js.map +0 -1
- data/public/lookbook-assets/js/lookbook-core.js.map +0 -1
- data/public/lookbook-assets/js/lookbook.js.map +0 -1
- data/public/lookbook-assets/lookbook-esm.js +0 -1427
- data/public/lookbook-assets/lookbook-esm.js.map +0 -1
- data/public/lookbook-assets/lookbook-global.js +0 -1427
- data/public/lookbook-assets/lookbook-global.js.map +0 -1
- data/public/lookbook-assets/lookbook.js +0 -1427
- data/public/lookbook-assets/lookbook.js.map +0 -1
@@ -9,12 +9,14 @@ const $8c6f87050723dba0$var$whiteListedAttributes = [
|
|
9
9
|
"actions",
|
10
10
|
"param-*"
|
11
11
|
];
|
12
|
-
function $8c6f87050723dba0$var$initEmbeds() {
|
12
|
+
function $8c6f87050723dba0$var$initEmbeds(root = document) {
|
13
13
|
if (typeof window.iFrameResize !== "function") {
|
14
14
|
console.error("Lookbook embeds require the 'iframe-resizer' library to be available. Skipping embed instantiation.");
|
15
15
|
return;
|
16
16
|
}
|
17
|
-
|
17
|
+
if (typeof root === "string") root = document.querySelector(root);
|
18
|
+
if (!root) return console.error("Could not initialize Lookbook embeds. Root node not found.");
|
19
|
+
const embeds = Array.from(root.querySelectorAll("lookbook-embed"));
|
18
20
|
embeds.forEach((embed)=>{
|
19
21
|
const attrs = Array.from(embed.attributes);
|
20
22
|
const wrapper = $8c6f87050723dba0$var$createWrapper();
|
@@ -848,12 +848,14 @@ const $8c6f87050723dba0$var$whiteListedAttributes = [
|
|
848
848
|
"actions",
|
849
849
|
"param-*"
|
850
850
|
];
|
851
|
-
function $8c6f87050723dba0$var$initEmbeds() {
|
851
|
+
function $8c6f87050723dba0$var$initEmbeds(root = document) {
|
852
852
|
if (typeof window.iFrameResize !== "function") {
|
853
853
|
console.error("Lookbook embeds require the 'iframe-resizer' library to be available. Skipping embed instantiation.");
|
854
854
|
return;
|
855
855
|
}
|
856
|
-
|
856
|
+
if (typeof root === "string") root = document.querySelector(root);
|
857
|
+
if (!root) return console.error("Could not initialize Lookbook embeds. Root node not found.");
|
858
|
+
const embeds = Array.from(root.querySelectorAll("lookbook-embed"));
|
857
859
|
embeds.forEach((embed)=>{
|
858
860
|
const attrs = Array.from(embed.attributes);
|
859
861
|
const wrapper = $8c6f87050723dba0$var$createWrapper();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Perkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: css_parser
|
@@ -164,6 +164,7 @@ extra_rdoc_files: []
|
|
164
164
|
files:
|
165
165
|
- LICENSE.txt
|
166
166
|
- README.md
|
167
|
+
- app/assets/lookbook/css/fonts.css
|
167
168
|
- app/assets/lookbook/css/lookbook.css
|
168
169
|
- app/assets/lookbook/css/themes/blue.css
|
169
170
|
- app/assets/lookbook/css/themes/green.css
|
@@ -171,6 +172,10 @@ files:
|
|
171
172
|
- app/assets/lookbook/css/themes/rose.css
|
172
173
|
- app/assets/lookbook/css/themes/zinc.css
|
173
174
|
- app/assets/lookbook/css/tooltip.css
|
175
|
+
- app/assets/lookbook/fonts/Inter-italic.var.woff2
|
176
|
+
- app/assets/lookbook/fonts/Inter-roman.var.woff2
|
177
|
+
- app/assets/lookbook/fonts/SourceCodeVariable-Italic.ttf.woff2
|
178
|
+
- app/assets/lookbook/fonts/SourceCodeVariable-Roman.ttf.woff2
|
174
179
|
- app/assets/lookbook/img/lucide-sprite.svg
|
175
180
|
- app/assets/lookbook/js/app.js
|
176
181
|
- app/assets/lookbook/js/components/clipboard.js
|
@@ -231,6 +236,8 @@ files:
|
|
231
236
|
- app/components/lookbook/embed_code_dropdown/component.html.erb
|
232
237
|
- app/components/lookbook/embed_code_dropdown/component.js
|
233
238
|
- app/components/lookbook/embed_code_dropdown/component.rb
|
239
|
+
- app/components/lookbook/file_source/component.html.erb
|
240
|
+
- app/components/lookbook/file_source/component.rb
|
234
241
|
- app/components/lookbook/filter/component.html.erb
|
235
242
|
- app/components/lookbook/filter/component.js
|
236
243
|
- app/components/lookbook/filter/component.rb
|
@@ -245,6 +252,11 @@ files:
|
|
245
252
|
- app/components/lookbook/inspector_panel/component.css
|
246
253
|
- app/components/lookbook/inspector_panel/component.html.erb
|
247
254
|
- app/components/lookbook/inspector_panel/component.rb
|
255
|
+
- app/components/lookbook/logo/component.html.erb
|
256
|
+
- app/components/lookbook/logo/component.rb
|
257
|
+
- app/components/lookbook/message/component.css
|
258
|
+
- app/components/lookbook/message/component.html.erb
|
259
|
+
- app/components/lookbook/message/component.rb
|
248
260
|
- app/components/lookbook/nav/component.html.erb
|
249
261
|
- app/components/lookbook/nav/component.js
|
250
262
|
- app/components/lookbook/nav/component.rb
|
@@ -306,11 +318,10 @@ files:
|
|
306
318
|
- app/helpers/lookbook/application_helper.rb
|
307
319
|
- app/views/layouts/lookbook/application.html.erb
|
308
320
|
- app/views/layouts/lookbook/embed.html.erb
|
309
|
-
- app/views/layouts/lookbook/shell.html.erb
|
310
321
|
- app/views/layouts/lookbook/skeleton.html.erb
|
311
|
-
- app/views/lookbook/404.html.erb
|
312
322
|
- app/views/lookbook/embeds/show.html.erb
|
313
|
-
- app/views/lookbook/
|
323
|
+
- app/views/lookbook/errors/default.html.erb
|
324
|
+
- app/views/lookbook/errors/not_found.html.erb
|
314
325
|
- app/views/lookbook/index.html.erb
|
315
326
|
- app/views/lookbook/inspector/inputs/_color.html.erb
|
316
327
|
- app/views/lookbook/inspector/inputs/_range.html.erb
|
@@ -326,6 +337,7 @@ files:
|
|
326
337
|
- app/views/lookbook/inspector/panels/_source.html.erb
|
327
338
|
- app/views/lookbook/inspector/show.html.erb
|
328
339
|
- app/views/lookbook/pages/show.html.erb
|
340
|
+
- app/views/lookbook/partials/_blank_slate.html.erb
|
329
341
|
- app/views/lookbook/partials/_iframe_content_scripts.html.erb
|
330
342
|
- app/views/lookbook/partials/_user_styles.html.erb
|
331
343
|
- app/views/lookbook/previews/group.html.erb
|
@@ -361,7 +373,6 @@ files:
|
|
361
373
|
- lib/lookbook/entities/rendered_scenario_entity.rb
|
362
374
|
- lib/lookbook/entities/scenario_entity.rb
|
363
375
|
- lib/lookbook/entities/scenario_group_entity.rb
|
364
|
-
- lib/lookbook/error.rb
|
365
376
|
- lib/lookbook/features.rb
|
366
377
|
- lib/lookbook/file_watcher.rb
|
367
378
|
- lib/lookbook/helpers/class_names_helper.rb
|
@@ -407,9 +418,11 @@ files:
|
|
407
418
|
- lib/lookbook/stores/tag_store.rb
|
408
419
|
- lib/lookbook/support/deprecation.rb
|
409
420
|
- lib/lookbook/support/errors/config_error.rb
|
410
|
-
- lib/lookbook/support/errors/
|
421
|
+
- lib/lookbook/support/errors/error.rb
|
411
422
|
- lib/lookbook/support/errors/parser_error.rb
|
412
423
|
- lib/lookbook/support/errors/preview_template_error.rb
|
424
|
+
- lib/lookbook/support/errors/routing_error.rb
|
425
|
+
- lib/lookbook/support/errors/template_error.rb
|
413
426
|
- lib/lookbook/support/evented_file_update_checker.rb
|
414
427
|
- lib/lookbook/support/null_object.rb
|
415
428
|
- lib/lookbook/support/null_websocket.rb
|
@@ -434,9 +447,16 @@ files:
|
|
434
447
|
- lib/lookbook/theme.rb
|
435
448
|
- lib/lookbook/version.rb
|
436
449
|
- lib/lookbook/websocket.rb
|
437
|
-
-
|
438
|
-
- public/lookbook-assets/
|
439
|
-
- public/lookbook-assets/
|
450
|
+
- public/lookbook-assets/Inter-italic.var.69eb0fe1.woff2
|
451
|
+
- public/lookbook-assets/Inter-italic.var.736a7044.woff2
|
452
|
+
- public/lookbook-assets/Inter-roman.var.b695afbe.woff2
|
453
|
+
- public/lookbook-assets/Inter-roman.var.fbdd51d0.woff2
|
454
|
+
- public/lookbook-assets/SourceCodeVariable-Italic.cad97b83.otf
|
455
|
+
- public/lookbook-assets/SourceCodeVariable-Italic.ttf.09b4354a.woff2
|
456
|
+
- public/lookbook-assets/SourceCodeVariable-Italic.ttf.fcd7e9f4.woff2
|
457
|
+
- public/lookbook-assets/SourceCodeVariable-Roman.185ddb17.otf
|
458
|
+
- public/lookbook-assets/SourceCodeVariable-Roman.ttf.118e9f22.woff2
|
459
|
+
- public/lookbook-assets/SourceCodeVariable-Roman.ttf.91043609.woff2
|
440
460
|
- public/lookbook-assets/css/lookbook.css
|
441
461
|
- public/lookbook-assets/css/lookbook.css.map
|
442
462
|
- public/lookbook-assets/css/themes/blue.css
|
@@ -449,28 +469,13 @@ files:
|
|
449
469
|
- public/lookbook-assets/css/themes/rose.css.map
|
450
470
|
- public/lookbook-assets/css/themes/zinc.css
|
451
471
|
- public/lookbook-assets/css/themes/zinc.css.map
|
452
|
-
- public/lookbook-assets/css/themes/zinc.css.map.91837.5
|
453
|
-
- public/lookbook-assets/feather-sprite.svg
|
454
472
|
- public/lookbook-assets/img/lucide-sprite.svg
|
455
|
-
- public/lookbook-assets/js/app.js
|
456
|
-
- public/lookbook-assets/js/app.js.map
|
457
|
-
- public/lookbook-assets/js/embed.js
|
458
|
-
- public/lookbook-assets/js/embed.js.91837.6
|
459
|
-
- public/lookbook-assets/js/embed.js.map
|
460
473
|
- public/lookbook-assets/js/iframe.js
|
461
474
|
- public/lookbook-assets/js/iframe.js.map
|
462
475
|
- public/lookbook-assets/js/index.js
|
463
476
|
- public/lookbook-assets/js/index.js.map
|
464
477
|
- public/lookbook-assets/js/lookbook-core.js
|
465
|
-
- public/lookbook-assets/js/lookbook-core.js.map
|
466
478
|
- public/lookbook-assets/js/lookbook.js
|
467
|
-
- public/lookbook-assets/js/lookbook.js.map
|
468
|
-
- public/lookbook-assets/lookbook-esm.js
|
469
|
-
- public/lookbook-assets/lookbook-esm.js.map
|
470
|
-
- public/lookbook-assets/lookbook-global.js
|
471
|
-
- public/lookbook-assets/lookbook-global.js.map
|
472
|
-
- public/lookbook-assets/lookbook.js
|
473
|
-
- public/lookbook-assets/lookbook.js.map
|
474
479
|
homepage: https://github.com/ViewComponent/lookbook
|
475
480
|
licenses:
|
476
481
|
- MIT
|
@@ -491,7 +496,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
491
496
|
- !ruby/object:Gem::Version
|
492
497
|
version: 1.3.1
|
493
498
|
requirements: []
|
494
|
-
rubygems_version: 3.
|
499
|
+
rubygems_version: 3.4.7
|
495
500
|
signing_key:
|
496
501
|
specification_version: 4
|
497
502
|
summary: A native development UI for ViewComponent
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<%= content_for :body do %>
|
2
|
-
<div
|
3
|
-
id="app"
|
4
|
-
x-data="app"
|
5
|
-
x-cloak
|
6
|
-
@popstate.window="handleNavigation"
|
7
|
-
@click.document="hijax"
|
8
|
-
@navigation:start="closeMobileSidebar"
|
9
|
-
class="w-screen h-screen grid grid-rows-[40px_1fr] relative">
|
10
|
-
|
11
|
-
<% if content_for? :user_styles %>
|
12
|
-
<style media="all" id="user-styles">
|
13
|
-
<%= content_for :user_styles -%>
|
14
|
-
</style>
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
<%= lookbook_render :header, id: "app-header", debug_menu: @config.debug_menu do |header| %>
|
18
|
-
<% header.branding { @config.project_name } %>
|
19
|
-
<% end %>
|
20
|
-
|
21
|
-
<%= content_for?(:shell) ? yield(:shell) : yield %>
|
22
|
-
</div>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<%= render template: "layouts/lookbook/skeleton" %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<div class="bg-white flex flex-col items-center justify-center h-screen w-full">
|
2
|
-
<div class="px-4 text-center max-w-sm">
|
3
|
-
<%= icon :alert_triangle, size: 10, class: "text-red-300 mx-auto" %>
|
4
|
-
<div class="mt-3">
|
5
|
-
<h5 class="text-base">
|
6
|
-
<%== message %>
|
7
|
-
</h5>
|
8
|
-
<% if defined?(description) %>
|
9
|
-
<p class="mt-2 opacity-50 text-sm">
|
10
|
-
<%== description %>
|
11
|
-
</p>
|
12
|
-
<% end %>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
</div>
|
@@ -1,46 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
error = error.is_a?(Lookbook::Error) ? error : Lookbook::Error.new(error)
|
3
|
-
@title = error.title
|
4
|
-
%>
|
5
|
-
|
6
|
-
<div class="flex flex-col h-screen">
|
7
|
-
<div class="h-full bg-red-50 overflow-y-auto">
|
8
|
-
<header class="mx-8 py-6">
|
9
|
-
<h2 class="text-xl font-bold text-red-700"><%= error.title %></h2>
|
10
|
-
</header>
|
11
|
-
|
12
|
-
<div class="flex-none px-8 py-6 mb-8 border-t border-b border-red-200 bg-red-100 text-base font-mono leading-relaxed">
|
13
|
-
<pre class="whitespace-pre-wrap font-sans leading-tight text-red-900"><%= error.message %></pre>
|
14
|
-
</div>
|
15
|
-
|
16
|
-
<% if error.file_name %>
|
17
|
-
<div class="text-sm mx-8 mb-2 font-mono">
|
18
|
-
<span><%= error.file_name %></span>
|
19
|
-
<% if error.line_number %>
|
20
|
-
<span>[line <strong><%= error.line_number %></strong>]</span>
|
21
|
-
<% end %>
|
22
|
-
</div>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<% if error.source_code %>
|
26
|
-
<div class="mx-8 border border-red-200 max-w-screen-lg">
|
27
|
-
<%= lookbook_render :code,
|
28
|
-
language: error.file_lang,
|
29
|
-
highlight_lines: [error.source_code[:highlighted_line]],
|
30
|
-
start_line: error.source_code[:start_line],
|
31
|
-
line_numbers: true do %><%= h(error.source_code[:code]) %><% end %>
|
32
|
-
</div>
|
33
|
-
<% end %>
|
34
|
-
|
35
|
-
<h3 class="font-bold mb-2 px-8 py-2 mt-8 sticky top-0 bg-red-50">Full stack trace:</h3>
|
36
|
-
<div class="text-xs font-mono">
|
37
|
-
<div class="px-8 pb-10 text-gray-400 leading-relaxed">
|
38
|
-
<% error.backtrace.each do |line| %>
|
39
|
-
<div class="hover:text-gray-900 transition-colors duration-100">
|
40
|
-
<%= line %>
|
41
|
-
</div>
|
42
|
-
<% end %>
|
43
|
-
</div>
|
44
|
-
</div>
|
45
|
-
</div>
|
46
|
-
</div>
|
data/lib/lookbook/error.rb
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
module Lookbook
|
2
|
-
class Error < StandardError
|
3
|
-
delegate :full_message, :backtrace, :to_s, to: :original
|
4
|
-
|
5
|
-
LINES_AROUND = 3
|
6
|
-
|
7
|
-
def initialize(original = nil, title: nil, message: nil, file_path: nil, file_name: nil, line_number: nil, source_code: nil)
|
8
|
-
@original = original
|
9
|
-
@title = title
|
10
|
-
@message = message
|
11
|
-
@file_path = file_path
|
12
|
-
@file_name = file_name
|
13
|
-
@line_number = line_number
|
14
|
-
@source_code = source_code
|
15
|
-
super()
|
16
|
-
end
|
17
|
-
|
18
|
-
def source_code
|
19
|
-
lines = source_code_lines
|
20
|
-
|
21
|
-
if lines.present? && line_number.is_a?(Integer)
|
22
|
-
start_line = source_code_start_line(lines)
|
23
|
-
end_line = source_code_end_line(lines)
|
24
|
-
highlighted_line = source_code_highlighted_line(lines)
|
25
|
-
|
26
|
-
line_count = end_line - start_line
|
27
|
-
relevant_lines = lines.slice(start_line - 1, line_count + 1)
|
28
|
-
if relevant_lines.present?
|
29
|
-
empty_start_lines = 0
|
30
|
-
relevant_lines.each do |line|
|
31
|
-
break unless line.strip.empty?
|
32
|
-
empty_start_lines += 1
|
33
|
-
end
|
34
|
-
|
35
|
-
{
|
36
|
-
code: relevant_lines.join("\n").lstrip,
|
37
|
-
start_line: start_line,
|
38
|
-
highlighted_line: highlighted_line - empty_start_lines
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def source_code_lines
|
46
|
-
if file_path || @source_code
|
47
|
-
if @source_code
|
48
|
-
@source_code.split("\n")
|
49
|
-
else
|
50
|
-
full_path = Rails.root.join(file_path)
|
51
|
-
File.read(full_path).split("\n") if File.exist? full_path
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def file_lang
|
57
|
-
lang = Lookbook::Lang.guess(file_path)
|
58
|
-
lang.present? ? lang[:name] : "plaintext"
|
59
|
-
end
|
60
|
-
|
61
|
-
def title
|
62
|
-
@title || original.class.to_s
|
63
|
-
end
|
64
|
-
|
65
|
-
def message
|
66
|
-
(@message || original.message).gsub("(<unknown>):", "").strip.upcase_first
|
67
|
-
end
|
68
|
-
|
69
|
-
def file_name
|
70
|
-
if @file_name == false
|
71
|
-
nil
|
72
|
-
else
|
73
|
-
@file_name || file_path
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def file_path
|
78
|
-
path = if @file_path.nil?
|
79
|
-
parsed_backtrace[0][0] if parsed_backtrace.any?
|
80
|
-
else
|
81
|
-
@file_path.presence || nil
|
82
|
-
end
|
83
|
-
path.nil? ? nil : path.to_s.delete_prefix("#{Rails.root}/")
|
84
|
-
end
|
85
|
-
|
86
|
-
def line_number
|
87
|
-
number = if @line_number.nil?
|
88
|
-
parsed_backtrace[0][1] if parsed_backtrace.any?
|
89
|
-
else
|
90
|
-
@line_number.presence || nil
|
91
|
-
end
|
92
|
-
number.present? ? number.to_i : number
|
93
|
-
end
|
94
|
-
|
95
|
-
def parsed_backtrace
|
96
|
-
backtrace.map do |x|
|
97
|
-
x =~ /^(.+?):(\d+)(|:in `(.+)')$/
|
98
|
-
[$1, $2, $4]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
protected
|
103
|
-
|
104
|
-
def original
|
105
|
-
@original.presence || self
|
106
|
-
end
|
107
|
-
|
108
|
-
def source_code_start_line(lines)
|
109
|
-
[(line_number - LINES_AROUND), 1].max unless line_number.nil?
|
110
|
-
end
|
111
|
-
|
112
|
-
def source_code_end_line(lines)
|
113
|
-
[line_number + LINES_AROUND, lines&.size || Infinity].min
|
114
|
-
end
|
115
|
-
|
116
|
-
def source_code_highlighted_line(lines)
|
117
|
-
[line_number - source_code_start_line(lines) + 1, 1].max unless line_number.nil?
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Lookbook
|
2
|
-
class LookbookError < StandardError
|
3
|
-
attr_reader :scope, :original, :message
|
4
|
-
|
5
|
-
def initialize(msg = nil, scope: nil, original: nil)
|
6
|
-
@scope = scope
|
7
|
-
@original = original
|
8
|
-
@message = msg
|
9
|
-
super(msg)
|
10
|
-
end
|
11
|
-
|
12
|
-
def full_message
|
13
|
-
if msg.nil?
|
14
|
-
message
|
15
|
-
else
|
16
|
-
scope_str = scope.nil? ? "[#{scope}]" : ""
|
17
|
-
"#{scope_str} #{message}".strip
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|