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,50 @@
1
+ # This class encapsulates the data structure of an array of bytes. Depending
2
+ # on the platform the actual byte array ca be a String, an array of integers,
3
+ # or the best choice everywhere.
4
+ # It is encouraged to use this structure specially for input/output
5
+ # operations where large byte arrays have to be handled.
6
+
7
+ module Wiris
8
+ class Bytes
9
+ def bytes=(bytes)
10
+ @bytes=bytes
11
+ end
12
+ def bytes
13
+ @bytes
14
+ end
15
+
16
+ def initialize(bytes)
17
+ @bytes = bytes
18
+ end
19
+
20
+
21
+ def self.ofString(s)
22
+ return Bytes.new(s.force_encoding("ISO-8859-1").bytes.to_a)
23
+ end
24
+
25
+ def self.ofData(data)
26
+ return Bytes.new(data)
27
+ end
28
+
29
+ def getData()
30
+ return @bytes
31
+ end
32
+
33
+ def get(index)
34
+ return @bytes[index]
35
+ end
36
+
37
+ def self.alloc(int)
38
+ return []
39
+ end
40
+
41
+ def length()
42
+ return @bytes.length
43
+ end
44
+
45
+ def toString()
46
+ return @bytes.pack('c*').force_encoding("ISO-8859-1")
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,38 @@
1
+ module Wiris
2
+ class BytesInput
3
+ def binary()
4
+ @binary
5
+ end
6
+
7
+ def initialize(bs)
8
+ @binary = bs.getData().to_enum
9
+ end
10
+
11
+ def readBytes(b, pos, len)
12
+ return @binary[pos..len]
13
+ end
14
+
15
+ def readByte()
16
+ byt = @binary.next
17
+ if byt.nil?
18
+ return false
19
+ else
20
+ return byt
21
+ end
22
+ end
23
+ def readInt32()
24
+ c1 = readByte
25
+ c2 = readByte
26
+ c3 = readByte
27
+ c4 = readByte
28
+ return (c1 << 8 | c2) << 16 | (c3 << 8 | c4)
29
+ end
30
+
31
+ def readBytes(bytes, pos, len)
32
+ for i in 0..len-1
33
+ bytes[i]=readByte
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,56 @@
1
+ module Wiris
2
+ class EReg
3
+ def regex=(regex)
4
+ @regex=regex
5
+ end
6
+ def regex
7
+ @regex
8
+ end
9
+
10
+ def match=(match)
11
+ @match=match
12
+ end
13
+ def match
14
+ @match
15
+ end
16
+
17
+ def initialize(pattern, opts=nil)
18
+ flags = 0
19
+ if not opts.nil?
20
+ for i in 0..opts.length
21
+ case opts[i]
22
+ when "i"
23
+ flags += Regexp::IGNORECASE
24
+ when "s"
25
+ flags += Regexp::MULTILINE
26
+ when "m"
27
+ flags += Regexp::MULTILINE
28
+ end
29
+ end
30
+ end
31
+ @regex = Regexp.new(pattern, flags)
32
+ end
33
+
34
+ def match(str)
35
+ @match = @regex.match(str)
36
+ if (@match.nil?)
37
+ return false
38
+ else
39
+ return true
40
+ end
41
+ end
42
+
43
+ def replace(str, by)
44
+ @match = @regex.match(str)
45
+ if @match.nil?
46
+ return str
47
+ else
48
+ return str.gsub(@match.regexp, by)
49
+ end
50
+ end
51
+
52
+ def matched(n)
53
+ return @match[n]
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,36 @@
1
+ module Wiris
2
+ class File < ::File
3
+ def self.saveContent(file, str)
4
+ out = write(file, true);
5
+ out.write(str)
6
+ out.close
7
+ end
8
+
9
+ def self.saveBytes(file, b)
10
+ File.open(file, 'wb' ) do |output|
11
+ b.bytes.each do | byte |
12
+ output.print byte.chr
13
+ end
14
+ end
15
+ end
16
+
17
+ def self.getBytes(file)
18
+ return Bytes.new(IO.binread(file).unpack("C*"))
19
+ end
20
+
21
+ def self.getContent(file)
22
+ return File.read(file)
23
+ end
24
+
25
+ def self.write(str, binary)
26
+ if (!binary)
27
+ raise Exception,"Only binary files allowed!"
28
+ end
29
+ return File.open(str, 'wb')
30
+ end
31
+
32
+ def self.saveContent(file, str)
33
+ IO.binwrite(file, str.force_encoding("UTF-8"))
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ module Wiris
2
+ class FileLock
3
+
4
+ TIMEOUT= 5000
5
+ WAIT = 100
6
+
7
+ def file
8
+ @file
9
+ end
10
+
11
+ def initialize(file)
12
+ @file = file
13
+ end
14
+
15
+ def self.getLock(filename, remaining = 0)
16
+ # Time in milliseconds
17
+ starwait = (Time.now.to_f*1000).to_i
18
+ file = File.new(filename + ".lock", "w+")
19
+ return FileLock.new(file)
20
+ end
21
+
22
+ def release()
23
+ file.close
24
+ File.delete(file)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ module Wiris
2
+ class FileSystem
3
+ def self.readDirectory(folder)
4
+ return Dir::entries(folder) - ['.'] - ['..']
5
+ end
6
+
7
+ def self.createDirectory(folder)
8
+ Dir.mkdir(folder)
9
+ end
10
+
11
+ def self.exists(folder)
12
+ File.exists?(folder)
13
+ end
14
+
15
+ def self.fullPath(path)
16
+ if !exists(path)
17
+ return nil
18
+ end
19
+ return File::realpath(path)
20
+ end
21
+ def self.rename (path, newpath)
22
+ File::rename(path, newpath)
23
+ raise Exception, "Unable to rename \""+path+"\" to \""+newpath+"\"."
24
+ end
25
+ def self.isDirectory(path)
26
+ return File.directory?(path)
27
+ end
28
+ def self.deleteDirectory(folder)
29
+ if (Dir.entries(folder) == ['.', '..'])
30
+ return Dir.delete(folder)
31
+ end
32
+ end
33
+ def self.deleteFile(file)
34
+ return File.delete(file)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ module Wiris
2
+ class Hash < Hash
3
+ def javaHashtable=(javaHashtable)
4
+ @javaHashtable=javaHashtable
5
+ end
6
+
7
+ def javaHashtable
8
+ @javaHashtable
9
+ end
10
+ # private:javaHashtable=
11
+
12
+ def initialize(hs=nil)
13
+ if (hs.nil?)
14
+ super()
15
+ end
16
+ @javaHashtable = hs
17
+ end
18
+
19
+ def get(key)
20
+ return self[key]
21
+ end
22
+ def set(key, value)
23
+ self[key] = value
24
+ end
25
+ alias originalkeysmethod keys
26
+
27
+ def keys()
28
+ return Iterator.new(self.originalkeysmethod().to_enum)
29
+ end
30
+
31
+ def getJavaHashtable()
32
+ return @javaHashtable
33
+ end
34
+
35
+ def exists(key)
36
+ self.has_key?(key)
37
+ end
38
+
39
+ def remove(key)
40
+ self.delete(key)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,107 @@
1
+ require "net/http"
2
+ require "uri"
3
+
4
+ module Wiris
5
+ class Http
6
+ #
7
+ # The server myURL.
8
+ #
9
+ #
10
+ @url
11
+ @postData
12
+ @headers
13
+ @params
14
+ @connection
15
+ @@PROXY=nil
16
+
17
+
18
+ def self.PROXY=(proxy)
19
+ @@PROXY = proxy
20
+ end
21
+
22
+ def self.PROXY
23
+ @@PROXY
24
+ end
25
+
26
+ def initialize(url)
27
+ @url = url
28
+ @headers = Hash.new()
29
+ @params = Hash.new()
30
+ end
31
+
32
+ def request(post)
33
+ # try{
34
+ serializedParams = formEncode(@params)
35
+ uri = URI.parse(@url)
36
+
37
+ unless @@PROXY.nil?
38
+ @connection = @@PROXY.start(uri.host, uri.port)
39
+ else
40
+ @connection = Net::HTTP.new(uri.host, uri.port)
41
+ end
42
+
43
+ if !post
44
+ uri.query = serializedParams
45
+ request = Net::HTTP::Get.new(uri.request_uri)
46
+ else
47
+ request = Net::HTTP::Post.new(uri.request_uri)
48
+ # request.set_form_data(@params)
49
+ request.body = @postData != nil ? @postData : serializedParams
50
+
51
+ end
52
+
53
+ keys = @headers.keys()
54
+
55
+ while keys.hasNext()
56
+ key = keys.next()
57
+ request.add_field(key, @headers.get(key))
58
+ end
59
+
60
+ response = @connection.request(request)
61
+
62
+ onData(response.body)
63
+ end
64
+
65
+ def formEncode(params)
66
+ i = params.keys()
67
+ sb = StringBuf.new()
68
+ first = true;
69
+ while (i.hasNext())
70
+ if(!first)
71
+ sb.add("&");
72
+ else
73
+ first = false;
74
+ end
75
+ key = i.next();
76
+ sb.add(StringTools.urlEncode(key));
77
+ sb.add("=");
78
+ sb.add(StringTools.urlEncode(params.get(key)));
79
+ end
80
+ return sb.toString();
81
+ end
82
+
83
+
84
+ def setHeader(header, value)
85
+ @headers.set(header,value)
86
+ end
87
+
88
+ #
89
+ # Sets a parameter to be sent in the request. Multiple parameters can be set
90
+ # by making multiple setParameter calls.
91
+ #
92
+ def setParameter(param, value)
93
+ @params.set(param,value);
94
+ end
95
+
96
+ def setPostData(data)
97
+ @postData = data;
98
+ end
99
+
100
+ def onData(data)
101
+ end
102
+
103
+ def onError(msg)
104
+ end
105
+
106
+ end
107
+ end
@@ -0,0 +1,25 @@
1
+ module Wiris
2
+ class HttpRequest
3
+ attr_accessor :params
4
+
5
+ def initialize(params)
6
+ @params = params;
7
+ end
8
+
9
+ def getParameter(key)
10
+ if (self.params[key].nil?)
11
+ return nil
12
+ end
13
+ return self.params[key]
14
+ end
15
+
16
+ def getContextURL()
17
+ return nil
18
+ end
19
+
20
+ def getParameterNames
21
+ return params.keys
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,71 @@
1
+ module Wiris
2
+ class HttpResponse
3
+ def actionController
4
+ @actionController
5
+ end
6
+
7
+ def actionController=(actionController)
8
+ @actionController=actionController
9
+ end
10
+ def res
11
+ @res
12
+ end
13
+ def headers=(headers)
14
+ @headers = headers
15
+ end
16
+
17
+ def headers
18
+ @headers
19
+ end
20
+
21
+ def out=(out)
22
+ @out=out
23
+ end
24
+
25
+ def out
26
+ @out
27
+ end
28
+
29
+ def writing
30
+ @writing
31
+ end
32
+
33
+ def writing=(writing)
34
+ @writing=writing
35
+ end
36
+
37
+ def writeString(s)
38
+ @writing = true
39
+ @out = @out + s
40
+ end
41
+
42
+ def writeBinary(data)
43
+ writeString(data.toString())
44
+ end
45
+
46
+ def initialize(actionController)
47
+ @closed=false
48
+ @actionController = actionController
49
+ @writing=false
50
+ @out = ""
51
+ @res = actionController.response
52
+ @headers = Hash.new()
53
+ end
54
+
55
+ def setHeader(name, value)
56
+ @headers.set(name, value)
57
+ @res.headers[name] = value
58
+ end
59
+
60
+ def getHeader(name)
61
+ return @headers.get(name)
62
+ end
63
+
64
+ def close
65
+ @res.close
66
+ if @writing
67
+ actionController.render :text => @out
68
+ end
69
+ end
70
+ end
71
+ end