wirispluginengine 3.62.0.1322
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 +7 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +2833 -0
- data/app/controllers/wirispluginengine/application_controller.rb +75 -0
- data/app/helpers/wirispluginengine/application_helper.rb +4 -0
- data/config/routes.rb +4 -0
- data/configuration.ini.dist +104 -0
- data/lib/com/wiris/common/WInteger.rb +57 -0
- data/lib/com/wiris/plugin/api/Cas.rb +8 -0
- data/lib/com/wiris/plugin/api/CleanCache.rb +8 -0
- data/lib/com/wiris/plugin/api/Configuration.rb +8 -0
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +96 -0
- data/lib/com/wiris/plugin/api/Editor.rb +8 -0
- data/lib/com/wiris/plugin/api/Filter.rb +8 -0
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +8 -0
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +8 -0
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +79 -0
- data/lib/com/wiris/plugin/api/Render.rb +8 -0
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +8 -0
- data/lib/com/wiris/plugin/api/Test.rb +8 -0
- data/lib/com/wiris/plugin/api/TextService.rb +8 -0
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +8 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +146 -0
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +111 -0
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +176 -0
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +38 -0
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +29 -0
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +86 -0
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +34 -0
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +59 -0
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +144 -0
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +56 -0
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +53 -0
- data/lib/com/wiris/plugin/impl/HttpListener.rb +8 -0
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +73 -0
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +34 -0
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +253 -0
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +280 -0
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +52 -0
- data/lib/com/wiris/plugin/impl/TestImpl.rb +166 -0
- data/lib/com/wiris/plugin/impl/TextFilter.rb +211 -0
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +55 -0
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +118 -0
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +8 -0
- data/lib/com/wiris/util/json/JSon.rb +536 -0
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +21 -0
- data/lib/com/wiris/util/json/StringParser.rb +61 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +18 -0
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +8 -0
- data/lib/com/wiris/util/sys/IniFile.rb +143 -0
- data/lib/com/wiris/util/sys/Store.rb +109 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +20 -0
- data/lib/com/wiris/util/xml/WCharacterBase.rb +634 -0
- data/lib/com/wiris/util/xml/WEntities.rb +14 -0
- data/lib/com/wiris/util/xml/WXmlUtils.rb +515 -0
- data/lib/com/wiris/util/xml/XmlSerializer.rb +485 -0
- data/lib/com/wiris/util/xml/XmlWriter.rb +279 -0
- data/lib/loader.rb +12 -0
- data/lib/src-generic/Array.rb +23 -0
- data/lib/src-generic/ArrayInt.rb +32 -0
- data/lib/src-generic/Base64.rb +15 -0
- data/lib/src-generic/BaseCode.rb +94 -0
- data/lib/src-generic/Bytes.rb +50 -0
- data/lib/src-generic/BytesInput.rb +38 -0
- data/lib/src-generic/EReg.rb +56 -0
- data/lib/src-generic/File.rb +36 -0
- data/lib/src-generic/FileLock.rb +27 -0
- data/lib/src-generic/FileSystem.rb +37 -0
- data/lib/src-generic/Hash.rb +43 -0
- data/lib/src-generic/Http.rb +107 -0
- data/lib/src-generic/HttpRequest.rb +25 -0
- data/lib/src-generic/HttpResponse.rb +71 -0
- data/lib/src-generic/Iterator.rb +20 -0
- data/lib/src-generic/Math.rb +15 -0
- data/lib/src-generic/Md5.rb +8 -0
- data/lib/src-generic/Md5Tools.rb +12 -0
- data/lib/src-generic/PropertiesTools.rb +33 -0
- data/lib/src-generic/Reflect.rb +17 -0
- data/lib/src-generic/RubyConfigurationUpdater.rb +45 -0
- data/lib/src-generic/Serializer.rb +85 -0
- data/lib/src-generic/Std.rb +74 -0
- data/lib/src-generic/Storage.rb +153 -0
- data/lib/src-generic/StringBuf.rb +41 -0
- data/lib/src-generic/StringTools.rb +46 -0
- data/lib/src-generic/Timer.rb +7 -0
- data/lib/src-generic/Type.rb +19 -0
- data/lib/src-generic/TypeTools.rb +32 -0
- data/lib/src-generic/Unserializer.rb +73 -0
- data/lib/src-generic/Utf8.rb +27 -0
- data/lib/src-generic/Xml.rb +199 -0
- data/lib/src-generic/extended/Integer.rb +5 -0
- data/lib/src-generic/extended/Math.rb +7 -0
- data/lib/src-generic/extended/Properties.rb +12 -0
- data/lib/src-generic/extended/String.rb +39 -0
- data/lib/src-generic/settings/PlatformSettings.rb +19 -0
- data/lib/wirispluginengine.rb +5 -0
- data/lib/wirispluginengine/engine.rb +5 -0
- data/lib/wirispluginengine/integration/cleancache.rb +8 -0
- data/lib/wirispluginengine/integration/configurationjs.rb +16 -0
- data/lib/wirispluginengine/integration/configurationjson.rb +7 -0
- data/lib/wirispluginengine/integration/createimage.rb +8 -0
- data/lib/wirispluginengine/integration/getmathml.rb +18 -0
- data/lib/wirispluginengine/integration/resource.rb +8 -0
- data/lib/wirispluginengine/integration/service.rb +6 -0
- data/lib/wirispluginengine/integration/showimage.rb +21 -0
- data/lib/wirispluginengine/integration/test.rb +6 -0
- data/lib/wirispluginengine/version.rb +3 -0
- data/resources/VERSION +1 -0
- data/resources/default-configuration.ini +45 -0
- data/resources/tech.txt +1 -0
- data/resources/wirisplugin.css +43 -0
- metadata +182 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Wiris
|
2
|
+
class Iterator < Enumerator
|
3
|
+
def initialize(enum)
|
4
|
+
super(enum)
|
5
|
+
end
|
6
|
+
alias enumeratornext next
|
7
|
+
def next
|
8
|
+
self.enumeratornext
|
9
|
+
end
|
10
|
+
|
11
|
+
def hasNext()
|
12
|
+
begin
|
13
|
+
self.peek
|
14
|
+
return true
|
15
|
+
rescue StopIteration
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Wiris
|
2
|
+
class PropertiesTools
|
3
|
+
def self.getProperty(prop, key, dflt=nil)
|
4
|
+
if (!prop[key].nil?)
|
5
|
+
return prop[key]
|
6
|
+
else
|
7
|
+
return dflt
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.setProperty(prop, key, value)
|
12
|
+
prop[key] = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.newProperties()
|
16
|
+
return Hash.new()
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.toProperties(hashString)
|
20
|
+
p = Hash.new()
|
21
|
+
keys = hashString.keys()
|
22
|
+
while keys.hasNext()
|
23
|
+
key = keys.next()
|
24
|
+
p[key] = hashString.get(key)
|
25
|
+
end
|
26
|
+
return p
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.fromProperties(prop)
|
30
|
+
return prop
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Wiris
|
2
|
+
class Reflect
|
3
|
+
def self.field(obj, field)
|
4
|
+
begin
|
5
|
+
cls = Module::const_get(obj.name)
|
6
|
+
return cls.class_variable_get(("@@" + field).to_sym)
|
7
|
+
end
|
8
|
+
rescue NameError
|
9
|
+
return nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.setField(obj, field, value)
|
13
|
+
cls = Module::const_get(obj.name)
|
14
|
+
cls.class_variable_set(("@@" + field), value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
class RubyConfigurationUpdater
|
3
|
+
include Wiris
|
4
|
+
def request
|
5
|
+
@request
|
6
|
+
end
|
7
|
+
def request=(request)
|
8
|
+
@request=request
|
9
|
+
end
|
10
|
+
|
11
|
+
def init(obj)
|
12
|
+
end
|
13
|
+
|
14
|
+
def updateConfiguration(configuration)
|
15
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CACHE_FOLDER, nil)
|
16
|
+
if v.nil?
|
17
|
+
configuration[ConfigurationKeys::CACHE_FOLDER] = File.dirname(__FILE__) + "/../../cache"
|
18
|
+
end
|
19
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::FORMULA_FOLDER, nil)
|
20
|
+
if v.nil?
|
21
|
+
configuration[ConfigurationKeys::FORMULA_FOLDER] = File.dirname(__FILE__) + "/../../formulas"
|
22
|
+
end
|
23
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::SHOWIMAGE_PATH, nil)
|
24
|
+
if v.nil?
|
25
|
+
configuration[ConfigurationKeys::SHOWIMAGE_PATH] = "wirispluginengine/integration/showimage?formula="
|
26
|
+
end
|
27
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CLEAN_CACHE_PATH, nil)
|
28
|
+
if v.nil?
|
29
|
+
configuration[ConfigurationKeys::CLEAN_CACHE_PATH] = "cleancache"
|
30
|
+
end
|
31
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::RESOURCE_PATH, nil)
|
32
|
+
if v.nil?
|
33
|
+
configuration[ConfigurationKeys::RESOURCE_PATH] = "resource"
|
34
|
+
end
|
35
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CONFIGURATION_PATH, nil)
|
36
|
+
if v.nil?
|
37
|
+
configuration[ConfigurationKeys::CONFIGURATION_PATH] = File.dirname(__FILE__) + "/../../"
|
38
|
+
end
|
39
|
+
v = PropertiesTools::getProperty(configuration, ConfigurationKeys::REFERER, nil)
|
40
|
+
if v.nil?
|
41
|
+
configuration[ConfigurationKeys::REFERER] = request.original_url
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Wiris
|
2
|
+
class Serializer
|
3
|
+
def buf
|
4
|
+
@buf
|
5
|
+
end
|
6
|
+
def initialize()
|
7
|
+
@buf = StringBuf.new()
|
8
|
+
end
|
9
|
+
|
10
|
+
##
|
11
|
+
# a : array
|
12
|
+
# b : hash
|
13
|
+
# c : class
|
14
|
+
# d : Float
|
15
|
+
# e : reserved (float exp)
|
16
|
+
# f : false
|
17
|
+
# g : object end
|
18
|
+
# h : array/list/hash end
|
19
|
+
# i : Int
|
20
|
+
# j : enum (by index)
|
21
|
+
# k : NaN
|
22
|
+
# l : list
|
23
|
+
# m : -Inf
|
24
|
+
# n : null
|
25
|
+
# o : object
|
26
|
+
# p : +Inf
|
27
|
+
# q : inthash
|
28
|
+
# r : reference
|
29
|
+
# s : bytes (base64)
|
30
|
+
# t : true
|
31
|
+
# u : array nulls
|
32
|
+
# v : date
|
33
|
+
# w : enum
|
34
|
+
# x : exceptiona
|
35
|
+
# y : urlencoded string
|
36
|
+
# z : zero
|
37
|
+
# C : custom
|
38
|
+
|
39
|
+
def serialize(o)
|
40
|
+
c = Type.getClass(o)
|
41
|
+
if (c == Type.resolveClass(Array).to_s)
|
42
|
+
buf.add("a")
|
43
|
+
v = o
|
44
|
+
ucount = 0
|
45
|
+
l = v.length()
|
46
|
+
for i in 0..l
|
47
|
+
if (v._(i) == nil)
|
48
|
+
ucount += 1
|
49
|
+
else
|
50
|
+
if (ucount > 0)
|
51
|
+
if (ucount == 1)
|
52
|
+
buf.add("n")
|
53
|
+
else
|
54
|
+
buf.add("u")
|
55
|
+
buf.add("" + ucount.to_s)
|
56
|
+
end
|
57
|
+
ucount = 0
|
58
|
+
end
|
59
|
+
serialize(v._(i))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
buf.add("h")
|
63
|
+
elsif (o.is_a? Integer)
|
64
|
+
if (o == 0)
|
65
|
+
buf.add("z")
|
66
|
+
else
|
67
|
+
buf.add("i")
|
68
|
+
buf.add("" + o.to_s)
|
69
|
+
end
|
70
|
+
else
|
71
|
+
raise Exception, "Object class not implemented: "+ c
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def toString()
|
76
|
+
return buf.toString()
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.run(o)
|
80
|
+
s = Serializer.new()
|
81
|
+
s.serialize(o)
|
82
|
+
return s.toString()
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Wiris
|
2
|
+
class Std
|
3
|
+
def self.trace(s)
|
4
|
+
puts s
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.is(o, cls)
|
8
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.substr(text, x0, length=-1)
|
12
|
+
if length==-1
|
13
|
+
text[x0..text.length]
|
14
|
+
else
|
15
|
+
text[x0,length] # Strings starts at 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def split(text, delimitator)
|
20
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.parseInt(number)
|
24
|
+
return Integer(number)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parseFloat(number)
|
28
|
+
return Float(number)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @deprecated
|
32
|
+
def parseDouble(number)
|
33
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.fromCharCode(c)
|
37
|
+
return c.chr(Encoding::UTF_8)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.charCodeAt(str, i)
|
41
|
+
return str[i].ord
|
42
|
+
end
|
43
|
+
|
44
|
+
def copyInto(array, cs)
|
45
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
46
|
+
end
|
47
|
+
|
48
|
+
def exit(n)
|
49
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
50
|
+
end
|
51
|
+
|
52
|
+
def random(x)
|
53
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.split(str, delimitator)
|
57
|
+
arr = Array.new()
|
58
|
+
str.split(delimitator).each {|x| arr.push(x)}
|
59
|
+
return arr
|
60
|
+
end
|
61
|
+
|
62
|
+
@@random = nil
|
63
|
+
def self.random=(random)
|
64
|
+
@@random=random
|
65
|
+
end
|
66
|
+
def self.random(x)
|
67
|
+
if @@random == nil
|
68
|
+
@@random = Random.new()
|
69
|
+
end
|
70
|
+
return @@random.rand(x)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
module Wiris
|
2
|
+
class Storage
|
3
|
+
TYPE_FILE = 0;
|
4
|
+
TYPE_RESOURCE = 1;
|
5
|
+
TYPE_URL =2;
|
6
|
+
@cls = nil
|
7
|
+
@@resourcesDir = nil
|
8
|
+
|
9
|
+
def type=(type)
|
10
|
+
@type = type
|
11
|
+
end
|
12
|
+
def type
|
13
|
+
@type
|
14
|
+
end
|
15
|
+
def file=(file)
|
16
|
+
@file = file
|
17
|
+
end
|
18
|
+
def file
|
19
|
+
@file
|
20
|
+
end
|
21
|
+
def resourceName
|
22
|
+
@resourceName
|
23
|
+
end
|
24
|
+
def resourceName=(resourceName)
|
25
|
+
@resourceName = resourceName
|
26
|
+
end
|
27
|
+
|
28
|
+
def location
|
29
|
+
@location
|
30
|
+
end
|
31
|
+
|
32
|
+
def location=(location)
|
33
|
+
@location = location
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.resourcesDir=(resourcesDir)
|
37
|
+
@@resourcesDir = resourcesDir
|
38
|
+
end
|
39
|
+
def self.resourcesDir
|
40
|
+
@@resourcesDir
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(location=nil)
|
44
|
+
if location != nil
|
45
|
+
@location = location
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.newStorage(name)
|
50
|
+
s = Storage.new(name)
|
51
|
+
s.type = TYPE_FILE
|
52
|
+
return s
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.newStorageWithParent(parent, name)
|
56
|
+
s = Storage.new(parent.location)
|
57
|
+
s.type = parent.type;
|
58
|
+
if (parent.type == TYPE_FILE)
|
59
|
+
# @file = File.new(File.join(parent.location, name), "w+")
|
60
|
+
# @file.close
|
61
|
+
s.location = File.join(parent.location, name)
|
62
|
+
elsif (parent.type == TYPE_RESOURCE)
|
63
|
+
s.resourceName = parent.resourceName;
|
64
|
+
if (s.resourceName.length() > 0 && !s.resourceName.endsWith("/"))
|
65
|
+
s.resourceName += "/"
|
66
|
+
end
|
67
|
+
s.resourceName += name
|
68
|
+
elsif (parent.type == TYPE_URL)
|
69
|
+
url = Url.new(Url.new(parent.url),name).toExternalForm()
|
70
|
+
end
|
71
|
+
return s
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.newResourceStorage(name)
|
75
|
+
s = Storage.new(File.join(getResourcesDir,name))
|
76
|
+
s.type = TYPE_RESOURCE
|
77
|
+
return s;
|
78
|
+
end
|
79
|
+
|
80
|
+
def read()
|
81
|
+
return File.read(location)
|
82
|
+
end
|
83
|
+
|
84
|
+
def readBinary()
|
85
|
+
s = File.binread(location)
|
86
|
+
return s.bytes.to_a
|
87
|
+
end
|
88
|
+
|
89
|
+
def write(str)
|
90
|
+
writeOrAppend(str, false)
|
91
|
+
end
|
92
|
+
|
93
|
+
def writeBinary(bs)
|
94
|
+
File.open(location, 'wb' ) do |output|
|
95
|
+
output.write bs.pack("C*")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def writeOrAppend(str, append)
|
100
|
+
if (@type == TYPE_RESOURCE)
|
101
|
+
notImplemented()
|
102
|
+
end
|
103
|
+
if (@type == TYPE_URL)
|
104
|
+
notImplemented()
|
105
|
+
end
|
106
|
+
@file = File.new(@location, "w")
|
107
|
+
@file.write(str)
|
108
|
+
@file.close
|
109
|
+
end
|
110
|
+
|
111
|
+
def exists()
|
112
|
+
return File.exists?(location)
|
113
|
+
end
|
114
|
+
|
115
|
+
def mkdirs()
|
116
|
+
if (@type == TYPE_RESOURCE)
|
117
|
+
notImplemented()
|
118
|
+
end
|
119
|
+
if (@type == TYPE_URL)
|
120
|
+
notImplemented()
|
121
|
+
end
|
122
|
+
Dir.mkdir(@location)
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.getResourcesDir()
|
127
|
+
if @@resourcesDir.nil?
|
128
|
+
setResourcesDir()
|
129
|
+
end
|
130
|
+
return @@resourcesDir
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.setResourcesDir()
|
134
|
+
@@resourcesDir = File.dirname(__FILE__)
|
135
|
+
end
|
136
|
+
|
137
|
+
def notImplemented()
|
138
|
+
raise Exception,'Error: Operation not available on this Storage'
|
139
|
+
end
|
140
|
+
|
141
|
+
def toString()
|
142
|
+
if type == TYPE_FILE
|
143
|
+
return location.to_s
|
144
|
+
elsif type == TYPE_RESOURCE
|
145
|
+
return resourceName
|
146
|
+
elsif type == TYPE_URL
|
147
|
+
return url
|
148
|
+
else
|
149
|
+
return nil
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|