scarpe 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/CHANGELOG.md +36 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +13 -3
- data/LICENSE.txt +7 -1
- data/README.md +77 -14
- data/Rakefile +67 -0
- data/examples/Edit_box_Styles.rb +8 -0
- data/examples/Kerning.rb +7 -0
- data/examples/border.rb +11 -0
- data/examples/check.rb +2 -0
- data/examples/download_and_show_image.rb +3 -0
- data/examples/flags/finland.rb +15 -0
- data/examples/flags/italy.rb +11 -0
- data/examples/flags/mauritius.rb +14 -0
- data/examples/font_family.rb +17 -0
- data/examples/font_shorthand.rb +9 -0
- data/examples/gen.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/append.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/background_change.rb +12 -0
- data/examples/legacy/not_checked/shoes-manual/background_pattern.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/basic_app.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/border.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/FONTS.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_color.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_open_file.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_save_folder.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/confirm.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/debug.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/info.rb +3 -0
- data/examples/legacy/not_checked/shoes-manual/button.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/clear.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/custom_header.rb +13 -0
- data/examples/legacy/not_checked/shoes-manual/displace.rb +14 -0
- data/examples/legacy/not_checked/shoes-manual/edit_box.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/fill_pattern.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/fonts.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/gutter.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/image_web.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/keypress.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/list_box.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/motion.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/mouse.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/move.rb +14 -0
- data/examples/legacy/not_checked/shoes-manual/nested_ovals.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/oval.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/ovals.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/ovals_image.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/prepend.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/progress_bar.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/radio.rb +18 -0
- data/examples/legacy/not_checked/shoes-manual/radio_alternative_1.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/radio_alternative_2.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/rotate_rectangle.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/shape.rb +11 -0
- data/examples/legacy/not_checked/shoes-manual/static/avatar.png +0 -0
- data/examples/legacy/not_checked/shoes-manual/stroke.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/style.rb +3 -0
- data/examples/legacy/not_checked/shoes-manual/style_alternative_1.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/style_alternative_2.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/style_length.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/timer.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/trigger_window.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/window_owner.rb +8 -0
- data/examples/legacy/working/shoes_manual/alert_button.rb +2 -0
- data/examples/legacy/working/shoes_manual/animate.rb +7 -0
- data/examples/legacy/working/shoes_manual/background_para.rb +4 -0
- data/examples/legacy/working/shoes_manual/button_alternative.rb +7 -0
- data/examples/legacy/working/shoes_manual/checkbox.rb +17 -0
- data/examples/legacy/working/shoes_manual/download.rb +12 -0
- data/examples/legacy/working/shoes_manual/edit_box.rb +6 -0
- data/examples/legacy/working/shoes_manual/editline.rb +7 -0
- data/examples/legacy/working/shoes_manual/fixed_height.rb +8 -0
- data/examples/legacy/working/shoes_manual/fixed_width.rb +12 -0
- data/examples/legacy/working/shoes_manual/image.rb +5 -0
- data/examples/legacy/working/shoes_manual/instance_variable_check.rb +10 -0
- data/examples/legacy/working/shoes_manual/message.rb +18 -0
- data/examples/legacy/working/shoes_manual/rectangle.rb +6 -0
- data/examples/legacy/working/shoes_manual/save_download.rb +12 -0
- data/examples/legacy/working/shoes_manual/self_check.rb +10 -0
- data/examples/legacy/working/shoes_manual/stack.rb +7 -0
- data/examples/legacy/working/shoes_manual/style_info.rb +8 -0
- data/examples/legacy/working/shoes_manual/utf8_support.rb +8 -0
- data/examples/legacy/working/shoes_manual/width.rb +4 -0
- data/examples/local_assets/multi_image.rb +5 -0
- data/examples/local_assets/small.png +0 -0
- data/examples/local_fonts.rb +3 -0
- data/examples/margin.rb +13 -0
- data/examples/margin_check.rb +27 -0
- data/examples/oval-with-kwargs.rb +3 -0
- data/examples/oval.rb +26 -0
- data/examples/para_font_styles.rb +17 -0
- data/examples/para_font_variant.rb +6 -0
- data/examples/para_fontweight.rb +13 -0
- data/examples/parse_xl_funnies.rb +3 -0
- data/examples/rect.rb +1 -1
- data/examples/scarpe_ext.rb +3 -0
- data/examples/shapes/star.rb +1 -3
- data/examples/spacing.rb +1 -1
- data/examples/span.rb +4 -2
- data/lacci/lacci.gemspec +2 -2
- data/lacci/lib/lacci/scarpe_cli.rb +0 -1
- data/lacci/lib/lacci/version.rb +1 -1
- data/lacci/lib/scarpe/niente/display_service.rb +5 -1
- data/lacci/lib/scarpe/niente/drawable.rb +2 -0
- data/lacci/lib/scarpe/niente/shoes_spec.rb +7 -1
- data/lacci/lib/scarpe/niente.rb +14 -2
- data/lacci/lib/shoes/app.rb +44 -50
- data/lacci/lib/shoes/constants.rb +23 -2
- data/lacci/lib/shoes/display_service.rb +43 -4
- data/lacci/lib/shoes/drawable.rb +309 -35
- data/lacci/lib/shoes/drawables/arc.rb +2 -24
- data/lacci/lib/shoes/drawables/arrow.rb +2 -22
- data/lacci/lib/shoes/drawables/border.rb +28 -0
- data/lacci/lib/shoes/drawables/button.rb +4 -20
- data/lacci/lib/shoes/drawables/check.rb +7 -3
- data/lacci/lib/shoes/drawables/document_root.rb +4 -4
- data/lacci/lib/shoes/drawables/edit_box.rb +6 -5
- data/lacci/lib/shoes/drawables/edit_line.rb +5 -4
- data/lacci/lib/shoes/drawables/flow.rb +3 -5
- data/lacci/lib/shoes/drawables/font_helper.rb +62 -0
- data/lacci/lib/shoes/drawables/image.rb +2 -2
- data/lacci/lib/shoes/drawables/line.rb +4 -7
- data/lacci/lib/shoes/drawables/link.rb +5 -8
- data/lacci/lib/shoes/drawables/list_box.rb +8 -5
- data/lacci/lib/shoes/drawables/oval.rb +48 -0
- data/lacci/lib/shoes/drawables/para.rb +106 -18
- data/lacci/lib/shoes/drawables/progress.rb +2 -1
- data/lacci/lib/shoes/drawables/radio.rb +5 -3
- data/lacci/lib/shoes/drawables/rect.rb +5 -4
- data/lacci/lib/shoes/drawables/shape.rb +2 -1
- data/lacci/lib/shoes/drawables/slot.rb +99 -8
- data/lacci/lib/shoes/drawables/stack.rb +6 -11
- data/lacci/lib/shoes/drawables/star.rb +8 -30
- data/lacci/lib/shoes/drawables/text_drawable.rb +93 -34
- data/lacci/lib/shoes/drawables/video.rb +3 -2
- data/lacci/lib/shoes/drawables/widget.rb +8 -3
- data/lacci/lib/shoes/drawables.rb +2 -1
- data/lacci/lib/shoes/errors.rb +13 -3
- data/lacci/lib/shoes/margin_helper.rb +79 -0
- data/lacci/lib/shoes.rb +4 -3
- data/lacci/test/.gitignore +1 -0
- data/lacci/test/test_draw_context.rb +167 -0
- data/lacci/test/test_font_helper.rb +57 -0
- data/lacci/test/test_helper.rb +31 -4
- data/lacci/test/test_lacci.rb +93 -6
- data/lacci/test/test_margin_helper.rb +82 -0
- data/lacci/test/test_niente_test_infra.rb +26 -0
- data/lacci/test/test_oval.rb +82 -0
- data/lacci/test/test_parenting.rb +140 -0
- data/lacci/test/test_text_drawables.rb +23 -0
- data/lib/scarpe/assets.rb +18 -0
- data/lib/scarpe/cats_cradle.rb +57 -98
- data/lib/scarpe/shoes_spec.rb +22 -43
- data/lib/scarpe/version.rb +1 -1
- data/lib/scarpe/wv/app.rb +1 -0
- data/lib/scarpe/wv/arc.rb +0 -4
- data/lib/scarpe/wv/border.rb +15 -0
- data/lib/scarpe/wv/control_interface.rb +2 -10
- data/lib/scarpe/wv/document_root.rb +2 -2
- data/lib/scarpe/wv/drawable.rb +6 -40
- data/lib/scarpe/wv/edit_box.rb +4 -1
- data/lib/scarpe/wv/edit_line.rb +5 -2
- data/lib/scarpe/wv/image.rb +2 -5
- data/lib/scarpe/wv/link.rb +4 -2
- data/lib/scarpe/wv/oval.rb +13 -0
- data/lib/scarpe/wv/para.rb +1 -0
- data/lib/scarpe/wv/scarpe_extensions.rb +8 -0
- data/lib/scarpe/wv/shape.rb +10 -5
- data/lib/scarpe/wv/text_drawable.rb +72 -14
- data/lib/scarpe/wv/web_wrangler.rb +33 -11
- data/lib/scarpe/wv/webview_local_display.rb +6 -2
- data/lib/scarpe/wv.rb +8 -1
- data/scarpe-components/Gemfile +4 -1
- data/scarpe-components/Gemfile.lock +2 -3
- data/scarpe-components/README.md +2 -2
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cerulean.css +12229 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cosmo.css +11810 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cyborg.css +12210 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-darkly.css +12153 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-flatly.css +12126 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-icons.min.css +5 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-journal.css +12099 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-litera.css +12211 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-lumen.css +12369 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-lux.css +11928 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-materia.css +13184 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-minty.css +12177 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-morph.css +12750 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-pulse.css +11890 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-quartz.css +12622 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-sandstone.css +12201 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-simplex.css +12186 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-sketchy.css +12451 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-slate.css +12492 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-solar.css +12149 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-spacelab.css +12266 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-superhero.css +12216 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-united.css +12077 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-vapor.css +12549 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-yeti.css +12325 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-zephyr.css +12283 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap.bundle.min.js +7 -0
- data/scarpe-components/lib/scarpe/components/asset_server.rb +219 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +22 -0
- data/scarpe-components/lib/scarpe/components/calzini/{art_widgets.rb → art_drawables.rb} +42 -18
- data/scarpe-components/lib/scarpe/components/calzini/border.rb +38 -0
- data/scarpe-components/lib/scarpe/components/calzini/button.rb +6 -8
- data/scarpe-components/lib/scarpe/components/calzini/misc.rb +7 -17
- data/scarpe-components/lib/scarpe/components/calzini/para.rb +213 -11
- data/scarpe-components/lib/scarpe/components/calzini/slots.rb +14 -60
- data/scarpe-components/lib/scarpe/components/calzini.rb +88 -1
- data/scarpe-components/lib/scarpe/components/errors.rb +4 -0
- data/scarpe-components/lib/scarpe/components/html.rb +4 -1
- data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +11 -3
- data/scarpe-components/lib/scarpe/components/minitest_result.rb +41 -0
- data/scarpe-components/lib/scarpe/components/print_logger.rb +17 -2
- data/scarpe-components/lib/scarpe/components/process_helpers.rb +37 -0
- data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +1 -1
- data/scarpe-components/lib/scarpe/components/tiranti.rb +42 -100
- data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +3 -1
- data/scarpe-components/lib/scarpe/components/version.rb +1 -1
- data/scarpe-components/test/assets/big-image.png +0 -0
- data/scarpe-components/test/assets/big-stylesheet.css +497 -0
- data/scarpe-components/test/assets/little-image.png +0 -0
- data/scarpe-components/test/assets/little-stylesheet.css +1 -0
- data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +7 -7
- data/scarpe-components/test/calzini/test_calzini_button.rb +7 -5
- data/scarpe-components/test/calzini/test_calzini_misc.rb +9 -9
- data/scarpe-components/test/calzini/test_calzini_para.rb +6 -9
- data/scarpe-components/test/calzini/test_calzini_slots.rb +12 -57
- data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +83 -18
- data/scarpe-components/test/calzini/test_various.rb +133 -0
- data/scarpe-components/test/test_asset_server.rb +72 -0
- data/scarpe-components/test/test_components.rb +31 -2
- data/scarpe-components/test/test_helper.rb +0 -1
- data/scarpe-components/test/test_minitest_result.rb +7 -0
- data/scarpe-components/test/test_segmented_app_files.rb +2 -0
- data/tasks/check_html_fixtures.rb +140 -0
- data/tasks/regenerate_html_fixtures.rb +104 -0
- data/templates/class_template_with_shapes.erb +0 -11
- metadata +180 -32
- data/lacci/lib/scarpe/niente/logger.rb +0 -29
- data/lacci/lib/shoes/drawables/span.rb +0 -27
- data/lacci/lib/shoes/spacing.rb +0 -9
- data/lib/scarpe/evented_assertions.rb +0 -121
- data/lib/scarpe/wv/span.rb +0 -44
- data/scarpe-components/lib/scarpe/components/calzini/text_widgets.rb +0 -65
- /data/examples/legacy/{not_checked → working}/shoes3-tests/editline/editline.rb +0 -0
@@ -1,32 +1,90 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# There are different ways to implement these tags. You can change the HTML tag (link,
|
4
|
+
# code, strong) or set default values (del for strikethrough.) There's no reason the
|
5
|
+
# Shoes tag name has to match the HTML tag (del, link). This can be a little
|
6
|
+
# complicated since CSS often sets default values (e.g. del for strikethrough) and
|
7
|
+
# Scarpe may use those default values or override them. Long term it may be easier
|
8
|
+
# for us to set up our own CSS for this somehow that does *not* use the HTML-tag
|
9
|
+
# defaults since the browser can mess with those, and there's no guarantee that
|
10
|
+
# Webview uses the same default CSS style across all OSes.
|
11
|
+
|
3
12
|
module Scarpe::Webview
|
13
|
+
# This class renders text tags like em, strong, link, etc.
|
4
14
|
class TextDrawable < Drawable
|
5
|
-
|
6
|
-
|
7
|
-
|
15
|
+
# Calzini renders based on properties, mostly Shoes styles.
|
16
|
+
# To have Calzini render this for us, we convert to the format
|
17
|
+
# Calzini expects and then let it render. See Webview::Para
|
18
|
+
# for the specific Calzini call.
|
19
|
+
def to_calzini_hash
|
20
|
+
text_array = items_to_display_children(@text_items).map do |item|
|
21
|
+
if item.respond_to?(:to_calzini_hash)
|
22
|
+
item.to_calzini_hash
|
23
|
+
elsif item.is_a?(String)
|
24
|
+
item
|
25
|
+
else
|
26
|
+
# This should normally be filtered out in Lacci, long before we see it
|
27
|
+
raise "Unrecognized item in TextDrawable! #{item.inspect}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
{
|
32
|
+
items: text_array,
|
33
|
+
html_id: @linkable_id.to_s,
|
34
|
+
tag: nil, # have Calzini assign a default unless a subclass overrides this
|
35
|
+
props: shoes_styles,
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def element
|
40
|
+
render("text_drawable", [to_calzini_hash])
|
41
|
+
end
|
42
|
+
|
43
|
+
def items_to_display_children(items)
|
44
|
+
return [] if items.nil?
|
45
|
+
|
46
|
+
items.map do |item|
|
47
|
+
if item.is_a?(String)
|
48
|
+
item
|
49
|
+
else
|
50
|
+
Scarpe::Webview::DisplayService.instance.query_display_drawable_for(item)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Usually we query by ID, but for TextDrawable it has to be by class.
|
56
|
+
# That's how needs_update!, etc continue to work.
|
57
|
+
def html_element
|
58
|
+
@elt_wrangler ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(selector: %{document.getElementsByClassName("id_#{html_id}")}, multi: true)
|
8
59
|
end
|
9
60
|
end
|
10
61
|
|
11
62
|
class << self
|
12
|
-
def
|
13
|
-
|
63
|
+
def default_wv_text_drawable_with_tag(shoes_tag, html_tag = nil)
|
64
|
+
html_tag ||= shoes_tag
|
65
|
+
webview_class_name = shoes_tag.capitalize
|
14
66
|
webview_drawable_class = Class.new(Scarpe::Webview::TextDrawable) do
|
15
|
-
|
16
|
-
|
17
|
-
@html_tag = class_name.delete_prefix("Webview").downcase
|
18
|
-
super
|
67
|
+
class << self
|
68
|
+
attr_accessor :html_tag
|
19
69
|
end
|
20
70
|
|
21
|
-
def
|
22
|
-
|
71
|
+
def to_calzini_hash
|
72
|
+
h = super
|
73
|
+
h[:tag] = self.class.html_tag
|
74
|
+
h
|
23
75
|
end
|
24
76
|
end
|
25
77
|
Scarpe::Webview.const_set webview_class_name, webview_drawable_class
|
78
|
+
webview_drawable_class.html_tag = html_tag
|
26
79
|
end
|
27
80
|
end
|
28
81
|
end
|
29
82
|
|
30
|
-
Scarpe::Webview.
|
31
|
-
Scarpe::Webview.
|
32
|
-
Scarpe::Webview.
|
83
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:code)
|
84
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:del)
|
85
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:em)
|
86
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:strong)
|
87
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:span)
|
88
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:sub)
|
89
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:sup)
|
90
|
+
Scarpe::Webview.default_wv_text_drawable_with_tag(:ins, "span") # Styled in Shoes, not CSS
|
@@ -261,6 +261,7 @@ module Scarpe::Webview
|
|
261
261
|
@log.debug("Scheduled JS: (#{this_eval_serial})\n#{wrapped_code}")
|
262
262
|
else
|
263
263
|
# We're mid-shutdown. No more scheduling things.
|
264
|
+
@log.warn "Mid-shutdown JS eval. Not scheduling JS!"
|
264
265
|
end
|
265
266
|
end
|
266
267
|
|
@@ -746,16 +747,37 @@ class Scarpe::Webview::WebWrangler
|
|
746
747
|
class ElementWrangler
|
747
748
|
attr_reader :html_id
|
748
749
|
|
749
|
-
# Create an ElementWrangler for the given HTML ID
|
750
|
+
# Create an ElementWrangler for the given HTML ID or selector.
|
751
|
+
# The caller should provide exactly one of the html_id or selector.
|
750
752
|
#
|
751
753
|
# @param html_id [String] the HTML ID for the DOM element
|
752
|
-
def initialize(html_id)
|
754
|
+
def initialize(html_id: nil, selector: nil, multi: false)
|
753
755
|
@webwrangler = ::Scarpe::Webview::DisplayService.instance.wrangler
|
754
756
|
raise Scarpe::MissingWranglerError, "Can't get WebWrangler!" unless @webwrangler
|
755
757
|
|
756
|
-
|
758
|
+
if html_id && !selector
|
759
|
+
@selector = "document.getElementById('" + html_id + "')"
|
760
|
+
elsif selector && !html_id
|
761
|
+
@selector = selector
|
762
|
+
else
|
763
|
+
raise ArgumentError, "Must provide exactly one of html_id or selector!"
|
764
|
+
end
|
765
|
+
|
766
|
+
@multi = multi
|
757
767
|
end
|
758
768
|
|
769
|
+
private
|
770
|
+
|
771
|
+
def on_each(fragment)
|
772
|
+
if @multi
|
773
|
+
@webwrangler.dom_change("a = Array.from(#{@selector}); a.forEach((item) => item#{fragment}); true")
|
774
|
+
else
|
775
|
+
@webwrangler.dom_change(@selector + fragment + ";true")
|
776
|
+
end
|
777
|
+
end
|
778
|
+
|
779
|
+
public
|
780
|
+
|
759
781
|
# Return a promise that will be fulfilled when all changes scheduled via
|
760
782
|
# this ElementWrangler are verified complete.
|
761
783
|
#
|
@@ -769,7 +791,7 @@ class Scarpe::Webview::WebWrangler
|
|
769
791
|
# @param new_value [String] the new value
|
770
792
|
# @return [Scarpe::Promise] a promise that will be fulfilled when the change is complete
|
771
793
|
def value=(new_value)
|
772
|
-
|
794
|
+
on_each(".value = `" + new_value + "`")
|
773
795
|
end
|
774
796
|
|
775
797
|
# Update the JS DOM element's inner_text. The given Ruby value will be converted to string and assigned in single-quotes.
|
@@ -777,7 +799,7 @@ class Scarpe::Webview::WebWrangler
|
|
777
799
|
# @param new_text [String] the new inner_text
|
778
800
|
# @return [Scarpe::Promise] a promise that will be fulfilled when the change is complete
|
779
801
|
def inner_text=(new_text)
|
780
|
-
|
802
|
+
on_each(".innerText = '" + new_text + "'")
|
781
803
|
end
|
782
804
|
|
783
805
|
# Update the JS DOM element's inner_html. The given Ruby value will be converted to string and assigned in backquotes.
|
@@ -785,7 +807,7 @@ class Scarpe::Webview::WebWrangler
|
|
785
807
|
# @param new_html [String] the new inner_html
|
786
808
|
# @return [Scarpe::Promise] a promise that will be fulfilled when the change is complete
|
787
809
|
def inner_html=(new_html)
|
788
|
-
|
810
|
+
on_each(".innerHTML = `" + new_html + "`")
|
789
811
|
end
|
790
812
|
|
791
813
|
# Update the JS DOM element's outer_html. The given Ruby value will be converted to string and assigned in backquotes.
|
@@ -793,7 +815,7 @@ class Scarpe::Webview::WebWrangler
|
|
793
815
|
# @param new_html [String] the new outer_html
|
794
816
|
# @return [Scarpe::Promise] a promise that will be fulfilled when the change is complete
|
795
817
|
def outer_html=(new_html)
|
796
|
-
|
818
|
+
on_each(".outerHTML = `" + new_html + "`")
|
797
819
|
end
|
798
820
|
|
799
821
|
# Update the JS DOM element's attribute. The given Ruby value will be inspected and assigned.
|
@@ -802,7 +824,7 @@ class Scarpe::Webview::WebWrangler
|
|
802
824
|
# @param value [String] the new attribute value
|
803
825
|
# @return [Scarpe::Promise] a promise that will be fulfilled when the change is complete
|
804
826
|
def set_attribute(attribute, value)
|
805
|
-
|
827
|
+
on_each(".setAttribute(" + attribute.inspect + "," + value.inspect + ")")
|
806
828
|
end
|
807
829
|
|
808
830
|
# Update an attribute of the JS DOM element's style. The given Ruby value will be inspected and assigned.
|
@@ -811,19 +833,19 @@ class Scarpe::Webview::WebWrangler
|
|
811
833
|
# @param value [String] the new style attribute value
|
812
834
|
# @return [Scarpe::Promise] a promise that will be fulfilled when the change is complete
|
813
835
|
def set_style(style_attr, value)
|
814
|
-
|
836
|
+
on_each(".style.#{style_attr} = " + value.inspect + ";")
|
815
837
|
end
|
816
838
|
|
817
839
|
# Remove the specified DOM element
|
818
840
|
#
|
819
841
|
# @return [Scarpe::Promise] a promise that wil be fulfilled when the element is removed
|
820
842
|
def remove
|
821
|
-
|
843
|
+
on_each(".remove()")
|
822
844
|
end
|
823
845
|
|
824
846
|
def toggle_input_button(mark)
|
825
847
|
checked_value = mark ? "true" : "false"
|
826
|
-
|
848
|
+
on_each(".checked = #{checked_value}")
|
827
849
|
end
|
828
850
|
end
|
829
851
|
end
|
@@ -52,10 +52,10 @@ module Scarpe
|
|
52
52
|
# @param properties [Hash] a JSON-serialisable Hash with the drawable's Shoes styles
|
53
53
|
# @param is_widget [Boolean] whether the class is a user-defined Shoes::Widget subclass
|
54
54
|
# @return [Webview::Drawable] the newly-created Webview drawable
|
55
|
-
def create_display_drawable_for(drawable_class_name, drawable_id, properties, is_widget:)
|
55
|
+
def create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:)
|
56
56
|
existing = query_display_drawable_for(drawable_id, nil_ok: true)
|
57
57
|
if existing
|
58
|
-
@log.warn("There is already a
|
58
|
+
@log.warn("There is already a Scarpe drawable for #{drawable_id.inspect}! Returning #{existing.class.name} rather than creating a #{drawable_class_name}.")
|
59
59
|
return existing
|
60
60
|
end
|
61
61
|
|
@@ -95,6 +95,10 @@ module Scarpe
|
|
95
95
|
@doc_root = display_drawable
|
96
96
|
end
|
97
97
|
|
98
|
+
# Nil parent is fine for DocumentRoot and any TextDrawable, so we have to specify it.
|
99
|
+
display_parent = Scarpe::Webview::DisplayService.instance.query_display_drawable_for(parent_id, nil_ok: true)
|
100
|
+
display_drawable.set_parent(display_parent)
|
101
|
+
|
98
102
|
display_drawable
|
99
103
|
end
|
100
104
|
|
data/lib/scarpe/wv.rb
CHANGED
@@ -63,6 +63,9 @@ Shoes::FONTS.push(
|
|
63
63
|
"Monaco",
|
64
64
|
)
|
65
65
|
|
66
|
+
Shoes::FEATURES.push(:html)
|
67
|
+
Shoes::EXTENSIONS.push(:scarpe)
|
68
|
+
|
66
69
|
require_relative "shoes_spec"
|
67
70
|
Shoes::Spec.instance = Scarpe::Test
|
68
71
|
|
@@ -72,6 +75,7 @@ require_relative "wv/control_interface"
|
|
72
75
|
require_relative "wv/drawable"
|
73
76
|
|
74
77
|
require_relative "wv/star"
|
78
|
+
require_relative "wv/oval"
|
75
79
|
require_relative "wv/radio"
|
76
80
|
|
77
81
|
require_relative "wv/arc"
|
@@ -91,7 +95,6 @@ require_relative "wv/list_box"
|
|
91
95
|
require_relative "wv/shape"
|
92
96
|
|
93
97
|
require_relative "wv/text_drawable"
|
94
|
-
require_relative "wv/span"
|
95
98
|
require_relative "wv/link"
|
96
99
|
require_relative "wv/line"
|
97
100
|
require_relative "wv/rect"
|
@@ -99,3 +102,7 @@ require_relative "wv/video"
|
|
99
102
|
require_relative "wv/check"
|
100
103
|
require_relative "wv/progress"
|
101
104
|
require_relative "wv/arrow"
|
105
|
+
|
106
|
+
require_relative "wv/scarpe_extensions"
|
107
|
+
require_relative "assets"
|
108
|
+
require_relative "wv/border"
|
data/scarpe-components/Gemfile
CHANGED
@@ -8,11 +8,14 @@ gem "lacci", path: "../lacci"
|
|
8
8
|
|
9
9
|
gem "rake", "~> 13.0"
|
10
10
|
|
11
|
-
gem "nokogiri"
|
11
|
+
#gem "nokogiri"
|
12
12
|
|
13
13
|
group :test do
|
14
14
|
gem "minitest", "~> 5.0"
|
15
15
|
gem "minitest-reporters"
|
16
|
+
|
17
|
+
# Dependencies for specific components being tested
|
18
|
+
gem "webrick"
|
16
19
|
end
|
17
20
|
|
18
21
|
group :development do
|
@@ -31,8 +31,6 @@ GEM
|
|
31
31
|
builder
|
32
32
|
minitest (>= 5.0)
|
33
33
|
ruby-progressbar
|
34
|
-
nokogiri (1.15.4-x86_64-darwin)
|
35
|
-
racc (~> 1.4)
|
36
34
|
parallel (1.23.0)
|
37
35
|
parser (3.2.2.3)
|
38
36
|
ast (~> 2.4.1)
|
@@ -67,6 +65,7 @@ GEM
|
|
67
65
|
ruby-progressbar (1.13.0)
|
68
66
|
stringio (3.0.8)
|
69
67
|
unicode-display_width (2.4.2)
|
68
|
+
webrick (1.8.1)
|
70
69
|
|
71
70
|
PLATFORMS
|
72
71
|
x86_64-darwin-22
|
@@ -76,11 +75,11 @@ DEPENDENCIES
|
|
76
75
|
lacci!
|
77
76
|
minitest (~> 5.0)
|
78
77
|
minitest-reporters
|
79
|
-
nokogiri
|
80
78
|
rake (~> 13.0)
|
81
79
|
rubocop (~> 1.21)
|
82
80
|
rubocop-shopify
|
83
81
|
scarpe-components!
|
82
|
+
webrick
|
84
83
|
|
85
84
|
BUNDLED WITH
|
86
85
|
2.4.14
|
data/scarpe-components/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Scarpe is several things. We package up the Shoes API with as few implementation details as possible (called Lacci.) We have a Webview-based display library, in both local and over-a-socket (relay) versions. We have a Wasm display library (Scarpe-Wasm) in a separate gem.
|
4
4
|
|
5
|
-
And we have various default implementations of different reusable components. Scarpe's hierarchical logger isn't particularly specific to your display library or underlying GUI library
|
5
|
+
And we have various default implementations of different reusable components. Calzini is a Shoes-to-HTML renderer shared between Scarpe-Webview and Scarpe-Wasm. Scarpe's hierarchical logger isn't particularly specific to your display library or underlying GUI library and we'd like it to be usable by multiple display libs. Scarpe's default downloader, using Ruby's built-in HTTP libraries, is good in many cases but you might want to replace it (e.g. with Typhoeus for better parallel downloads or Hystrix for robustness to bad network connections) in some cases.
|
6
6
|
|
7
|
-
Part of our solution is the Scarpe-Components gem, which lives in the same repository as Scarpe
|
7
|
+
Part of our solution is the Scarpe-Components gem, which lives in the same repository as Scarpe and Lacci for now. These components can live there. Any specific display library can pick and choose what it wants or needs and handle its dependencies as it sees fit.
|
8
8
|
|
9
9
|
## Dependency Hell
|
10
10
|
|