atome 0.5.6.2.0 → 0.5.6.2.3
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/lib/atome/genesis/generators/communication.rb +6 -4
- data/lib/atome/genesis/sparkle.rb +12 -5
- data/lib/atome/helpers/utilities.rb +12 -24
- data/lib/atome/kernel/universe.rb +13 -0
- data/lib/atome/version.rb +1 -1
- data/vendor/assets/application/examples/basic_understanding.rb +1 -1
- data/vendor/assets/application/examples/database_handling.rb +26 -10
- data/vendor/assets/application/examples/server.rb +15 -12
- data/vendor/assets/application/examples/test.rb +5 -26
- data/vendor/assets/server/atome_server.rb +8 -344
- data/vendor/assets/server/database.rb +217 -0
- data/vendor/assets/server/eDen.rb +65 -0
- data/vendor/assets/server/extensions.rb +13 -0
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +7 -16
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02c478a58bfcce998a040779efdc8970c38a1d5286f8ca942231132493707f7d
|
4
|
+
data.tar.gz: 930ebabe49f5824c66e03b3b1b8b53e1def6ad0ce26ff40f2110c07461970f8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9161e9c2364dd6eb8e85d44d93872ea43f52e241a19aac7f1f4697890b1d638faa0891a94e85d917a2f8e4e75e5e322170e1bbfab1223ea0d26c1ee32ee33797
|
7
|
+
data.tar.gz: 2136de3b80e45cff68ad2c0345baf11d2565473f591c27261c6f2942414ca5d4442338597ee4d29936bb306e707846da991337cd915535a2dce705fd6dc1756a
|
@@ -10,10 +10,12 @@ new({ particle: :message, category: :communication, type: :hash }) do |params, b
|
|
10
10
|
params = { data: params } unless params.instance_of? Hash
|
11
11
|
params[:user] = 'dfghg4df5gdfgh654'
|
12
12
|
params[:pass] = 'gfhkzrhgzr4h98948'
|
13
|
-
instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
|
14
|
-
store_proc= instance_variable_get('@message_code')
|
15
|
-
|
16
|
-
|
13
|
+
# instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
|
14
|
+
# store_proc= instance_variable_get('@message_code')
|
15
|
+
message_id= "msg_#{Universe.messages.length}"
|
16
|
+
params[:message_id]=message_id
|
17
|
+
# store_proc[mmessage_id]=bloc
|
18
|
+
Universe.store_messages({msg_nb:message_id, proc: bloc })
|
17
19
|
html.send_message(params)
|
18
20
|
|
19
21
|
end
|
@@ -141,7 +141,9 @@ end
|
|
141
141
|
def atome_genesis
|
142
142
|
atome_infos
|
143
143
|
A.server({ address: 'localhost:9292', type: 'ws' })
|
144
|
-
A.init_websocket
|
144
|
+
A.init_websocket do |msg|
|
145
|
+
puts "-3 #{msg}"
|
146
|
+
end
|
145
147
|
end
|
146
148
|
|
147
149
|
def init_database # this method is call from JS (atome/communication)
|
@@ -149,6 +151,7 @@ def init_database # this method is call from JS (atome/communication)
|
|
149
151
|
particles = Universe.particle_list
|
150
152
|
categories = Universe.categories
|
151
153
|
atomes = Universe.atomes
|
154
|
+
puts "we are here!!"
|
152
155
|
# particles.each do |particle, value|
|
153
156
|
# value[:category] = :undefined if value[:category].nil?
|
154
157
|
# A.message({ action: :init_db, particle: particle, type: value[:type], category: value[:category] })
|
@@ -156,8 +159,12 @@ def init_database # this method is call from JS (atome/communication)
|
|
156
159
|
end
|
157
160
|
|
158
161
|
def user_login
|
159
|
-
user = Universe.current_user
|
160
|
-
|
161
|
-
message({ action: :
|
162
|
-
|
162
|
+
# user = Universe.current_user
|
163
|
+
password = Black_matter.password
|
164
|
+
message({ action: :authentication, data: { email: 'jeezs@atome.one' } }) do |email|
|
165
|
+
puts "email received : #{email}"
|
166
|
+
end
|
167
|
+
message({ action: :authorization, data: { password: password } }) do |p|
|
168
|
+
puts "2 : #{p}"
|
169
|
+
end
|
163
170
|
end
|
@@ -177,13 +177,13 @@ class Atome
|
|
177
177
|
new_atome
|
178
178
|
end
|
179
179
|
|
180
|
-
def store(params)
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
end
|
180
|
+
# def store(params)
|
181
|
+
# params.each do |particle_to_save, data|
|
182
|
+
# # @!atome[particle_to_save]=data
|
183
|
+
# # instance_variable_set(particle_to_save,data)
|
184
|
+
# end
|
185
|
+
#
|
186
|
+
# end
|
187
187
|
|
188
188
|
def history(filter = {})
|
189
189
|
filter[:id] = @id
|
@@ -210,7 +210,7 @@ class Atome
|
|
210
210
|
# option_found = params.values[0]
|
211
211
|
# instance_variable_get(elem_code)["#{option_found}_code"] = user_proc
|
212
212
|
# else
|
213
|
-
|
213
|
+
instance_variable_get(elem_code)[element] = user_proc
|
214
214
|
# end
|
215
215
|
end
|
216
216
|
|
@@ -251,9 +251,9 @@ class Atome
|
|
251
251
|
else
|
252
252
|
instance_variable_get("@#{element}_code")[element]
|
253
253
|
# instance_exec(@callback[element], proc_found)if proc_found.is_a? Proc
|
254
|
-
|
254
|
+
end
|
255
255
|
# array_of_proc_found.each do |proc_found|
|
256
|
-
|
256
|
+
proc_found.call(return_params) if proc_found.is_a? Proc
|
257
257
|
# end if array_of_proc_found
|
258
258
|
|
259
259
|
# if array_of_proc_found
|
@@ -381,26 +381,14 @@ class Atome
|
|
381
381
|
end
|
382
382
|
|
383
383
|
def server_receiver(params)
|
384
|
-
|
385
|
-
|
386
|
-
calllbacks_found= instance_variable_get('@message_code')
|
387
|
-
# we delete the default message created by atome
|
388
|
-
calllbacks_found.delete(:message)
|
389
|
-
# we get the oldest available callback, to treat it
|
390
|
-
oldest_callback = calllbacks_found.delete(calllbacks_found.keys.first)
|
391
|
-
params=params[:return] #TODO : format retrun data correctly instead of this line
|
392
|
-
oldest_callback.call(params) if oldest_callback.is_a? Proc
|
393
|
-
# callback(:message, params)
|
384
|
+
callback_found = Universe.messages[params[:message_id]]
|
385
|
+
callback_found.call(params) if callback_found.is_a? Proc
|
394
386
|
end
|
395
387
|
|
396
388
|
def init_websocket
|
397
|
-
instance_variable_set('@message_code', {})
|
398
|
-
# connection is particle (communication.rb)
|
399
389
|
connection(@current_server)
|
400
390
|
end
|
401
391
|
|
402
|
-
|
403
|
-
|
404
392
|
def encrypt(string)
|
405
393
|
# if RUBY_ENGINE.downcase == 'opal' || 'wasm32-wasi'
|
406
394
|
# `sha256(#{string})`
|
@@ -9,6 +9,7 @@ class Universe
|
|
9
9
|
@renderer_list = %i[html browser headless server log]
|
10
10
|
@sanitizers = {}
|
11
11
|
@specificities = {}
|
12
|
+
@messages = {}
|
12
13
|
|
13
14
|
@categories = %w[ communication effect event geometry hierarchy identity material
|
14
15
|
property security spatial time utility ]
|
@@ -20,6 +21,18 @@ class Universe
|
|
20
21
|
class << self
|
21
22
|
attr_reader :atomes, :renderer_list, :atome_list, :particle_list, :classes, :counter, :atomes_specificities
|
22
23
|
|
24
|
+
def messages
|
25
|
+
@messages
|
26
|
+
end
|
27
|
+
|
28
|
+
def store_messages(new_msg)
|
29
|
+
@messages[new_msg[:msg_nb]] = new_msg[:proc]
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete_messages(msg_to_del)
|
33
|
+
@messages.delete(msg_to_del)
|
34
|
+
end
|
35
|
+
|
23
36
|
def set_help(particle, &doc)
|
24
37
|
@help[particle] = doc
|
25
38
|
end
|
data/lib/atome/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# The class Universe is used to
|
3
|
+
# The class Universe is used to retrieve some data needed for the atome framework
|
4
4
|
# per example you can retrieve the list of all available particles
|
5
5
|
puts Universe.particle_list
|
6
6
|
# this give at the date 14/11/2023 :
|
@@ -1,23 +1,39 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} })
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
|
4
|
+
puts "0 data received: #{datas}"
|
5
|
+
end
|
4
6
|
|
5
7
|
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
|
6
|
-
puts "my first insert #{data_received_from_server}"
|
8
|
+
puts "1 my first insert #{data_received_from_server}"
|
7
9
|
end
|
8
10
|
|
11
|
+
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
|
12
|
+
|
9
13
|
A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
|
10
|
-
puts "another insert : #{data_received_from_server}"
|
14
|
+
puts "2 another insert : #{data_received_from_server}"
|
11
15
|
end
|
12
16
|
|
13
17
|
A.message({ action: :query, data: { table: :identity } }) do |data_received|
|
14
|
-
puts "received : #{data_received}"
|
18
|
+
puts "3 received : #{data_received}"
|
19
|
+
end
|
20
|
+
|
21
|
+
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
|
22
|
+
puts "4 insert done : #{result}"
|
23
|
+
end
|
24
|
+
|
25
|
+
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
|
26
|
+
puts "5 last message received: #{result}"
|
15
27
|
end
|
16
28
|
|
17
|
-
A.message({ action: :insert, data: { table: :
|
18
|
-
puts "
|
29
|
+
A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
|
30
|
+
puts "6 test 1 : #{data_received_from_server}"
|
19
31
|
end
|
20
32
|
|
21
|
-
A.message({ action: :insert, data: { table: :identity, particle: :
|
22
|
-
puts "
|
33
|
+
A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
|
34
|
+
puts "7 test 2 : #{data_received_from_server}"
|
23
35
|
end
|
36
|
+
|
37
|
+
A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
|
38
|
+
puts "test 3 : #{data_received_from_server}"
|
39
|
+
end
|
@@ -4,18 +4,21 @@ user_password = {global: :all_star, read: { atome: :all_star }, write: { atome:
|
|
4
4
|
|
5
5
|
human({ id: :jeezs, login: true, password: user_password, data: { birthday: '10/05/2016' },selection: [], tag: { system: true } , attach: :user_view })
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
7
|
c = box({ color: :yellow, left: 333 })
|
13
|
-
|
14
8
|
c.touch(true) do
|
15
|
-
c.message({
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
c.message({data: 'cd ..;cd server;ls; pwd', action: :terminal }) do |result|
|
10
|
+
puts "shell command return: #{result}"
|
11
|
+
end
|
12
|
+
c.message({data: {source: 'capture.rb',operation: :read }, action: :file}) do |result|
|
13
|
+
|
14
|
+
puts "file read encoded_content: #{result[:data].gsub('\x23', '#')}"
|
15
|
+
end
|
16
|
+
c.message({ action: :file,data: {source: 'user_created_file.rb', operation: :write, value: :hello }})do |result|
|
17
|
+
puts "file creation result : #{result}"
|
18
|
+
end
|
19
|
+
|
20
|
+
A.message({ action: :terminal , data: 'cd ..;cd server;ls; pwd'}) do |result|
|
21
|
+
puts "result : #{result}"
|
22
|
+
end
|
20
23
|
end
|
21
|
-
|
24
|
+
#
|
@@ -1,27 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
human({ id: :jeezs, login: true, password: user_password, data: { birthday: '10/05/2016' },selection: [], tag: { system: true } , attach: :user_view })
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
# b = box({ color: :red, id: :my_box })
|
12
|
-
#
|
13
|
-
# b.touch(true) do
|
14
|
-
# b.connection('localhost:9292') do |params|
|
15
|
-
# alert " the connection is : #{params}"
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
|
19
|
-
b = box({ color: :yellow, left: 333 })
|
20
|
-
|
21
|
-
b.touch(true) do
|
22
|
-
b.message({message: 'cd ..;cd server;ls; pwd', action: :terminal })
|
23
|
-
b.message({message: 'capture.rb', action: :file, option: :read })
|
24
|
-
b.message({message: 'tototo.rb', action: :file, option: :write, value: :hello })
|
25
|
-
# b.message({message: 'cd ..;cd server;ls; pwd'})
|
26
|
-
# c = box({ color: :red, left: 333 })
|
27
|
-
end
|
3
|
+
my_pass = Black_matter.encode('hell')
|
4
|
+
puts my_pass
|
5
|
+
checker = Black_matter.check_password('hello,', my_pass)
|
6
|
+
puts checker
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# atome server
|
4
|
+
|
4
5
|
require 'em/pure_ruby' if RUBY_PLATFORM == 'x64-mingw32'
|
5
6
|
require 'fileutils'
|
6
7
|
require '../src/utilities/aui'
|
@@ -14,341 +15,13 @@ require 'roda'
|
|
14
15
|
require 'rufus-scheduler'
|
15
16
|
require 'securerandom'
|
16
17
|
require 'sequel'
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def self.db_access
|
21
|
-
Database.connect_database
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.terminal(cmd, option, ws, value, user, pass)
|
25
|
-
{ return: `#{cmd}` }
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.pass(cmd, option, ws, value, user, pass)
|
29
|
-
{ return: 'pass received' }
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.init_db(cmd, option, ws, value, user, pass)
|
33
|
-
# Database.
|
34
|
-
{ return: 'database initialised' }
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.query(cmd, option, ws, value, user, pass)
|
38
|
-
identity_table = db_access[cmd['table'].to_sym]
|
39
|
-
result = identity_table.send(:all).send(:select)
|
40
|
-
{ action: :query, data: cmd['table'], return: result }
|
41
|
-
end
|
42
|
-
|
43
|
-
# def self.insert(cmd, option, ws, value, user, pass)
|
44
|
-
# identity_table = db_access[:identity]
|
45
|
-
# identity_table.insert(email: 'tre@tre')
|
46
|
-
# { action: :insert, data: cmd, return: { email: 'tre@tre' } }
|
47
|
-
# end
|
48
|
-
|
49
|
-
def self.insert(params, option, ws, value, user, pass)
|
50
|
-
table = params['table']
|
51
|
-
particle = params['particle']
|
52
|
-
data = params['data']
|
53
|
-
identity_table = db_access[table.to_sym]
|
54
|
-
# identity_table = db_access[:identity]
|
55
|
-
#######
|
56
|
-
identity_table.insert(particle => data )
|
57
|
-
# identity_table.insert(email: 'tre@tre')
|
58
|
-
#
|
59
|
-
{ return: "column : #{particle}, in table : #{table}, updated with : #{data}" }
|
60
|
-
end
|
61
|
-
|
62
|
-
# def self.authentification(cmd, option, ws, value, user, pass)
|
63
|
-
# db = Database.connect_database
|
64
|
-
# identity_items = db[:identity]
|
65
|
-
# security_items = db[:security]
|
66
|
-
#
|
67
|
-
# identity_items.insert(email: 'tre@tre')
|
68
|
-
# security_items.insert(password: 'poipoi')
|
69
|
-
# # testtest= "Mails count: #{identity_items.count}"
|
70
|
-
#
|
71
|
-
# user_email = value["mail"]
|
72
|
-
# user_password = value["pass"]
|
73
|
-
#
|
74
|
-
# # user_exists = identity_items.all.select{|item| item[:email]==user_email}
|
75
|
-
# user_exists = identity_items.send(:all).send(:select) do |item|
|
76
|
-
# item[:email] == user_email
|
77
|
-
# end
|
78
|
-
#
|
79
|
-
# if user_exists.empty?
|
80
|
-
# # "Mails count: #{identity_items.count}"
|
81
|
-
# # "Mails count: #{identity_items.all}"
|
82
|
-
# "Email non trouvé, erreur"
|
83
|
-
# # Ask to the user if he wants to subscribe
|
84
|
-
# # Send the basic template
|
85
|
-
# else
|
86
|
-
# "Email trouvé, cherche mdp"
|
87
|
-
# # Verify password
|
88
|
-
# # If password isn't ok, send error
|
89
|
-
# # If the password is ok, send the user account template
|
90
|
-
# end
|
91
|
-
# end
|
92
|
-
|
93
|
-
def self.file(source, operation, ws, value, user, pass)
|
94
|
-
file_content = File.send(operation, source, value).to_s
|
95
|
-
file_content = file_content.gsub("'", "\"")
|
96
|
-
{ return: "=> operation: #{operation}, source: #{source} , content : #{file_content}" }
|
97
|
-
end
|
98
|
-
|
99
|
-
# return_message = EDen.safe_send(action_requested, data,option, current_user, user_pass)
|
100
|
-
|
101
|
-
def self.safe_send(method_name, *args)
|
102
|
-
method_sym = method_name.to_sym
|
103
|
-
eden_methods = EDen.singleton_methods(false) - Object.singleton_methods
|
104
|
-
if eden_methods.include?(method_sym)
|
105
|
-
send(method_sym, *args)
|
106
|
-
else
|
107
|
-
{ return: "forbidden action: #{method_name}" }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
18
|
+
require './eDen'
|
19
|
+
require './database'
|
20
|
+
require './extensions'
|
111
21
|
|
112
22
|
Faye::WebSocket.load_adapter('puma')
|
113
23
|
|
114
|
-
class String
|
115
|
-
def is_json?
|
116
|
-
begin
|
117
|
-
!JSON.parse(self).nil?
|
118
|
-
rescue
|
119
|
-
false
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
class Database
|
125
|
-
|
126
|
-
def self.table_exists?(table_name)
|
127
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
128
|
-
if eden.table_exists?(table_name)
|
129
|
-
puts "La table #{table_name} existe dans la base de données."
|
130
|
-
else
|
131
|
-
puts "La table suivante : #{table_name} n'existe pas dans la base de données."
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
# def self.create_table(table_name)
|
137
|
-
def self.connect_database
|
138
|
-
if File.exist?("eden.sqlite3")
|
139
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
140
|
-
# now we test if the table exist
|
141
|
-
table_exists?(:table_name)
|
142
|
-
else
|
143
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
144
|
-
eden.create_table :atome do
|
145
|
-
primary_key :atome_id
|
146
|
-
String :creator
|
147
|
-
end
|
148
|
-
|
149
|
-
eden.create_table :communication do
|
150
|
-
primary_key :communication_id
|
151
|
-
String :connection
|
152
|
-
JSON :data
|
153
|
-
JSON :controller
|
154
|
-
end
|
155
|
-
|
156
|
-
###################
|
157
|
-
|
158
|
-
Sequel.extension :migration
|
159
|
-
|
160
|
-
Sequel.migration do
|
161
|
-
change do
|
162
|
-
add_column :communication, :jesaispas, String
|
163
|
-
end
|
164
|
-
end.apply(eden, :up)
|
165
|
-
|
166
|
-
###################
|
167
|
-
|
168
|
-
eden.create_table :effect do
|
169
|
-
primary_key :effect_id
|
170
|
-
Int :smooth
|
171
|
-
Int :blur
|
172
|
-
end
|
173
|
-
|
174
|
-
eden.create_table :event do
|
175
|
-
primary_key :event_id
|
176
|
-
JSON :touch
|
177
|
-
Boolean :play
|
178
|
-
Boolean :pause
|
179
|
-
Int :time
|
180
|
-
Boolean :on
|
181
|
-
Boolean :fullscreen
|
182
|
-
Boolean :mute
|
183
|
-
Boolean :drag
|
184
|
-
Boolean :drop
|
185
|
-
Boolean :over
|
186
|
-
String :targets
|
187
|
-
Boolean :start
|
188
|
-
Boolean :stop
|
189
|
-
Time :begin
|
190
|
-
Time :end
|
191
|
-
Int :duration
|
192
|
-
Int :mass
|
193
|
-
Int :damping
|
194
|
-
Int :stiffness
|
195
|
-
Int :velocity
|
196
|
-
Boolean :repeat
|
197
|
-
Boolean :ease
|
198
|
-
Boolean :keyboard
|
199
|
-
Boolean :resize
|
200
|
-
Boolean :overflow
|
201
|
-
end
|
202
|
-
|
203
|
-
eden.create_table :geometry do
|
204
|
-
primary_key :geometry_id
|
205
|
-
Int :width
|
206
|
-
Int :height
|
207
|
-
Int :size
|
208
|
-
end
|
209
|
-
|
210
|
-
eden.create_table :hierarchy do
|
211
|
-
primary_key :hierarchy_id
|
212
|
-
String :attach
|
213
|
-
String :attached
|
214
|
-
String :apply
|
215
|
-
String :affect
|
216
|
-
String :detached
|
217
|
-
String :collect
|
218
|
-
end
|
219
|
-
|
220
|
-
eden.create_table :identity do
|
221
|
-
primary_key :identity_id
|
222
|
-
String :real
|
223
|
-
String :type
|
224
|
-
Int :id
|
225
|
-
String :name
|
226
|
-
String :firstname
|
227
|
-
String :email
|
228
|
-
String :nickname
|
229
|
-
Boolean :active
|
230
|
-
String :markup
|
231
|
-
String :bundle
|
232
|
-
String :data
|
233
|
-
String :category
|
234
|
-
String :selection
|
235
|
-
Boolean :selected
|
236
|
-
String :format
|
237
|
-
String :alien
|
238
|
-
end
|
239
|
-
|
240
|
-
eden.create_table :material do
|
241
|
-
primary_key :material_id
|
242
|
-
String :component
|
243
|
-
Boolean :edit
|
244
|
-
String :style
|
245
|
-
Boolean :hide
|
246
|
-
Boolean :remove
|
247
|
-
JSON :classes
|
248
|
-
Boolean :remove_classes
|
249
|
-
Int :opacity
|
250
|
-
String :definition
|
251
|
-
Int :gradient
|
252
|
-
Int :border
|
253
|
-
end
|
254
|
-
|
255
|
-
eden.create_table :property do
|
256
|
-
primary_key :property_id
|
257
|
-
String :red
|
258
|
-
String :green
|
259
|
-
String :blue
|
260
|
-
String :alpha
|
261
|
-
String :diffusion
|
262
|
-
Boolean :clean
|
263
|
-
String :insert
|
264
|
-
Boolean :remove
|
265
|
-
Int :sort
|
266
|
-
end
|
267
|
-
|
268
|
-
eden.create_table :security do
|
269
|
-
primary_key :security_id
|
270
|
-
String :password
|
271
|
-
end
|
272
|
-
|
273
|
-
eden.create_table :spatial do
|
274
|
-
primary_key :spatial_id
|
275
|
-
Int :left
|
276
|
-
Int :right
|
277
|
-
Int :top
|
278
|
-
Int :bottom
|
279
|
-
Int :rotate
|
280
|
-
String :direction
|
281
|
-
String :center
|
282
|
-
Int :depth
|
283
|
-
Int :position
|
284
|
-
String :organise
|
285
|
-
String :spacing
|
286
|
-
Boolean :display
|
287
|
-
String :layout
|
288
|
-
end
|
289
|
-
|
290
|
-
eden.create_table :time do
|
291
|
-
primary_key :time_id
|
292
|
-
JSON :markers
|
293
|
-
end
|
294
|
-
|
295
|
-
eden.create_table :utility do
|
296
|
-
primary_key :utility_id
|
297
|
-
String :renderers
|
298
|
-
String :code
|
299
|
-
Boolean :run
|
300
|
-
Boolean :delete
|
301
|
-
Boolean :clear
|
302
|
-
String :path
|
303
|
-
String :schedule
|
304
|
-
String :read
|
305
|
-
String :cursor
|
306
|
-
String :preset
|
307
|
-
JSON :relations
|
308
|
-
JSON :tag
|
309
|
-
String :web
|
310
|
-
JSON :unit
|
311
|
-
String :initialize
|
312
|
-
String :login
|
313
|
-
String :hypertext
|
314
|
-
String :hyperedit
|
315
|
-
String :terminal
|
316
|
-
String :browse
|
317
|
-
String :copies
|
318
|
-
Int :temporary
|
319
|
-
String :atomes
|
320
|
-
String :match
|
321
|
-
Boolean :invert
|
322
|
-
String :option
|
323
|
-
String :duplicate
|
324
|
-
String :copy
|
325
|
-
String :paste
|
326
|
-
String :backup
|
327
|
-
String :import
|
328
|
-
String :compute
|
329
|
-
String :get
|
330
|
-
end
|
331
|
-
|
332
|
-
end
|
333
|
-
eden
|
334
|
-
end
|
335
|
-
|
336
|
-
end
|
337
|
-
|
338
24
|
class App < Roda
|
339
|
-
|
340
|
-
# comment below when test will be done
|
341
|
-
# File.delete("./eden.sqlite3") if File.exist?("./eden.sqlite3")
|
342
|
-
eden = Database.connect_database
|
343
|
-
items = eden[:atome]
|
344
|
-
|
345
|
-
# populate the table
|
346
|
-
items.insert(creator: 'moi')
|
347
|
-
items.insert(creator: 'toi')
|
348
|
-
items.insert(creator: 'vous')
|
349
|
-
puts "Item count: #{items.count}"
|
350
|
-
test = "Item count: #{items.count}"
|
351
|
-
# puts "My name is: #{items(:creator)}"
|
352
25
|
index_content = File.read("../src/index_server.html")
|
353
26
|
opts[:root] = '../src'
|
354
27
|
plugin :static, %w[/css /js /medias], root: '../src'
|
@@ -356,34 +29,25 @@ class App < Roda
|
|
356
29
|
r.root do
|
357
30
|
if Faye::WebSocket.websocket?(r.env)
|
358
31
|
ws = Faye::WebSocket.new(r.env)
|
359
|
-
ws.on :open do |
|
32
|
+
ws.on :open do |_event|
|
360
33
|
ws.send({ return: 'server ready' }.to_json)
|
361
|
-
# ws.send('asking for synchro data'.to_json)
|
362
34
|
end
|
363
|
-
|
364
35
|
ws.on(:message) do |event|
|
365
36
|
json_string = event.data.gsub(/(\w+):/) { "\"#{$1}\":" }.gsub('=>', ':')
|
366
37
|
full_data = JSON.parse(json_string)
|
367
38
|
data = full_data['data']
|
368
39
|
action_requested = full_data['action']
|
369
|
-
|
370
|
-
|
371
|
-
current_user = full_data['user']
|
372
|
-
user_pass = full_data['pass']['global']
|
373
|
-
# return_message = EDen.safe_send(action_requested, data, option, ws, value, current_user, user_pass)
|
374
|
-
return_message = EDen.safe_send(action_requested, data, option, ws, value, current_user, user_pass)
|
40
|
+
message_id = full_data['message_id']
|
41
|
+
return_message = EDen.safe_send(action_requested, data, message_id)
|
375
42
|
ws.send(return_message.to_json)
|
376
43
|
end
|
377
|
-
|
378
44
|
ws.on(:close) do |event|
|
379
45
|
puts "server closed with status #{event.code}"
|
380
46
|
end
|
381
47
|
ws.rack_response
|
382
48
|
end
|
383
|
-
|
384
49
|
index_content
|
385
50
|
end
|
386
|
-
|
387
51
|
end
|
388
52
|
|
389
|
-
end
|
53
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# database handling for eDen Db
|
4
|
+
|
5
|
+
class Database
|
6
|
+
|
7
|
+
def self.table_exists?(table_name)
|
8
|
+
eden = Sequel.connect("sqlite://eden.sqlite3")
|
9
|
+
if eden.table_exists?(table_name)
|
10
|
+
puts "La table #{table_name} existe dans la base de données."
|
11
|
+
else
|
12
|
+
puts "La table suivante : #{table_name} n'existe pas dans la base de données."
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# def self.create_table(table_name)
|
18
|
+
def self.connect_database
|
19
|
+
if File.exist?("eden.sqlite3")
|
20
|
+
eden = Sequel.connect("sqlite://eden.sqlite3")
|
21
|
+
# now we test if the table exist
|
22
|
+
table_exists?(:table_name)
|
23
|
+
else
|
24
|
+
eden = Sequel.connect("sqlite://eden.sqlite3")
|
25
|
+
eden.create_table :atome do
|
26
|
+
primary_key :atome_id
|
27
|
+
String :creator
|
28
|
+
end
|
29
|
+
|
30
|
+
eden.create_table :communication do
|
31
|
+
primary_key :communication_id
|
32
|
+
String :connection
|
33
|
+
JSON :data
|
34
|
+
JSON :controller
|
35
|
+
end
|
36
|
+
|
37
|
+
###################
|
38
|
+
|
39
|
+
Sequel.extension :migration
|
40
|
+
|
41
|
+
Sequel.migration do
|
42
|
+
change do
|
43
|
+
add_column :communication, :jesaispas, String
|
44
|
+
end
|
45
|
+
end.apply(eden, :up)
|
46
|
+
|
47
|
+
###################
|
48
|
+
|
49
|
+
eden.create_table :effect do
|
50
|
+
primary_key :effect_id
|
51
|
+
Int :smooth
|
52
|
+
Int :blur
|
53
|
+
end
|
54
|
+
|
55
|
+
eden.create_table :event do
|
56
|
+
primary_key :event_id
|
57
|
+
JSON :touch
|
58
|
+
Boolean :play
|
59
|
+
Boolean :pause
|
60
|
+
Int :time
|
61
|
+
Boolean :on
|
62
|
+
Boolean :fullscreen
|
63
|
+
Boolean :mute
|
64
|
+
Boolean :drag
|
65
|
+
Boolean :drop
|
66
|
+
Boolean :over
|
67
|
+
String :targets
|
68
|
+
Boolean :start
|
69
|
+
Boolean :stop
|
70
|
+
Time :begin
|
71
|
+
Time :end
|
72
|
+
Int :duration
|
73
|
+
Int :mass
|
74
|
+
Int :damping
|
75
|
+
Int :stiffness
|
76
|
+
Int :velocity
|
77
|
+
Boolean :repeat
|
78
|
+
Boolean :ease
|
79
|
+
Boolean :keyboard
|
80
|
+
Boolean :resize
|
81
|
+
Boolean :overflow
|
82
|
+
end
|
83
|
+
|
84
|
+
eden.create_table :geometry do
|
85
|
+
primary_key :geometry_id
|
86
|
+
Int :width
|
87
|
+
Int :height
|
88
|
+
Int :size
|
89
|
+
end
|
90
|
+
|
91
|
+
eden.create_table :hierarchy do
|
92
|
+
primary_key :hierarchy_id
|
93
|
+
String :attach
|
94
|
+
String :attached
|
95
|
+
String :apply
|
96
|
+
String :affect
|
97
|
+
String :detached
|
98
|
+
String :collect
|
99
|
+
end
|
100
|
+
|
101
|
+
eden.create_table :identity do
|
102
|
+
primary_key :identity_id
|
103
|
+
String :real
|
104
|
+
String :type
|
105
|
+
Int :id
|
106
|
+
String :name
|
107
|
+
String :firstname
|
108
|
+
String :email
|
109
|
+
String :nickname
|
110
|
+
Boolean :active
|
111
|
+
String :markup
|
112
|
+
String :bundle
|
113
|
+
String :data
|
114
|
+
String :category
|
115
|
+
String :selection
|
116
|
+
Boolean :selected
|
117
|
+
String :format
|
118
|
+
String :alien
|
119
|
+
end
|
120
|
+
|
121
|
+
eden.create_table :material do
|
122
|
+
primary_key :material_id
|
123
|
+
String :component
|
124
|
+
Boolean :edit
|
125
|
+
String :style
|
126
|
+
Boolean :hide
|
127
|
+
Boolean :remove
|
128
|
+
JSON :classes
|
129
|
+
Boolean :remove_classes
|
130
|
+
Int :opacity
|
131
|
+
String :definition
|
132
|
+
Int :gradient
|
133
|
+
Int :border
|
134
|
+
end
|
135
|
+
|
136
|
+
eden.create_table :property do
|
137
|
+
primary_key :property_id
|
138
|
+
String :red
|
139
|
+
String :green
|
140
|
+
String :blue
|
141
|
+
String :alpha
|
142
|
+
String :diffusion
|
143
|
+
Boolean :clean
|
144
|
+
String :insert
|
145
|
+
Boolean :remove
|
146
|
+
Int :sort
|
147
|
+
end
|
148
|
+
|
149
|
+
eden.create_table :security do
|
150
|
+
primary_key :security_id
|
151
|
+
String :password
|
152
|
+
end
|
153
|
+
|
154
|
+
eden.create_table :spatial do
|
155
|
+
primary_key :spatial_id
|
156
|
+
Int :left
|
157
|
+
Int :right
|
158
|
+
Int :top
|
159
|
+
Int :bottom
|
160
|
+
Int :rotate
|
161
|
+
String :direction
|
162
|
+
String :center
|
163
|
+
Int :depth
|
164
|
+
Int :position
|
165
|
+
String :organise
|
166
|
+
String :spacing
|
167
|
+
Boolean :display
|
168
|
+
String :layout
|
169
|
+
end
|
170
|
+
|
171
|
+
eden.create_table :time do
|
172
|
+
primary_key :time_id
|
173
|
+
JSON :markers
|
174
|
+
end
|
175
|
+
|
176
|
+
eden.create_table :utility do
|
177
|
+
primary_key :utility_id
|
178
|
+
String :renderers
|
179
|
+
String :code
|
180
|
+
Boolean :run
|
181
|
+
Boolean :delete
|
182
|
+
Boolean :clear
|
183
|
+
String :path
|
184
|
+
String :schedule
|
185
|
+
String :read
|
186
|
+
String :cursor
|
187
|
+
String :preset
|
188
|
+
JSON :relations
|
189
|
+
JSON :tag
|
190
|
+
String :web
|
191
|
+
JSON :unit
|
192
|
+
String :initialize
|
193
|
+
String :login
|
194
|
+
String :hypertext
|
195
|
+
String :hyperedit
|
196
|
+
String :terminal
|
197
|
+
String :browse
|
198
|
+
String :copies
|
199
|
+
Int :temporary
|
200
|
+
String :atomes
|
201
|
+
String :match
|
202
|
+
Boolean :invert
|
203
|
+
String :option
|
204
|
+
String :duplicate
|
205
|
+
String :copy
|
206
|
+
String :paste
|
207
|
+
String :backup
|
208
|
+
String :import
|
209
|
+
String :compute
|
210
|
+
String :get
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
eden
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# server utils to handle eDen Db
|
4
|
+
|
5
|
+
class EDen
|
6
|
+
|
7
|
+
def self.db_access
|
8
|
+
Database.connect_database
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.terminal(data, message_id)
|
12
|
+
{ data: { message: `#{data}` }, message_id: message_id }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.authorization(_data, message_id)
|
16
|
+
{ data: { message: 'password received'}, message_id: message_id }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.authentication(_data, message_id)
|
20
|
+
{ data: { message: 'login received' }, message_id: message_id }
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.init_db(_data, message_id)
|
24
|
+
{ data: { message: 'database initialised' }, message_id: message_id }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.query(data, message_id)
|
28
|
+
identity_table = db_access[data['table'].to_sym]
|
29
|
+
result = identity_table.send(:all).send(:select)
|
30
|
+
{ data: { table: data['table'], infos: result }, message_id: message_id }
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.insert(data, message_id)
|
34
|
+
table = data['table'].to_sym
|
35
|
+
particle = data['particle'].to_sym
|
36
|
+
data = data['data']
|
37
|
+
if db_access.table_exists?(table)
|
38
|
+
schema = db_access.schema(table)
|
39
|
+
if schema.any? { |col_def| col_def.first == particle }
|
40
|
+
identity_table = db_access[table.to_sym]
|
41
|
+
identity_table.insert(particle => data)
|
42
|
+
{ data: { message: "column : #{particle}, in table : #{table}, updated with : #{data}"}, message_id: message_id }
|
43
|
+
else
|
44
|
+
{ data: { message: "column not found: #{particle.class}" }, message_id: message_id }
|
45
|
+
end
|
46
|
+
else
|
47
|
+
{ data: { message: "table not found: #{table.class}" }, message_id: message_id }
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.file(data, message_id)
|
53
|
+
|
54
|
+
file_content = File.send(data['operation'], data['source'], data['value']).to_s
|
55
|
+
file_content = file_content.gsub("'", "\"")
|
56
|
+
|
57
|
+
file_content = file_content.gsub('#', '\x23')
|
58
|
+
{ data: "=> operation: #{data['operation']}, source: #{data['source']}, content: #{file_content}", message_id: message_id }
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.safe_send(method_name, data, message_id)
|
62
|
+
method_sym = method_name.to_sym
|
63
|
+
send(method_sym, data, message_id)
|
64
|
+
end
|
65
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
const communication = {
|
2
|
-
// websocket: new WebSocket('ws://localhost:9292'),
|
3
2
|
websocket: null,
|
4
3
|
initialize: function () {
|
5
4
|
this.websocket = new WebSocket('ws://localhost:9292')
|
@@ -10,9 +9,7 @@ const communication = {
|
|
10
9
|
};
|
11
10
|
|
12
11
|
this.websocket.onmessage = function (event) {
|
13
|
-
rubyVMCallback('message', "('" + event.data
|
14
|
-
|
15
|
-
// rubyVMCallback("puts 'object ruby callback : " + event.data + "'")
|
12
|
+
rubyVMCallback('message', "('" + event.data + "')")
|
16
13
|
};
|
17
14
|
|
18
15
|
this.websocket.onclose = function (event) {
|
@@ -65,22 +62,16 @@ const communication = {
|
|
65
62
|
}
|
66
63
|
},
|
67
64
|
connect: function (type, server, user, pass, atomes, particles) {
|
68
|
-
this.websocket = new WebSocket(type+'://'+server);
|
65
|
+
this.websocket = new WebSocket(type + '://' + server);
|
69
66
|
this.websocket.onopen = function (event) {
|
70
67
|
|
71
|
-
//
|
72
|
-
// now new can exec user code : loadApplicationJs in index.html
|
73
|
-
// rubyVMCallback("A.init_database");
|
68
|
+
// now new can exec user code : loadApplicationJs in index.html
|
74
69
|
loadApplicationJs();
|
75
70
|
rubyVMCallback("A.user_login");
|
76
|
-
// rubyVMCallback("A.init_database");
|
77
71
|
};
|
78
72
|
this.websocket.onmessage = function (event) {
|
79
|
-
//
|
80
|
-
|
81
|
-
// rubyVMCallback("A.callback({ touch: '" + event.data + "' })");
|
82
|
-
rubyVMCallback("A.server_receiver(" + event.data + ")");
|
83
|
-
// alert(event.data)
|
73
|
+
// console.log(event.data)
|
74
|
+
rubyVMCallback("A.server_receiver(" + event.data + ")");
|
84
75
|
};
|
85
76
|
|
86
77
|
this.websocket.onclose = function (event) {
|
@@ -97,6 +88,7 @@ const communication = {
|
|
97
88
|
},
|
98
89
|
ws_sender: function (message) {
|
99
90
|
// now we send the data to the server
|
91
|
+
// puts "--> message : #{message}"
|
100
92
|
this.websocket.send(message)
|
101
93
|
},
|
102
94
|
}
|
@@ -130,8 +122,7 @@ const communication = {
|
|
130
122
|
// }
|
131
123
|
|
132
124
|
|
133
|
-
|
134
|
-
function controller_message(msg){
|
125
|
+
function controller_message(msg) {
|
135
126
|
// message receiver from controller (Vie)
|
136
127
|
console.log(msg)
|
137
128
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.6.2.
|
4
|
+
version: 0.5.6.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Eric Godard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: artoo
|
@@ -622,6 +622,9 @@ files:
|
|
622
622
|
- vendor/assets/server/atome_server_wasm.rb
|
623
623
|
- vendor/assets/server/capture.rb
|
624
624
|
- vendor/assets/server/config.ru
|
625
|
+
- vendor/assets/server/database.rb
|
626
|
+
- vendor/assets/server/eDen.rb
|
627
|
+
- vendor/assets/server/extensions.rb
|
625
628
|
- vendor/assets/src-tauri/.gitignore
|
626
629
|
- vendor/assets/src-tauri/Cargo.toml
|
627
630
|
- vendor/assets/src-tauri/build.rs
|