atome 0.5.5.6.5 → 0.5.5.6.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +251 -90
- data/atome.gemspec +64 -0
- data/documentation/deep learning/basic_infos.txt +66 -2
- data/exe/atome +165 -36
- data/lib/atome/genesis/generators/utility.rb +3 -0
- data/lib/atome/helpers/utilities.rb +14 -1
- data/lib/atome/version.rb +1 -1
- data/lib/platform_specific/opal/atome_opal_extensions.rb +1 -0
- data/lib/renderers/html/utility.rb +46 -0
- data/vendor/assets/application/examples/file.rb +11 -46
- data/vendor/assets/application/examples/security.rb +5 -5
- data/vendor/assets/src/js/atome/atome.js +156 -20
- metadata +4 -18
- data/app_builder_helpers/Rakefile +0 -278
data/exe/atome
CHANGED
@@ -70,6 +70,7 @@ def build_aui(destination, project_name)
|
|
70
70
|
# now building opal version
|
71
71
|
js_directory = "#{destination}/#{project_name}/src/js"
|
72
72
|
opal_js = "#{js_directory}/aui.js"
|
73
|
+
FileUtils.mkdir_p(js_directory)
|
73
74
|
File.new opal_js, 'w'
|
74
75
|
# we add platform_specific script to the Opal framework
|
75
76
|
opal_content = Opal::Builder.build("#{path}aui.rb").to_s
|
@@ -131,7 +132,19 @@ STR
|
|
131
132
|
File.open(opal_compiler, 'w') do |f|
|
132
133
|
f.puts opal_compiler_content
|
133
134
|
end
|
134
|
-
|
135
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
136
|
+
# Code à exécuter sous Windows
|
137
|
+
`cd #{destination}\\#{project_name}\\tmp\\application\\ && echo %cd% && ruby .opal_compiler.rb`
|
138
|
+
|
139
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
140
|
+
# Code à exécuter sous MacOS
|
141
|
+
`cd #{destination}/#{project_name}/tmp/application/;pwd;ruby .opal_compiler.rb`
|
142
|
+
|
143
|
+
else
|
144
|
+
# Code à exécuter sous Unix/Linux
|
145
|
+
`cd #{destination}/#{project_name}/tmp/application/;pwd;ruby .opal_compiler.rb`
|
146
|
+
end
|
147
|
+
|
135
148
|
end
|
136
149
|
|
137
150
|
def add_to_application_folder(script_source, destination, project_name)
|
@@ -165,7 +178,7 @@ def create_application(source, destination, project_name)
|
|
165
178
|
end
|
166
179
|
# we copy all folder to be refreshed
|
167
180
|
files_list.each do |file|
|
168
|
-
FileUtils.cp_r("#{source}/vendor/assets/#{file}", "#{destination}/#{project_name}/#{file}")
|
181
|
+
FileUtils.cp_r("#{source}/vendor/assets/#{file}", "#{destination}/#{project_name}/#{file}")
|
169
182
|
end
|
170
183
|
build_aui(destination, project_name)
|
171
184
|
end
|
@@ -201,6 +214,7 @@ def build_atome_kernel_for_opal(source, destination, project_name)
|
|
201
214
|
# now lets build the atome kernel
|
202
215
|
atome_directory = "#{destination}/#{project_name}/src/js/atome"
|
203
216
|
kernel_js = "#{atome_directory}/kernel.js"
|
217
|
+
FileUtils.mkdir_p(atome_directory)
|
204
218
|
File.new kernel_js, 'w'
|
205
219
|
builder = Opal::Builder.new
|
206
220
|
builder.append_paths("#{source}/lib/")
|
@@ -243,22 +257,77 @@ def wasm_initialize (source, destination, project_name, wasi_source)
|
|
243
257
|
#### IMPORTANT TO REFRESH RUBY WASM TO THE LATEST VERSION, (when ruby_browser get far too large)
|
244
258
|
# and UNCOMMENT the line below : ('curl -LO ....')
|
245
259
|
unless File.exist?("#{wasm_temp_folder}/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz")
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
260
|
+
|
261
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
262
|
+
application_location = "#{destination}\\#{project_name}"
|
263
|
+
wasm_temp_folder = "#{application_location}\\tmp"
|
264
|
+
`cd /d #{wasm_temp_folder} && curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz
|
265
|
+
`
|
266
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
267
|
+
# Code à exécuter sous MacOS
|
268
|
+
# `cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
269
|
+
`cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
270
|
+
# debug : https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-minimal-js-debug.tar.gz
|
271
|
+
# standard : `cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
272
|
+
|
273
|
+
else
|
274
|
+
# Code à exécuter sous Unix/Linux
|
275
|
+
`cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
276
|
+
end
|
277
|
+
|
250
278
|
end
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
279
|
+
|
280
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
281
|
+
# Code à exécuter sous Windows
|
282
|
+
application_location = "#{destination}\\#{project_name}"
|
283
|
+
|
284
|
+
`cd /d #{wasm_temp_folder} && tar xfz ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
285
|
+
`move #{wasm_temp_folder}\\3_2-wasm32-unknown-wasi-full-js\\usr\\local\\bin\\ruby #{wasm_temp_folder}\\system_ruby_browser.wasm`
|
286
|
+
`del #{application_location}\\src\\wasm\\ruby_browser.wasm`
|
287
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
288
|
+
# Code à exécuter sous MacOS
|
289
|
+
`cd #{wasm_temp_folder}; tar xfz ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
290
|
+
`mv #{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr/local/bin/ruby #{wasm_temp_folder}/system_ruby_browser.wasm`
|
291
|
+
`rm -f #{application_location}/src/wasm/ruby_browser.wasm`
|
292
|
+
else
|
293
|
+
# Code à exécuter sous Unix/Linux
|
294
|
+
`cd #{wasm_temp_folder}; tar xfz ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
295
|
+
`mv #{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr/local/bin/ruby #{wasm_temp_folder}/system_ruby_browser.wasm`
|
296
|
+
`rm -f #{application_location}/src/wasm/ruby_browser.wasm`
|
297
|
+
end
|
298
|
+
|
299
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
300
|
+
# Code à exécuter sous Windows
|
301
|
+
cmd = <<~STRDELIM
|
302
|
+
"#{application_location}\\src-wasm\\wasm\\#{wasi_source}" pack "#{wasm_temp_folder}\\system_ruby_browser.wasm"
|
303
|
+
-mapdir usr::"#{wasm_temp_folder}\\3_2-wasm32-unknown-wasi-full-js\\usr"
|
304
|
+
-mapdir lib::"#{source}\\lib\\"
|
305
|
+
-mapdir \::"#{application_location}\\application\\"
|
306
|
+
-mapdir utilities::"#{application_location}\\src\\utilities\\"
|
307
|
+
-o "#{application_location}\\src\\wasm\\ruby_browser.wasm"
|
308
|
+
STRDELIM
|
309
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
310
|
+
# Code à exécuter sous MacOS
|
311
|
+
cmd = <<~STRDELIM
|
312
|
+
#{application_location}/src-wasm/wasm/#{wasi_source} pack #{wasm_temp_folder}/system_ruby_browser.wasm
|
313
|
+
--mapdir usr::#{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr
|
314
|
+
--mapdir lib::#{source}/lib/
|
315
|
+
--mapdir /::#{application_location}/application/
|
316
|
+
--mapdir utilities::#{application_location}/src/utilities/
|
317
|
+
-o #{application_location}/src/wasm/ruby_browser.wasm
|
318
|
+
STRDELIM
|
319
|
+
else
|
320
|
+
# Code à exécuter sous Unix/Linux
|
321
|
+
cmd = <<~STRDELIM
|
322
|
+
#{application_location}/src-wasm/wasm/#{wasi_source} pack #{wasm_temp_folder}/system_ruby_browser.wasm
|
323
|
+
--mapdir usr::#{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr
|
324
|
+
--mapdir lib::#{source}/lib/
|
325
|
+
--mapdir /::#{application_location}/application/
|
326
|
+
--mapdir utilities::#{application_location}/src/utilities/
|
327
|
+
-o #{application_location}/src/wasm/ruby_browser.wasm
|
328
|
+
STRDELIM
|
329
|
+
end
|
330
|
+
|
262
331
|
cleaned_cmd = cmd.lines.reject { |line| line.start_with?('#') }.join
|
263
332
|
command = cleaned_cmd.chomp.gsub("\n", ' ')
|
264
333
|
system(command)
|
@@ -277,14 +346,33 @@ end
|
|
277
346
|
|
278
347
|
def build_for_osx(destination, mode = :dev)
|
279
348
|
# dev or build
|
349
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
350
|
+
# Code à exécuter sous Windows
|
351
|
+
`cd /d #{destination} && cargo tauri #{mode}`
|
280
352
|
|
281
|
-
|
353
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
354
|
+
# Code à exécuter sous MacOS
|
355
|
+
`cd #{destination};cargo tauri #{mode}`
|
356
|
+
else
|
357
|
+
# Code à exécuter sous Unix/Linux
|
358
|
+
`cd #{destination};cargo tauri #{mode}`
|
359
|
+
end
|
282
360
|
|
283
361
|
end
|
284
362
|
|
285
363
|
def build_for_server(destination, project_name, port, production)
|
286
364
|
prod = '--env production' if production
|
287
|
-
|
365
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
366
|
+
# Code à exécuter sous Windows
|
367
|
+
`cd /d #{destination}\\#{project_name}\\server && puma --port #{port} #{prod}`
|
368
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
369
|
+
# Code à exécuter sous MacOS
|
370
|
+
`cd #{destination}/#{project_name}/server;puma --port #{port} #{prod}`
|
371
|
+
else
|
372
|
+
# Code à exécuter sous Unix/Linux
|
373
|
+
`cd #{destination}/#{project_name}/server;puma --port #{port} #{prod}`
|
374
|
+
end
|
375
|
+
|
288
376
|
end
|
289
377
|
|
290
378
|
# def run_application(build_target, location, port = 9292, production = false)
|
@@ -295,10 +383,24 @@ end
|
|
295
383
|
# below we analyse the ARGV
|
296
384
|
location = '/'
|
297
385
|
project_name = ARGV[1]
|
298
|
-
|
386
|
+
|
387
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
388
|
+
# Code à exécuter sous Windows
|
389
|
+
destination = `cd`.chomp
|
390
|
+
wasi_file = 'wasi-vfs.exe'
|
391
|
+
|
392
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
393
|
+
# Code à exécuter sous MacOS
|
394
|
+
destination = `pwd`.chomp
|
395
|
+
wasi_file = 'wasi-vfs-osx_arm' # default to osx arm
|
396
|
+
else
|
397
|
+
# Code à exécuter sous Unix/Linux
|
398
|
+
destination = `pwd`.chomp
|
399
|
+
wasi_file = 'wasi-vfs-unix'
|
400
|
+
end
|
401
|
+
|
299
402
|
source = Pathname(__FILE__).parent.parent.to_s
|
300
403
|
|
301
|
-
wasi_file = 'wasi-vfs-osx_arm' # default to osx arm
|
302
404
|
# TODO : get wasi params from ARG to allow compile on windows / Unix
|
303
405
|
if ARGV.include?('create')
|
304
406
|
create_application(source, destination, project_name)
|
@@ -319,23 +421,18 @@ end
|
|
319
421
|
if ARGV.include?('update')
|
320
422
|
# TODO: also update index.html and all other files except the application folder
|
321
423
|
# first we delete everything but application
|
322
|
-
|
323
|
-
|
424
|
+
|
425
|
+
files_to_treat = %w[server src-tauri src-wasm Guardfile Rakefile src/css src/js/atome src/js/third_parties src/medias
|
426
|
+
src/favicon.ico src/index.html src/index_opal.html src/index_server.html src/index_server_wasm.html]
|
427
|
+
files_to_treat.each do |item|
|
324
428
|
item_path = File.join(destination, item)
|
325
|
-
if File.directory?(item_path)
|
429
|
+
if File.directory?(item_path)
|
326
430
|
FileUtils.rm_rf(item_path) unless item == '.' || item == '..'
|
327
431
|
elsif File.file?(item_path)
|
328
432
|
File.delete(item_path)
|
329
433
|
end
|
330
|
-
|
331
|
-
|
332
|
-
puts "#{source}/vendor/assets"
|
333
|
-
|
334
|
-
update_source = "#{source}/vendor/assets"
|
335
|
-
|
336
|
-
Dir.glob("#{update_source}/*").each do |item|
|
337
|
-
target = File.join(destination, File.basename(item))
|
338
|
-
FileUtils.cp_r(item, target) unless File.exist?(target)
|
434
|
+
source_item = "#{source}/vendor/assets/#{item}"
|
435
|
+
FileUtils.cp_r(source_item, item)
|
339
436
|
end
|
340
437
|
end
|
341
438
|
|
@@ -349,7 +446,17 @@ if ARGV.include?('guard')
|
|
349
446
|
end
|
350
447
|
|
351
448
|
if ARGV.include?('run')
|
352
|
-
|
449
|
+
|
450
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
451
|
+
# Code à exécuter sous Windows
|
452
|
+
current_path = `cd`.chomp
|
453
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
454
|
+
# Code à exécuter sous MacOS
|
455
|
+
current_path = `pwd`.chomp
|
456
|
+
else
|
457
|
+
# Code à exécuter sous Unix/Linux
|
458
|
+
current_path = `pwd`.chomp
|
459
|
+
end
|
353
460
|
segments = current_path.split("/")
|
354
461
|
project_name = segments.last
|
355
462
|
destination = segments[0...-1].join("/")
|
@@ -366,7 +473,18 @@ if ARGV.include?('run')
|
|
366
473
|
threads = []
|
367
474
|
threads << Thread.new do
|
368
475
|
sleep 1
|
369
|
-
|
476
|
+
|
477
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
478
|
+
# Code à exécuter sous Windows
|
479
|
+
`start "" "#{destination}\\#{project_name}\\src\\index_opal.html`
|
480
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
481
|
+
# Code à exécuter sous MacOS
|
482
|
+
`open http://localhost:9292`
|
483
|
+
else
|
484
|
+
# Code à exécuter sous Unix/Linux
|
485
|
+
`open http://localhost:9292`
|
486
|
+
end
|
487
|
+
|
370
488
|
end
|
371
489
|
build_for_server(destination, project_name, 9292, :production)
|
372
490
|
when 'osx'
|
@@ -386,7 +504,18 @@ if ARGV.include?('run')
|
|
386
504
|
else
|
387
505
|
wasi_file = 'wasi-vfs-osx_arm'
|
388
506
|
wasm_common(source, destination, project_name, wasi_file, 'pure_wasm')
|
389
|
-
|
507
|
+
|
508
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
509
|
+
# Code à exécuter sous Windows
|
510
|
+
`start "" "#{current_path}\\src\\index.html"`
|
511
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
512
|
+
# Code à exécuter sous MacOS
|
513
|
+
`open #{current_path}/src/index.html`
|
514
|
+
else
|
515
|
+
# Code à exécuter sous Unix/Linux
|
516
|
+
`open #{current_path}/src/index.html`
|
517
|
+
end
|
518
|
+
|
390
519
|
end
|
391
520
|
|
392
521
|
end
|
@@ -2,10 +2,19 @@
|
|
2
2
|
|
3
3
|
# toolbox method here
|
4
4
|
require 'json'
|
5
|
+
|
5
6
|
class Atome
|
6
7
|
class << self
|
8
|
+
|
9
|
+
def file_handler(parent, content, bloc)
|
10
|
+
grab(parent).instance_exec(content, &bloc)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
7
15
|
def controller_sender(message)
|
8
16
|
return if $host == :html
|
17
|
+
|
9
18
|
json_msg = message.to_json
|
10
19
|
js_json_msg = json_msg.inspect
|
11
20
|
js_command = "atomeJS.controller_sender(#{js_json_msg})"
|
@@ -44,6 +53,9 @@ class Atome
|
|
44
53
|
end
|
45
54
|
|
46
55
|
# local server messaging
|
56
|
+
def file_for_opal(parent, bloc)
|
57
|
+
JS.eval("fileForOpal('#{parent}', #{bloc})")
|
58
|
+
end
|
47
59
|
|
48
60
|
def response_listener(hashed_msg)
|
49
61
|
js_action = hashed_msg.JS[:action]
|
@@ -127,6 +139,7 @@ class Atome
|
|
127
139
|
def atome_post_process(element, params, new_atome, &user_proc)
|
128
140
|
|
129
141
|
return unless Atome.instance_variable_get("@post_#{element}").is_a?(Proc)
|
142
|
+
|
130
143
|
new_atome.instance_exec(params, user_proc, &Atome.instance_variable_get("@post_#{element}"))
|
131
144
|
|
132
145
|
end
|
@@ -280,6 +293,7 @@ class Atome
|
|
280
293
|
debug "#{user_id} not found"
|
281
294
|
end
|
282
295
|
end
|
296
|
+
|
283
297
|
def remove_layout
|
284
298
|
display(:default)
|
285
299
|
# we get the current parent (the previous layout)
|
@@ -297,5 +311,4 @@ class Atome
|
|
297
311
|
end
|
298
312
|
end
|
299
313
|
|
300
|
-
|
301
314
|
end
|
data/lib/atome/version.rb
CHANGED
@@ -36,3 +36,49 @@ new({renderer: :html, method: :match}) do |params, bloc|
|
|
36
36
|
html.match(params)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
42
|
+
|
43
|
+
if Atome::host == 'web-opal'
|
44
|
+
file_for_opal(@id, bloc) do |file_content|
|
45
|
+
bloc.call(file_content)
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
# Wasm version
|
50
|
+
def create_file_browser(_options = '', &bloc)
|
51
|
+
div_element = JS.global[:document].getElementById(@id.to_s)
|
52
|
+
input_element = JS.global[:document].createElement("input")
|
53
|
+
input_element[:type] = "file"
|
54
|
+
input_element[:style][:position] = "absolute"
|
55
|
+
input_element[:style][:display] = "none"
|
56
|
+
input_element[:style][:width] = "0px"
|
57
|
+
input_element[:style][:height] = "0px"
|
58
|
+
|
59
|
+
input_element.addEventListener("change") do |native_event|
|
60
|
+
event = Native(native_event)
|
61
|
+
file = event[:target][:files][0]
|
62
|
+
if file
|
63
|
+
puts "file requested: #{file[:name]}"
|
64
|
+
file_reader = JS.global[:FileReader].new
|
65
|
+
file_reader.addEventListener("load") do |load_event|
|
66
|
+
file_content = load_event[:target][:result]
|
67
|
+
Atome.file_handler(@id, file_content, bloc)
|
68
|
+
end
|
69
|
+
file_reader.readAsText(file)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
div_element.addEventListener("mousedown") do |event|
|
74
|
+
input_element.click
|
75
|
+
end
|
76
|
+
div_element.appendChild(input_element)
|
77
|
+
end
|
78
|
+
create_file_browser(:options) do |file_content|
|
79
|
+
# puts "wasm ===>#{file_content}"
|
80
|
+
bloc.call(file_content)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -1,50 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
# id: :s3,
|
7
|
-
# left: 3, top: 3, blur: 9,
|
8
|
-
# invert: true,
|
9
|
-
# red: 0, green: 0, blue: 0, alpha: 0.7
|
10
|
-
# })
|
11
|
-
def create_file_browser
|
12
|
-
div_element = JS.global[:document].createElement("div")
|
13
|
-
|
14
|
-
# Définir les propriétés CSS de l'élément div
|
15
|
-
div_element[:style][:width] = "33px" # Taille: largeur de 100 pixels
|
16
|
-
div_element[:style][:height] = "33px" # Taille: hauteur de 100 pixels
|
17
|
-
div_element[:style][:backgroundColor] = "rgba(255,0,0,0.3)" # Couleur de fond rouge
|
18
|
-
div_element[:style][:position] = "absolute" # Positionnement absolu
|
19
|
-
div_element[:style][:top] = "0px" # Position par rapport au haut de l'écran
|
20
|
-
div_element[:style][:left] = "0px" # Position par rapport à la gauche de l'écran
|
21
|
-
|
22
|
-
# Définir un ID pour l'élément div
|
23
|
-
div_element[:id] = "monDiv"
|
24
|
-
|
25
|
-
input_element = JS.global[:document].createElement("input")
|
26
|
-
input_element[:type] = "file"
|
27
|
-
input_element[:style][:position] = "absolute"
|
28
|
-
input_element[:style][:display] = "none"
|
29
|
-
input_element[:style][:width] = "0px"
|
30
|
-
input_element[:style][:height] = "0px"
|
31
|
-
input_element.addEventListener("change") do |native_event|
|
32
|
-
event = Native(native_event)
|
33
|
-
file = event[:target][:files][0]
|
34
|
-
if file
|
35
|
-
puts "file requested: #{file[:name]}"
|
36
|
-
# support.controller({ action: :loadProject, params: { path: file[:name]} })
|
37
|
-
end
|
38
|
-
end
|
39
|
-
div_element.addEventListener("mousedown") do |event|
|
40
|
-
# Déclenchez manuellement un clic sur l'input
|
41
|
-
input_element.click
|
42
|
-
end
|
43
|
-
view_div = JS.global[:document].querySelector("#view")
|
44
|
-
|
45
|
-
view_div.appendChild(input_element)
|
46
|
-
view_div.appendChild(div_element)
|
47
|
-
|
3
|
+
b = box({ drag: true })
|
4
|
+
b.import(true) do |content|
|
5
|
+
puts "add code here, content: #{content}"
|
48
6
|
end
|
49
7
|
|
50
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
c=circle({left: 220})
|
5
|
-
t=text({left: 550,data: :hello,password: { read: {atome: :my_secret} }})
|
5
|
+
t=text({left: 550,data: :hello,password: { read: { atome: :my_secret} }})
|
6
6
|
b = box({ id: :the_box, left: 66,smooth: 1.789,
|
7
7
|
password: {
|
8
8
|
read: {
|
@@ -18,16 +18,16 @@ b = box({ id: :the_box, left: 66,smooth: 1.789,
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
b.authorise({ read: {atome: :the_pass,smooth: :read_pass }, write: {smooth: :write_pass}, destroy: true} )
|
21
|
+
b.authorise({ read: { atome: :the_pass, smooth: :read_pass }, write: { smooth: :write_pass}, destroy: true} )
|
22
22
|
puts b.smooth
|
23
23
|
# next will be rejected because destroy: true
|
24
24
|
puts b.smooth
|
25
25
|
#
|
26
|
-
b.authorise({ read: {atome: :wrong_pass,smooth: :no_read_pass }, write: {smooth: :wrong_write_pass}, destroy: false} )
|
26
|
+
b.authorise({ read: { atome: :wrong_pass, smooth: :no_read_pass }, write: { smooth: :wrong_write_pass}, destroy: false} )
|
27
27
|
puts 'will send the wrong password'
|
28
28
|
puts b.smooth
|
29
29
|
|
30
|
-
b.authorise({ read: {atome: :wrong_pass,smooth: :read_pass }, write: {smooth: :wrong_write_pass}, destroy: false} )
|
30
|
+
b.authorise({ read: { atome: :wrong_pass, smooth: :read_pass }, write: { smooth: :wrong_write_pass}, destroy: false} )
|
31
31
|
puts "'with send the right password it'll works"
|
32
32
|
puts b.smooth
|
33
33
|
# authorise has two params the first is the password to authorise the second is used to destroy the password or keep for
|
@@ -41,7 +41,7 @@ wait 1 do
|
|
41
41
|
b.authorise({write: {smooth: :write_pass}, destroy: false} )
|
42
42
|
b.smooth(66)
|
43
43
|
wait 1 do
|
44
|
-
b.authorise({write: {smooth: :false_pass, atome: :no_apss, destroy: true}} )
|
44
|
+
b.authorise({write: { smooth: :false_pass, atome: :no_apss, destroy: true}} )
|
45
45
|
b.smooth(6)
|
46
46
|
end
|
47
47
|
end
|