atome 0.5.6.2.1 → 0.5.6.2.4
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 +2 -2
- data/lib/atome/genesis/generators/identity.rb +3 -1
- data/lib/atome/genesis/generators/utility.rb +9 -2
- data/lib/atome/genesis/sparkle.rb +30 -12
- data/lib/atome/version.rb +1 -1
- data/lib/renderers/html/property.rb +0 -8
- data/vendor/assets/application/examples/basic_understanding.rb +1 -1
- data/vendor/assets/application/examples/database_handling.rb +39 -39
- 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 +7 -300
- data/vendor/assets/server/atome_server_wasm.rb +37 -37
- data/vendor/assets/server/database.rb +35 -0
- data/vendor/assets/server/eDen.rb +112 -0
- data/vendor/assets/server/extensions.rb +13 -0
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +2 -1
- 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: 5a31a51c4b23141c27202a017b8eda058b7fc25fb7d9bc0b2efd13ddb7eaf252
|
4
|
+
data.tar.gz: 30b7d9e1d5fcfbd1bdfa358df8a1c122be32c7fb10825f7bfc470ab8742077cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b85398a923c15fa0ee33f1e96eb56df3938d38c3c938631e9d97f34ff3c0c8628d185573817da9d25474ab3edddb51c76879a91865414d1b1eec31b506f60f9
|
7
|
+
data.tar.gz: d84a2f1c53c250e01c70b80b50fef4bcb0ab73687e924715b2d42b27bde2aa18c7d92f8434b5d5d7810fdacf9d5538d04c14f6d15137ab8aee64a29c8f43acd3
|
@@ -8,8 +8,8 @@ end
|
|
8
8
|
|
9
9
|
new({ particle: :message, category: :communication, type: :hash }) do |params, bloc|
|
10
10
|
params = { data: params } unless params.instance_of? Hash
|
11
|
-
params[:user] = 'dfghg4df5gdfgh654'
|
12
|
-
params[:pass] = 'gfhkzrhgzr4h98948'
|
11
|
+
# params[:user] = 'dfghg4df5gdfgh654'
|
12
|
+
# params[:pass] = 'gfhkzrhgzr4h98948'
|
13
13
|
# instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
|
14
14
|
# store_proc= instance_variable_get('@message_code')
|
15
15
|
message_id= "msg_#{Universe.messages.length}"
|
@@ -61,4 +61,6 @@ new(particle: :selected, category: :identity, type: :boolean) do |params|
|
|
61
61
|
end
|
62
62
|
|
63
63
|
new({ particle: :format, category: :identity, type: :string })
|
64
|
-
new({ particle: :alien, category: :identity, type: :string }) #special particel that old alien object
|
64
|
+
new({ particle: :alien, category: :identity, type: :string }) #special particel that old alien object
|
65
|
+
|
66
|
+
new({ particle: :email, category: :identity, type: :string })
|
@@ -115,7 +115,14 @@ new({ particle: :web, category: :utility, type: :string })
|
|
115
115
|
# new({ particle: :metrics, type: :hash })
|
116
116
|
# do not change the line below initialise is a special method
|
117
117
|
new({ initialize: :unit, value: {} })
|
118
|
-
|
118
|
+
new({ particle: :unit, store: false, type: :string, category: :utility }) do |params|
|
119
|
+
params.each do |k, v|
|
120
|
+
@unit[k] = v
|
121
|
+
# now we refresh the particle
|
122
|
+
send(k, send(k))
|
123
|
+
end
|
124
|
+
@unit
|
125
|
+
end
|
119
126
|
new({ particle: :login, category: :utility, type: :string }) do |params|
|
120
127
|
set_current_user(id) if params
|
121
128
|
end
|
@@ -124,7 +131,7 @@ new({ particle: :hyperedit, category: :utility, type: :string })
|
|
124
131
|
new({ particle: :terminal, category: :utility, type: :string })
|
125
132
|
new({ particle: :read, category: :utility, type: :string })
|
126
133
|
new({ particle: :browse, category: :utility, type: :string })
|
127
|
-
new({ particle: :copies, category: :utility, type: :string})
|
134
|
+
new({ particle: :copies, category: :utility, type: :string })
|
128
135
|
new({ particle: :temporary, category: :utility, type: :int })
|
129
136
|
new({ particle: :atomes, category: :utility, type: :string })
|
130
137
|
|
@@ -147,24 +147,42 @@ def atome_genesis
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def init_database # this method is call from JS (atome/communication)
|
150
|
+
# we init the db file eDen
|
151
|
+
A.message({ action: :init_db, data: { database: :eDen } }) do |db_state|
|
152
|
+
puts db_state
|
153
|
+
end
|
150
154
|
|
151
155
|
particles = Universe.particle_list
|
152
156
|
categories = Universe.categories
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
157
|
+
categories.each do |category|
|
158
|
+
A.message({ action: :crate_db_table, data: { table: category } }) do |db_state|
|
159
|
+
puts db_state
|
160
|
+
end
|
161
|
+
end
|
162
|
+
particles_length=particles.length
|
163
|
+
particles.each_with_index do |(particle, infos), index|
|
164
|
+
type = infos[:type]
|
165
|
+
table = infos[:category]
|
166
|
+
@i=1
|
167
|
+
A.message({ action: :create_db_column, data: { table: table, column: particle, type: type } }) do |db_state|
|
168
|
+
@i+=1
|
169
|
+
if @i==particles_length
|
170
|
+
user_login
|
171
|
+
end
|
172
|
+
puts db_state
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
159
177
|
end
|
160
178
|
|
161
179
|
def user_login
|
162
|
-
user = Universe.current_user
|
163
|
-
|
164
|
-
message({ action: :
|
165
|
-
puts "
|
180
|
+
# user = Universe.current_user
|
181
|
+
password = Black_matter.password
|
182
|
+
message({ action: :authentication, data: { email: 'jeezs@atome.one' } }) do |email|
|
183
|
+
puts "email received : #{email}"
|
166
184
|
end
|
167
|
-
message({ action: :
|
168
|
-
puts "
|
185
|
+
message({ action: :authorization, data: { password: password } }) do |pass|
|
186
|
+
puts "password recieved : #{pass}"
|
169
187
|
end
|
170
188
|
end
|
data/lib/atome/version.rb
CHANGED
@@ -51,11 +51,3 @@ new({ method: :sort, renderer: :html, type: :hash }) do |params|
|
|
51
51
|
html.refresh_table(params)
|
52
52
|
end
|
53
53
|
|
54
|
-
new({ particle: :unit, store: false }) do |params|
|
55
|
-
params.each do |k, v|
|
56
|
-
@unit[k] = v
|
57
|
-
# now we refresh the particle
|
58
|
-
send(k, send(k))
|
59
|
-
end
|
60
|
-
@unit
|
61
|
-
end
|
@@ -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,39 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
|
12
|
-
|
13
|
-
A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
A.message({ action: :query, data: { table: :identity } }) do |data_received|
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
|
38
|
-
|
39
|
-
end
|
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
|
6
|
+
#
|
7
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
|
8
|
+
# puts "1 my first insert #{data_received_from_server}"
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
|
12
|
+
#
|
13
|
+
# A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
|
14
|
+
# puts "2 another insert : #{data_received_from_server}"
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# A.message({ action: :query, data: { table: :identity } }) do |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}"
|
27
|
+
# end
|
28
|
+
#
|
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}"
|
31
|
+
# end
|
32
|
+
#
|
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}"
|
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,301 +15,12 @@ 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, message_id)
|
25
|
-
{ return: `#{cmd}`, message_id: message_id }
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.pass(cmd, option, ws, value, user, pass, message_id)
|
29
|
-
{ return: 'password received', message_id: message_id }
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.login(cmd, option, ws, value, user, pass, message_id)
|
33
|
-
{ return: 'login received', message_id: message_id }
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.init_db(cmd, option, ws, value, user, pass, message_id)
|
37
|
-
# Database.
|
38
|
-
{ return: 'database initialised', message_id: message_id }
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.query(cmd, option, ws, value, user, pass, message_id)
|
42
|
-
identity_table = db_access[cmd['table'].to_sym]
|
43
|
-
result = identity_table.send(:all).send(:select)
|
44
|
-
{ action: :query, data: cmd['table'], return: "==> #{result}", message_id: message_id }
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.insert(params, option, ws, value, user, pass, message_id)
|
48
|
-
table = params['table'].to_sym
|
49
|
-
particle = params['particle'].to_sym
|
50
|
-
data = params['data']
|
51
|
-
if db_access.table_exists?(table)
|
52
|
-
schema = db_access.schema(table)
|
53
|
-
if schema.any? { |col_def| col_def.first == particle }
|
54
|
-
identity_table = db_access[table.to_sym]
|
55
|
-
identity_table.insert(particle => data)
|
56
|
-
{ action: :insert, return: "column : #{particle}, in table : #{table}, updated with : #{data}", message_id: message_id }
|
57
|
-
else
|
58
|
-
{ action: :insert, return: "column not found: #{particle.class}", message_id: message_id }
|
59
|
-
end
|
60
|
-
else
|
61
|
-
{ action: :insert, return: "table not found: #{table.class}", message_id: message_id }
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.file(source, operation, ws, value, user, pass, message_id)
|
67
|
-
file_content = File.send(operation, source, value).to_s
|
68
|
-
file_content = file_content.gsub("'", "\"")
|
69
|
-
{ return: "=> operation: #{operation}, source: #{source} , content : #{file_content}", message_id: message_id }
|
70
|
-
end
|
71
|
-
|
72
|
-
# return_message = EDen.safe_send(action_requested, data,option, current_user, user_pass)
|
73
|
-
|
74
|
-
def self.safe_send(method_name, *args)
|
75
|
-
method_sym = method_name.to_sym
|
76
|
-
eden_methods = EDen.singleton_methods(false) - Object.singleton_methods
|
77
|
-
if eden_methods.include?(method_sym)
|
78
|
-
send(method_sym, *args)
|
79
|
-
else
|
80
|
-
{ return: "forbidden action: #{method_name}" }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
18
|
+
require './eDen'
|
19
|
+
require './database'
|
20
|
+
require './extensions'
|
84
21
|
|
85
22
|
Faye::WebSocket.load_adapter('puma')
|
86
23
|
|
87
|
-
class String
|
88
|
-
def is_json?
|
89
|
-
begin
|
90
|
-
!JSON.parse(self).nil?
|
91
|
-
rescue
|
92
|
-
false
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
class Database
|
98
|
-
|
99
|
-
def self.table_exists?(table_name)
|
100
|
-
# code below must be removed but not fpr now
|
101
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
102
|
-
if eden.table_exists?(table_name)
|
103
|
-
puts "La table #{table_name} existe dans la base de données."
|
104
|
-
else
|
105
|
-
puts "La table suivante : #{table_name} n'existe pas dans la base de données."
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
# def self.create_table(table_name)
|
111
|
-
def self.connect_database
|
112
|
-
if File.exist?("eden.sqlite3")
|
113
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
114
|
-
# now we test if the table exist
|
115
|
-
table_exists?(:table_name)
|
116
|
-
else
|
117
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
118
|
-
eden.create_table :atome do
|
119
|
-
primary_key :atome_id
|
120
|
-
String :creator
|
121
|
-
end
|
122
|
-
|
123
|
-
eden.create_table :communication do
|
124
|
-
primary_key :communication_id
|
125
|
-
String :connection
|
126
|
-
JSON :data
|
127
|
-
JSON :controller
|
128
|
-
end
|
129
|
-
|
130
|
-
###################
|
131
|
-
|
132
|
-
Sequel.extension :migration
|
133
|
-
|
134
|
-
Sequel.migration do
|
135
|
-
change do
|
136
|
-
add_column :communication, :jesaispas, String
|
137
|
-
end
|
138
|
-
end.apply(eden, :up)
|
139
|
-
|
140
|
-
###################
|
141
|
-
|
142
|
-
eden.create_table :effect do
|
143
|
-
primary_key :effect_id
|
144
|
-
Int :smooth
|
145
|
-
Int :blur
|
146
|
-
end
|
147
|
-
|
148
|
-
eden.create_table :event do
|
149
|
-
primary_key :event_id
|
150
|
-
JSON :touch
|
151
|
-
Boolean :play
|
152
|
-
Boolean :pause
|
153
|
-
Int :time
|
154
|
-
Boolean :on
|
155
|
-
Boolean :fullscreen
|
156
|
-
Boolean :mute
|
157
|
-
Boolean :drag
|
158
|
-
Boolean :drop
|
159
|
-
Boolean :over
|
160
|
-
String :targets
|
161
|
-
Boolean :start
|
162
|
-
Boolean :stop
|
163
|
-
Time :begin
|
164
|
-
Time :end
|
165
|
-
Int :duration
|
166
|
-
Int :mass
|
167
|
-
Int :damping
|
168
|
-
Int :stiffness
|
169
|
-
Int :velocity
|
170
|
-
Boolean :repeat
|
171
|
-
Boolean :ease
|
172
|
-
Boolean :keyboard
|
173
|
-
Boolean :resize
|
174
|
-
Boolean :overflow
|
175
|
-
end
|
176
|
-
|
177
|
-
eden.create_table :geometry do
|
178
|
-
primary_key :geometry_id
|
179
|
-
Int :width
|
180
|
-
Int :height
|
181
|
-
Int :size
|
182
|
-
end
|
183
|
-
|
184
|
-
eden.create_table :hierarchy do
|
185
|
-
primary_key :hierarchy_id
|
186
|
-
String :attach
|
187
|
-
String :attached
|
188
|
-
String :apply
|
189
|
-
String :affect
|
190
|
-
String :detached
|
191
|
-
String :collect
|
192
|
-
end
|
193
|
-
|
194
|
-
eden.create_table :identity do
|
195
|
-
primary_key :identity_id
|
196
|
-
String :real
|
197
|
-
String :type
|
198
|
-
Int :id
|
199
|
-
String :name
|
200
|
-
String :firstname
|
201
|
-
String :email
|
202
|
-
String :nickname
|
203
|
-
Boolean :active
|
204
|
-
String :markup
|
205
|
-
String :bundle
|
206
|
-
String :data
|
207
|
-
String :category
|
208
|
-
String :selection
|
209
|
-
Boolean :selected
|
210
|
-
String :format
|
211
|
-
String :alien
|
212
|
-
end
|
213
|
-
|
214
|
-
eden.create_table :material do
|
215
|
-
primary_key :material_id
|
216
|
-
String :component
|
217
|
-
Boolean :edit
|
218
|
-
String :style
|
219
|
-
Boolean :hide
|
220
|
-
Boolean :remove
|
221
|
-
JSON :classes
|
222
|
-
Boolean :remove_classes
|
223
|
-
Int :opacity
|
224
|
-
String :definition
|
225
|
-
Int :gradient
|
226
|
-
Int :border
|
227
|
-
end
|
228
|
-
|
229
|
-
eden.create_table :property do
|
230
|
-
primary_key :property_id
|
231
|
-
String :red
|
232
|
-
String :green
|
233
|
-
String :blue
|
234
|
-
String :alpha
|
235
|
-
String :diffusion
|
236
|
-
Boolean :clean
|
237
|
-
String :insert
|
238
|
-
Boolean :remove
|
239
|
-
Int :sort
|
240
|
-
end
|
241
|
-
|
242
|
-
eden.create_table :security do
|
243
|
-
primary_key :security_id
|
244
|
-
String :password
|
245
|
-
end
|
246
|
-
|
247
|
-
eden.create_table :spatial do
|
248
|
-
primary_key :spatial_id
|
249
|
-
Int :left
|
250
|
-
Int :right
|
251
|
-
Int :top
|
252
|
-
Int :bottom
|
253
|
-
Int :rotate
|
254
|
-
String :direction
|
255
|
-
String :center
|
256
|
-
Int :depth
|
257
|
-
Int :position
|
258
|
-
String :organise
|
259
|
-
String :spacing
|
260
|
-
Boolean :display
|
261
|
-
String :layout
|
262
|
-
end
|
263
|
-
|
264
|
-
eden.create_table :time do
|
265
|
-
primary_key :time_id
|
266
|
-
JSON :markers
|
267
|
-
end
|
268
|
-
|
269
|
-
eden.create_table :utility do
|
270
|
-
primary_key :utility_id
|
271
|
-
String :renderers
|
272
|
-
String :code
|
273
|
-
Boolean :run
|
274
|
-
Boolean :delete
|
275
|
-
Boolean :clear
|
276
|
-
String :path
|
277
|
-
String :schedule
|
278
|
-
String :read
|
279
|
-
String :cursor
|
280
|
-
String :preset
|
281
|
-
JSON :relations
|
282
|
-
JSON :tag
|
283
|
-
String :web
|
284
|
-
JSON :unit
|
285
|
-
String :initialize
|
286
|
-
String :login
|
287
|
-
String :hypertext
|
288
|
-
String :hyperedit
|
289
|
-
String :terminal
|
290
|
-
String :browse
|
291
|
-
String :copies
|
292
|
-
Int :temporary
|
293
|
-
String :atomes
|
294
|
-
String :match
|
295
|
-
Boolean :invert
|
296
|
-
String :option
|
297
|
-
String :duplicate
|
298
|
-
String :copy
|
299
|
-
String :paste
|
300
|
-
String :backup
|
301
|
-
String :import
|
302
|
-
String :compute
|
303
|
-
String :get
|
304
|
-
end
|
305
|
-
|
306
|
-
end
|
307
|
-
eden
|
308
|
-
end
|
309
|
-
|
310
|
-
end
|
311
|
-
|
312
24
|
class App < Roda
|
313
25
|
index_content = File.read("../src/index_server.html")
|
314
26
|
opts[:root] = '../src'
|
@@ -317,7 +29,7 @@ class App < Roda
|
|
317
29
|
r.root do
|
318
30
|
if Faye::WebSocket.websocket?(r.env)
|
319
31
|
ws = Faye::WebSocket.new(r.env)
|
320
|
-
ws.on :open do |
|
32
|
+
ws.on :open do |_event|
|
321
33
|
ws.send({ return: 'server ready' }.to_json)
|
322
34
|
end
|
323
35
|
ws.on(:message) do |event|
|
@@ -325,15 +37,10 @@ class App < Roda
|
|
325
37
|
full_data = JSON.parse(json_string)
|
326
38
|
data = full_data['data']
|
327
39
|
action_requested = full_data['action']
|
328
|
-
value = full_data['value']
|
329
|
-
option = full_data['option']
|
330
|
-
current_user = full_data['user']
|
331
40
|
message_id = full_data['message_id']
|
332
|
-
|
333
|
-
return_message = EDen.safe_send(action_requested, data, option, ws, value, current_user, user_pass, message_id)
|
41
|
+
return_message = EDen.safe_send(action_requested, data, message_id)
|
334
42
|
ws.send(return_message.to_json)
|
335
43
|
end
|
336
|
-
|
337
44
|
ws.on(:close) do |event|
|
338
45
|
puts "server closed with status #{event.code}"
|
339
46
|
end
|
@@ -343,4 +50,4 @@ class App < Roda
|
|
343
50
|
end
|
344
51
|
end
|
345
52
|
|
346
|
-
end
|
53
|
+
end
|
@@ -26,43 +26,43 @@ class String
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
class Database
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
29
|
+
# class Database
|
30
|
+
# def self.connect_database
|
31
|
+
# if File.exist?("eden.sqlite3")
|
32
|
+
# eden = Sequel.connect("sqlite://eden.sqlite3")
|
33
|
+
# else
|
34
|
+
# eden = Sequel.connect("sqlite://eden.sqlite3")
|
35
|
+
# eden.create_table :atome do
|
36
|
+
# primary_key :atome_id
|
37
|
+
# String :aui
|
38
|
+
# String :id
|
39
|
+
# String :type
|
40
|
+
# String :name
|
41
|
+
# String :content
|
42
|
+
# String :position
|
43
|
+
# String :dimension
|
44
|
+
# String :color
|
45
|
+
# String :right
|
46
|
+
# String :effect
|
47
|
+
# String :shadow
|
48
|
+
# String :border
|
49
|
+
# String :fill
|
50
|
+
# Float :x
|
51
|
+
# Float :xx
|
52
|
+
# Float :y
|
53
|
+
# Float :yy
|
54
|
+
# Float :z
|
55
|
+
# Float :zz
|
56
|
+
# Float :width
|
57
|
+
# Float :height
|
58
|
+
# Float :depth
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# end
|
62
|
+
# eden
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# end
|
66
66
|
|
67
67
|
class App < Roda
|
68
68
|
# comment below when test will be done
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# database handling for eDen Db
|
4
|
+
class Database
|
5
|
+
class << self
|
6
|
+
Sequel.extension :migration
|
7
|
+
|
8
|
+
def db_access
|
9
|
+
Sequel.connect("sqlite://eden.sqlite3")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_table(table_name)
|
13
|
+
eden = Sequel.connect("sqlite://eden.sqlite3")
|
14
|
+
unless eden.table_exists?(table_name)
|
15
|
+
eden.create_table table_name.to_sym do
|
16
|
+
primary_key "#{table_name}_id".to_sym
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_column(table, column_name, type)
|
22
|
+
eden = Sequel.connect("sqlite://eden.sqlite3")
|
23
|
+
if eden.table_exists?(table)
|
24
|
+
unless eden.schema(table).any? { |column| column.first == column_name }
|
25
|
+
Sequel.migration do
|
26
|
+
change do
|
27
|
+
add_column table, column_name, type
|
28
|
+
end
|
29
|
+
end.apply(eden, :up)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# server utils to handle eDen Db
|
4
|
+
|
5
|
+
class EDen
|
6
|
+
class << self
|
7
|
+
def db_access
|
8
|
+
Database.db_access
|
9
|
+
end
|
10
|
+
|
11
|
+
def terminal(data, message_id)
|
12
|
+
{ data: { message: `#{data}` }, message_id: message_id }
|
13
|
+
end
|
14
|
+
|
15
|
+
def authorization(data, message_id)
|
16
|
+
db = db_access
|
17
|
+
security_items = db[:security]
|
18
|
+
user_password = data["password"]
|
19
|
+
user_exists = security_items.where(password: user_password).first
|
20
|
+
|
21
|
+
if !user_exists
|
22
|
+
{ return: 'Password not found', message_id: message_id }
|
23
|
+
# Ask to the user if he wants to subscribe
|
24
|
+
# Send the basic template
|
25
|
+
else
|
26
|
+
{ return: 'Password found, connected', message_id: message_id }
|
27
|
+
# Send the user account template
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def authentication(data, message_id)
|
32
|
+
# { data: { message: 'login received' }, message_id: message_id }
|
33
|
+
db = db_access
|
34
|
+
identity_items = db[:identity]
|
35
|
+
user_email = data["email"]
|
36
|
+
mail_exists = identity_items.where(email: user_email).first
|
37
|
+
|
38
|
+
if !mail_exists
|
39
|
+
{ return: 'Email not found', message_id: message_id }
|
40
|
+
# { return: user_email, message_id: message_id }
|
41
|
+
# Ask to the user if he wants to subscribe
|
42
|
+
# Send the basic template
|
43
|
+
else
|
44
|
+
{ return: 'Email found, looking for pass', message_id: message_id }
|
45
|
+
# Verify password
|
46
|
+
# If password isn't ok, send error
|
47
|
+
# If the password is ok, send the user account template
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def init_db(_data, message_id)
|
52
|
+
unless File.exist?("eden.sqlite3")
|
53
|
+
Sequel.connect("sqlite://eden.sqlite3")
|
54
|
+
end
|
55
|
+
{ data: { message: 'database initialised' }, message_id: message_id }
|
56
|
+
end
|
57
|
+
|
58
|
+
def crate_db_table(data, message_id)
|
59
|
+
table = data['table']
|
60
|
+
Database.create_table(table)
|
61
|
+
{ data: { message: "table #{table} added" }, message_id: message_id }
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_db_column(data, message_id)
|
65
|
+
table = data['table']
|
66
|
+
column = data['column']
|
67
|
+
type = data['type']
|
68
|
+
Database.create_column(table, column, type)
|
69
|
+
{ data: { message: "column #{column} with type : #{type} added" }, message_id: message_id }
|
70
|
+
end
|
71
|
+
|
72
|
+
def query(data, message_id)
|
73
|
+
identity_table = db_access[data['table'].to_sym]
|
74
|
+
result = identity_table.send(:all).send(:select)
|
75
|
+
{ data: { table: data['table'], infos: result }, message_id: message_id }
|
76
|
+
end
|
77
|
+
|
78
|
+
def insert(data, message_id)
|
79
|
+
table = data['table'].to_sym
|
80
|
+
particle = data['particle'].to_sym
|
81
|
+
data = data['data']
|
82
|
+
if db_access.table_exists?(table)
|
83
|
+
schema = db_access.schema(table)
|
84
|
+
if schema.any? { |col_def| col_def.first == particle }
|
85
|
+
identity_table = db_access[table.to_sym]
|
86
|
+
identity_table.insert(particle => data)
|
87
|
+
{ data: { message: "column : #{particle}, in table : #{table}, updated with : #{data}" }, message_id: message_id }
|
88
|
+
else
|
89
|
+
{ data: { message: "column not found: #{particle.class}" }, message_id: message_id }
|
90
|
+
end
|
91
|
+
else
|
92
|
+
{ data: { message: "table not found: #{table.class}" }, message_id: message_id }
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def file(data, message_id)
|
98
|
+
|
99
|
+
file_content = File.send(data['operation'], data['source'], data['value']).to_s
|
100
|
+
file_content = file_content.gsub("'", "\"")
|
101
|
+
|
102
|
+
file_content = file_content.gsub('#', '\x23')
|
103
|
+
{ data: "=> operation: #{data['operation']}, source: #{data['source']}, content: #{file_content}", message_id: message_id }
|
104
|
+
end
|
105
|
+
|
106
|
+
def safe_send(method_name, data, message_id)
|
107
|
+
method_sym = method_name.to_sym
|
108
|
+
send(method_sym, data, message_id)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -67,9 +67,10 @@ const communication = {
|
|
67
67
|
|
68
68
|
// now new can exec user code : loadApplicationJs in index.html
|
69
69
|
loadApplicationJs();
|
70
|
-
rubyVMCallback("A.user_login");
|
70
|
+
// rubyVMCallback("A.user_login");
|
71
71
|
};
|
72
72
|
this.websocket.onmessage = function (event) {
|
73
|
+
// console.log(event.data)
|
73
74
|
rubyVMCallback("A.server_receiver(" + event.data + ")");
|
74
75
|
};
|
75
76
|
|
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.4
|
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
|