|
@@ -22,6 +22,10 @@ require 'xml/smart'
|
|
|
require 'riddl/server'
|
|
|
require 'fileutils'
|
|
|
require 'typhoeus'
|
|
|
+
|
|
|
+# process:
|
|
|
+# https://centurio.work/customers/evva/flow/?monitor=https://centurio.work/flow-test/engine/729/
|
|
|
+
|
|
|
class Get < Riddl::Implementation
|
|
|
def response
|
|
|
if @r[0] == 'test'
|
|
@@ -34,15 +38,16 @@ end
|
|
|
|
|
|
class Put < Riddl::Implementation
|
|
|
def response
|
|
|
- puts "AAAAAAAAAAAAAAAAAAA"
|
|
|
Dir.mkdir(File.join('data',@r.last)) rescue nil
|
|
|
File.write(File.join('data',@r.last,'style.url'),@p[0].value)
|
|
|
+
|
|
|
File.write(File.join('data',@r.last,'document.xml'),@p[1].value)
|
|
|
+
|
|
|
File.write(File.join('data',@r.last,'frames.json'),JSON.dump(JSON.parse('{"data":[]}')))
|
|
|
+
|
|
|
+
|
|
|
+ File.write(File.join('data',@r.last,'info.json'),JSON.dump(JSON.parse('{"x_amount":' + @p[2].value + ', "y_amount":' + @p[3].value + ', "lang":"' + @p[4].value + '", "langs":["' + @p[4].value + '"]}')))
|
|
|
|
|
|
- if @p[2]&.name == 'info'
|
|
|
- File.write(File.join('data',@r.last,'info.json'),@p[2].value)
|
|
|
- end
|
|
|
|
|
|
File.write(File.join('data',@r.last,'callback'),@h['CPEE_CALLBACK'])
|
|
|
|
|
@@ -61,19 +66,33 @@ class NewFrame < Riddl::Implementation
|
|
|
file = File.read(path)
|
|
|
data_hash = JSON::parse(file)
|
|
|
|
|
|
- #puts "Before " + JSON.dump(data_hash);
|
|
|
-
|
|
|
data_hash["data"].each do | c |
|
|
|
-
|
|
|
if doOverlap(c['lx'], c['ly'], c['rx'], c['ry'], @p[0].value.to_i, @p[1].value.to_i, (@p[0].value.to_i + @p[2].value.to_i - 1), (@p[1].value.to_i + @p[3].value.to_i - 1))
|
|
|
data_hash["data"].delete(c)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- hash = {lx: @p[0].value.to_i, ly: @p[1].value.to_i, rx: (@p[0].value.to_i + @p[2].value.to_i - 1), ry: (@p[1].value.to_i + @p[3].value.to_i - 1), url: @p[4].value};
|
|
|
-
|
|
|
+# example
|
|
|
+# myObj = {
|
|
|
+# "lx":3,
|
|
|
+# "ly":3,
|
|
|
+# "rx":3,
|
|
|
+# "ry":3,
|
|
|
+# "url": {
|
|
|
+# "de-at":"xyz.at",
|
|
|
+# "en-us":"xyz.com"
|
|
|
+# }
|
|
|
+# }
|
|
|
+ urls = JSON::parse(@p[4].value);
|
|
|
|
|
|
+ hash = {lx: @p[0].value.to_i, ly: @p[1].value.to_i, rx: (@p[0].value.to_i + @p[2].value.to_i - 1), ry: (@p[1].value.to_i + @p[3].value.to_i - 1), url: urls};
|
|
|
+ data_hash["data"].push(hash)
|
|
|
File.write(path, JSON.dump(data_hash))
|
|
|
+
|
|
|
+ #only send active url to client
|
|
|
+ infofile = File.join('data',@r.last,'info.json')
|
|
|
+ infojson = JSON::parse(File.read(infofile))
|
|
|
+ hash["url"] = urls[infojson["lang"]]
|
|
|
|
|
|
@a[0].send(JSON.dump(hash))
|
|
|
nil
|
|
@@ -116,6 +135,27 @@ class Delete < Riddl::Implementation
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+class GetFrames < Riddl::Implementation #{{{
|
|
|
+ def response
|
|
|
+ fname = File.join('data',@r[-2],'frames.json')
|
|
|
+ if File.exists? fname
|
|
|
+
|
|
|
+ infofile = File.join('data',@r[-2],'info.json')
|
|
|
+ infojson = JSON::parse(File.read(infofile))
|
|
|
+
|
|
|
+ #remove not used languages
|
|
|
+ file = JSON::parse(File.read(fname))
|
|
|
+ file["data"].each do |child|
|
|
|
+ child["url"] = child["url"][infojson["lang"]]
|
|
|
+ end
|
|
|
+
|
|
|
+ Riddl::Parameter::Complex.new('value','application/json',JSON.dump(file))
|
|
|
+ else
|
|
|
+ @status = 404
|
|
|
+ end
|
|
|
+ end
|
|
|
+end #}}}
|
|
|
+
|
|
|
class GetInfo < Riddl::Implementation #{{{
|
|
|
def response
|
|
|
fname = File.join('data',@r[-2],'info.json')
|
|
@@ -142,6 +182,32 @@ class GetLangs < Riddl::Implementation #{{{
|
|
|
end
|
|
|
end
|
|
|
end #}}}
|
|
|
+
|
|
|
+class SetLang < Riddl::Implementation #{{{
|
|
|
+ def response
|
|
|
+ fname = File.join('data',@r[-2],'info.json')
|
|
|
+ if File.exists? fname
|
|
|
+ infojson = JSON::parse(File.read(fname))
|
|
|
+ infojson["lang"] = @p[0].value
|
|
|
+
|
|
|
+
|
|
|
+ #add to langs
|
|
|
+ if !infojson["langs"].include?(@p[0].value)
|
|
|
+ infojson["langs"].push(@p[0].value)
|
|
|
+ end
|
|
|
+
|
|
|
+ File.write(fname, JSON.dump(infojson))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @a[0].send('reset')
|
|
|
+ nil
|
|
|
+ else
|
|
|
+ @status = 404
|
|
|
+ end
|
|
|
+ end
|
|
|
+end #}}}
|
|
|
+
|
|
|
class GetStyle < Riddl::Implementation #{{{
|
|
|
def response
|
|
|
fname = File.join('data',@r[-2],'style.url')
|
|
@@ -257,6 +323,7 @@ server = Riddl::Server.new(File.join(__dir__,'/frames.xml'), :host => 'localhost
|
|
|
end
|
|
|
on resource 'languages' do
|
|
|
run GetLangs if get
|
|
|
+ run SetLang, opts[:signals][idx] if post 'lang'
|
|
|
end
|
|
|
on resource 'style.url' do
|
|
|
run GetStyle if get
|
|
@@ -264,6 +331,10 @@ server = Riddl::Server.new(File.join(__dir__,'/frames.xml'), :host => 'localhost
|
|
|
on resource 'info.json' do
|
|
|
run GetInfo if get
|
|
|
end
|
|
|
+ on resource 'frames.json' do
|
|
|
+ run GetFrames if get
|
|
|
+ end
|
|
|
+
|
|
|
on resource 'buttons' do
|
|
|
on resource '[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*' do
|
|
|
run GetButton if get
|