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.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +34 -0
  3. data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +2833 -0
  4. data/app/controllers/wirispluginengine/application_controller.rb +75 -0
  5. data/app/helpers/wirispluginengine/application_helper.rb +4 -0
  6. data/config/routes.rb +4 -0
  7. data/configuration.ini.dist +104 -0
  8. data/lib/com/wiris/common/WInteger.rb +57 -0
  9. data/lib/com/wiris/plugin/api/Cas.rb +8 -0
  10. data/lib/com/wiris/plugin/api/CleanCache.rb +8 -0
  11. data/lib/com/wiris/plugin/api/Configuration.rb +8 -0
  12. data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +96 -0
  13. data/lib/com/wiris/plugin/api/Editor.rb +8 -0
  14. data/lib/com/wiris/plugin/api/Filter.rb +8 -0
  15. data/lib/com/wiris/plugin/api/ImageFormatController.rb +8 -0
  16. data/lib/com/wiris/plugin/api/ParamsProvider.rb +8 -0
  17. data/lib/com/wiris/plugin/api/PluginBuilder.rb +79 -0
  18. data/lib/com/wiris/plugin/api/Render.rb +8 -0
  19. data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +8 -0
  20. data/lib/com/wiris/plugin/api/Test.rb +8 -0
  21. data/lib/com/wiris/plugin/api/TextService.rb +8 -0
  22. data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +8 -0
  23. data/lib/com/wiris/plugin/impl/CasImpl.rb +146 -0
  24. data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +111 -0
  25. data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +176 -0
  26. data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +38 -0
  27. data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +29 -0
  28. data/lib/com/wiris/plugin/impl/EditorImpl.rb +86 -0
  29. data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +34 -0
  30. data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +59 -0
  31. data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +144 -0
  32. data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +56 -0
  33. data/lib/com/wiris/plugin/impl/HttpImpl.rb +53 -0
  34. data/lib/com/wiris/plugin/impl/HttpListener.rb +8 -0
  35. data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +73 -0
  36. data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +34 -0
  37. data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +253 -0
  38. data/lib/com/wiris/plugin/impl/RenderImpl.rb +280 -0
  39. data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +52 -0
  40. data/lib/com/wiris/plugin/impl/TestImpl.rb +166 -0
  41. data/lib/com/wiris/plugin/impl/TextFilter.rb +211 -0
  42. data/lib/com/wiris/plugin/impl/TextFilterTags.rb +55 -0
  43. data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +118 -0
  44. data/lib/com/wiris/plugin/storage/StorageAndCache.rb +8 -0
  45. data/lib/com/wiris/util/json/JSon.rb +536 -0
  46. data/lib/com/wiris/util/json/JSonIntegerFormat.rb +21 -0
  47. data/lib/com/wiris/util/json/StringParser.rb +61 -0
  48. data/lib/com/wiris/util/sys/HttpConnection.rb +18 -0
  49. data/lib/com/wiris/util/sys/HttpConnectionListener.rb +8 -0
  50. data/lib/com/wiris/util/sys/IniFile.rb +143 -0
  51. data/lib/com/wiris/util/sys/Store.rb +109 -0
  52. data/lib/com/wiris/util/xml/SerializableImpl.rb +20 -0
  53. data/lib/com/wiris/util/xml/WCharacterBase.rb +634 -0
  54. data/lib/com/wiris/util/xml/WEntities.rb +14 -0
  55. data/lib/com/wiris/util/xml/WXmlUtils.rb +515 -0
  56. data/lib/com/wiris/util/xml/XmlSerializer.rb +485 -0
  57. data/lib/com/wiris/util/xml/XmlWriter.rb +279 -0
  58. data/lib/loader.rb +12 -0
  59. data/lib/src-generic/Array.rb +23 -0
  60. data/lib/src-generic/ArrayInt.rb +32 -0
  61. data/lib/src-generic/Base64.rb +15 -0
  62. data/lib/src-generic/BaseCode.rb +94 -0
  63. data/lib/src-generic/Bytes.rb +50 -0
  64. data/lib/src-generic/BytesInput.rb +38 -0
  65. data/lib/src-generic/EReg.rb +56 -0
  66. data/lib/src-generic/File.rb +36 -0
  67. data/lib/src-generic/FileLock.rb +27 -0
  68. data/lib/src-generic/FileSystem.rb +37 -0
  69. data/lib/src-generic/Hash.rb +43 -0
  70. data/lib/src-generic/Http.rb +107 -0
  71. data/lib/src-generic/HttpRequest.rb +25 -0
  72. data/lib/src-generic/HttpResponse.rb +71 -0
  73. data/lib/src-generic/Iterator.rb +20 -0
  74. data/lib/src-generic/Math.rb +15 -0
  75. data/lib/src-generic/Md5.rb +8 -0
  76. data/lib/src-generic/Md5Tools.rb +12 -0
  77. data/lib/src-generic/PropertiesTools.rb +33 -0
  78. data/lib/src-generic/Reflect.rb +17 -0
  79. data/lib/src-generic/RubyConfigurationUpdater.rb +45 -0
  80. data/lib/src-generic/Serializer.rb +85 -0
  81. data/lib/src-generic/Std.rb +74 -0
  82. data/lib/src-generic/Storage.rb +153 -0
  83. data/lib/src-generic/StringBuf.rb +41 -0
  84. data/lib/src-generic/StringTools.rb +46 -0
  85. data/lib/src-generic/Timer.rb +7 -0
  86. data/lib/src-generic/Type.rb +19 -0
  87. data/lib/src-generic/TypeTools.rb +32 -0
  88. data/lib/src-generic/Unserializer.rb +73 -0
  89. data/lib/src-generic/Utf8.rb +27 -0
  90. data/lib/src-generic/Xml.rb +199 -0
  91. data/lib/src-generic/extended/Integer.rb +5 -0
  92. data/lib/src-generic/extended/Math.rb +7 -0
  93. data/lib/src-generic/extended/Properties.rb +12 -0
  94. data/lib/src-generic/extended/String.rb +39 -0
  95. data/lib/src-generic/settings/PlatformSettings.rb +19 -0
  96. data/lib/wirispluginengine.rb +5 -0
  97. data/lib/wirispluginengine/engine.rb +5 -0
  98. data/lib/wirispluginengine/integration/cleancache.rb +8 -0
  99. data/lib/wirispluginengine/integration/configurationjs.rb +16 -0
  100. data/lib/wirispluginengine/integration/configurationjson.rb +7 -0
  101. data/lib/wirispluginengine/integration/createimage.rb +8 -0
  102. data/lib/wirispluginengine/integration/getmathml.rb +18 -0
  103. data/lib/wirispluginengine/integration/resource.rb +8 -0
  104. data/lib/wirispluginengine/integration/service.rb +6 -0
  105. data/lib/wirispluginengine/integration/showimage.rb +21 -0
  106. data/lib/wirispluginengine/integration/test.rb +6 -0
  107. data/lib/wirispluginengine/version.rb +3 -0
  108. data/resources/VERSION +1 -0
  109. data/resources/default-configuration.ini +45 -0
  110. data/resources/tech.txt +1 -0
  111. data/resources/wirisplugin.css +43 -0
  112. 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,15 @@
1
+ module Wiris
2
+ class Math
3
+ def self.round(f)
4
+ return f.round
5
+ end
6
+
7
+ def self.random()
8
+ return Random::rand()
9
+ end
10
+
11
+ def self.floor(f)
12
+ return f.floor
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ require 'digest/md5'
2
+ module Wiris
3
+ class Md5
4
+ def self.encode(content)
5
+ return Digest::MD5.hexdigest(content)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module Wiris
2
+ class Md5Tools
3
+ def self.encodeString(content)
4
+ return Md5::encode(content)
5
+ end
6
+
7
+ def self.encodeBytes(bytes)
8
+ bytes = bytes.getData()
9
+ return Md5::encode(bytes.pack('c*'))
10
+ end
11
+ end
12
+ 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