wirispluginengine 3.62.0.1322 → 7.14.0.1422

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 (149) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +34 -34
  3. data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
  4. data/app/controllers/wirispluginengine/application_controller.rb +84 -75
  5. data/app/helpers/wirispluginengine/application_helper.rb +4 -4
  6. data/config/routes.rb +4 -4
  7. data/lib/com/wiris/common/WInteger.rb +52 -51
  8. data/lib/com/wiris/plugin/api/Cas.rb +5 -5
  9. data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
  10. data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
  11. data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
  12. data/lib/com/wiris/plugin/api/Editor.rb +5 -5
  13. data/lib/com/wiris/plugin/api/Filter.rb +5 -5
  14. data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
  15. data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
  16. data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
  17. data/lib/com/wiris/plugin/api/Render.rb +5 -5
  18. data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
  19. data/lib/com/wiris/plugin/api/Test.rb +5 -5
  20. data/lib/com/wiris/plugin/api/TextService.rb +5 -5
  21. data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
  22. data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
  23. data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
  24. data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
  25. data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
  26. data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
  27. data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
  28. data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
  29. data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
  30. data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
  31. data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
  32. data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
  33. data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
  34. data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
  35. data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
  36. data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
  37. data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
  38. data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
  39. data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
  40. data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
  41. data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
  42. data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
  43. data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
  44. data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
  45. data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
  46. data/lib/com/wiris/util/json/JSon.rb +505 -493
  47. data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
  48. data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
  49. data/lib/com/wiris/util/json/StringParser.rb +57 -56
  50. data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
  51. data/lib/com/wiris/util/sys/Cache.rb +8 -0
  52. data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
  53. data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
  54. data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
  55. data/lib/com/wiris/util/sys/IniFile.rb +132 -131
  56. data/lib/com/wiris/util/sys/Lock.rb +8 -0
  57. data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
  58. data/lib/com/wiris/util/sys/Store.rb +126 -101
  59. data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
  60. data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
  61. data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
  62. data/lib/com/wiris/util/type/Arrays.rb +275 -0
  63. data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
  64. data/lib/com/wiris/util/type/Comparator.rb +8 -0
  65. data/lib/com/wiris/util/type/DataUtils.rb +24 -0
  66. data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
  67. data/lib/com/wiris/util/type/HashCache.rb +43 -0
  68. data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
  69. data/lib/com/wiris/util/type/Queue.rb +31 -0
  70. data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
  71. data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
  72. data/lib/com/wiris/util/type/SortedHash.rb +45 -0
  73. data/lib/com/wiris/util/type/Stack.rb +31 -0
  74. data/lib/com/wiris/util/type/StringUtils.rb +56 -0
  75. data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
  76. data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
  77. data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
  78. data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
  79. data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
  80. data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
  81. data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
  82. data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
  83. data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
  84. data/lib/com/wiris/util/xml/WEntities.rb +11 -9
  85. data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
  86. data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
  87. data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
  88. data/lib/loader.rb +15 -12
  89. data/lib/src-generic/Array.rb +22 -22
  90. data/lib/src-generic/ArrayInt.rb +31 -31
  91. data/lib/src-generic/Base64.rb +14 -14
  92. data/lib/src-generic/BaseCode.rb +93 -93
  93. data/lib/src-generic/Boolean.rb +27 -0
  94. data/lib/src-generic/Bytes.rb +50 -50
  95. data/lib/src-generic/BytesInput.rb +37 -37
  96. data/lib/src-generic/EReg.rb +55 -55
  97. data/lib/src-generic/File.rb +35 -35
  98. data/lib/src-generic/FileLock.rb +26 -26
  99. data/lib/src-generic/FileSystem.rb +37 -37
  100. data/lib/src-generic/Hash.rb +42 -42
  101. data/lib/src-generic/Http.rb +111 -107
  102. data/lib/src-generic/HttpRequest.rb +25 -25
  103. data/lib/src-generic/HttpResponse.rb +70 -70
  104. data/lib/src-generic/Iterator.rb +20 -19
  105. data/lib/src-generic/Math.rb +14 -14
  106. data/lib/src-generic/Md5.rb +8 -8
  107. data/lib/src-generic/Md5Tools.rb +11 -11
  108. data/lib/src-generic/PropertiesTools.rb +32 -32
  109. data/lib/src-generic/Reflect.rb +16 -16
  110. data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
  111. data/lib/src-generic/Serializer.rb +84 -84
  112. data/lib/src-generic/Std.rb +74 -74
  113. data/lib/src-generic/Storage.rb +152 -152
  114. data/lib/src-generic/StringBuf.rb +40 -40
  115. data/lib/src-generic/StringTools.rb +44 -46
  116. data/lib/src-generic/Timer.rb +6 -6
  117. data/lib/src-generic/Type.rb +18 -18
  118. data/lib/src-generic/TypeTools.rb +31 -31
  119. data/lib/src-generic/Unserializer.rb +72 -72
  120. data/lib/src-generic/Utf8.rb +26 -26
  121. data/lib/src-generic/Xml.rb +199 -198
  122. data/lib/src-generic/extended/Integer.rb +5 -5
  123. data/lib/src-generic/extended/Math.rb +6 -6
  124. data/lib/src-generic/extended/Properties.rb +11 -11
  125. data/lib/src-generic/extended/String.rb +38 -38
  126. data/lib/src-generic/settings/PlatformSettings.rb +18 -18
  127. data/lib/src-generic/system/HttpProxy.rb +23 -0
  128. data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
  129. data/lib/wirispluginengine.rb +5 -5
  130. data/lib/wirispluginengine/engine.rb +5 -5
  131. data/lib/wirispluginengine/integration/cleancache.rb +8 -8
  132. data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
  133. data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
  134. data/lib/wirispluginengine/integration/createimage.rb +7 -7
  135. data/lib/wirispluginengine/integration/getmathml.rb +18 -18
  136. data/lib/wirispluginengine/integration/resource.rb +8 -8
  137. data/lib/wirispluginengine/integration/service.rb +5 -5
  138. data/lib/wirispluginengine/integration/showimage.rb +28 -21
  139. data/lib/wirispluginengine/integration/test.rb +5 -5
  140. data/lib/wirispluginengine/integration/testfilter.rb +10 -0
  141. data/lib/wirispluginengine/version.rb +2 -2
  142. data/resources/VERSION +1 -1
  143. data/resources/WEB-INF/web.xml +25 -0
  144. data/resources/WIRISplugins.js +3809 -0
  145. data/resources/default-configuration.ini +47 -45
  146. data/resources/tech.txt +1 -1
  147. data/resources/wirisplugin.css +43 -42
  148. metadata +40 -4
  149. data/configuration.ini.dist +0 -104
@@ -1,52 +1,54 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ServiceResourceLoader.rb')
4
- class ServiceResourceLoaderImpl
5
- extend ServiceResourceLoaderInterface
3
+ require('com/wiris/plugin/api/ServiceResourceLoader.rb')
4
+ require('com/wiris/plugin/api/ServiceResourceLoader.rb')
5
+ class ServiceResourceLoaderImpl
6
+ extend ServiceResourceLoaderInterface
6
7
 
7
- include Wiris
8
+ include Wiris
8
9
 
9
- def initialize()
10
- super()
11
- end
12
- def getContent(resource)
13
- return Storage::newResourceStorage(resource)::read()
14
- end
15
- def getContentType(name)
16
- ext = Std::substr(name,name::lastIndexOf(".")+1)
17
- if (ext=="png")
18
- return "image/png"
19
- else
20
- if (ext=="gif")
21
- return "image/gif"
22
- else
23
- if (ext=="jpg")||(ext=="jpeg")
24
- return "image/jpeg"
25
- else
26
- if (ext=="html")||(ext=="htm")
27
- return "text/html"
10
+ def initialize()
11
+ super()
12
+ end
13
+ def getContent(resource)
14
+ return Storage::newResourceStorage(resource)::read()
15
+ end
16
+ def getContentType(name)
17
+ ext = Std::substr(name,name::lastIndexOf(".") + 1)
18
+ if (ext == "png")
19
+ return "image/png"
28
20
  else
29
- if (ext=="css")
30
- return "text/css"
31
- else
32
- if (ext=="js")
33
- return "application/javascript"
21
+ if (ext == "gif")
22
+ return "image/gif"
34
23
  else
35
- if (ext=="txt")
36
- return "text/plain"
37
- else
38
- if (ext=="ini")
39
- return "text/plain"
24
+ if (ext == "jpg") || (ext == "jpeg")
25
+ return "image/jpeg"
40
26
  else
41
- return "application/octet-stream"
27
+ if (ext == "html") || (ext == "htm")
28
+ return "text/html"
29
+ else
30
+ if (ext == "css")
31
+ return "text/css"
32
+ else
33
+ if (ext == "js")
34
+ return "application/javascript"
35
+ else
36
+ if (ext == "txt")
37
+ return "text/plain"
38
+ else
39
+ if (ext == "ini")
40
+ return "text/plain"
41
+ else
42
+ return "application/octet-stream"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
42
48
  end
43
- end
44
49
  end
45
- end
46
50
  end
47
- end
48
51
  end
49
- end
52
+
50
53
  end
51
- end
52
54
  end
@@ -1,166 +1,186 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
- require('com/wiris/plugin/impl/HttpImpl.rb')
5
- require('com/wiris/plugin/api/Test.rb')
6
- class TestImpl
7
- extend TestInterface
3
+ require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
+ require('com/wiris/plugin/impl/HttpImpl.rb')
5
+ require('com/wiris/plugin/api/Test.rb')
6
+ require('com/wiris/util/type/UrlUtils.rb')
7
+ require('com/wiris/util/json/JSon.rb')
8
+ require('com/wiris/plugin/api/Test.rb')
9
+ class TestImpl
10
+ extend TestInterface
8
11
 
9
- include Wiris
12
+ include Wiris
10
13
 
11
- attr_accessor :plugin
12
- def initialize(plugin)
13
- super()
14
- @plugin = plugin
15
- end
16
- def getTestPage()
17
- random = ""+(Math::random()*9999).to_s
18
- mml = ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><msqrt><mn>"+random)+"</mn></msqrt></mrow></math>"
19
- output = ""
20
- output+="<html><head>\r\n"
21
- output+="<title>WIRIS plugin test page</title><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /><style type=\"text/css\">/*<!--*/html {font-family: sans-serif;}h2 {margin-left: 1em;}h3 {margin-left: 2em;}p {margin-left: 3em;}p.concrete {margin-left: 4em;}.ok {font-weight: bold;color: #0c0;}.error {font-weight: bold;color: #f00;}/*-->*/</style><style type=\"text/css\">body{font-family: Arial;}span{font-weight: bold;}span.ok {color: #009900;}span.error {color: #dd0000;}table, th, td, tr {border: solid 1px #000000;border-collapse:collapse;padding: 5px;}th{background-color: #eeeeee;}img{border:none;}</style>\r\n"
22
- output+="<script src=\"../core/WIRISplugins.js?viewer=image\" ></script>\r\n"
23
- output+="</head><body><h1>WIRIS plugin test page</h1>\r\n"
24
- output+="<table><tr><th>Test</th><th>Report</th><th>Status</th></tr>\r\n"
25
- testName = "WIRIS plugin version"
26
- begin
27
- s = Storage::newResourceStorage("VERSION")::read()
28
- reportText = ("<b>"+s)+"</b>"
29
- solutionLink = ""
30
- condition = true
31
- end
32
- output+=createTableRow(testName,reportText,solutionLink,condition)
33
- testName = "Creating and storing data"
34
- solutionLink = ""
35
- param = PropertiesTools::newProperties()
36
- outp = PropertiesTools::newProperties()
37
- provider = @plugin::newGenericParamsProvider(param)
38
- imageUrl = plugin::newRender()::createImage(mml,provider,outp)
39
- reportText = ((("<a href=\""+imageUrl)+"\" />")+imageUrl)+"</a>"
40
- condition = true
41
- output+=createTableRow(testName,reportText,solutionLink,condition)
42
- testName = "Retrieving data"
43
- solutionLink = ""
44
- reportText = ("<img src=\""+imageUrl)+"\" />"
45
- output+=createTableRow(testName,reportText,solutionLink,condition)
46
- testName = "JavaScript MathML filter"
47
- solutionLink = ""
48
- reportText = mml
49
- output+=createTableRow(testName,reportText,solutionLink,condition)
50
- testName = "Host platform"
51
- solutionLink = ""
52
- platform = plugin::getConfiguration()::getProperty(ConfigurationKeys::HOST_PLATFORM,"failed")
53
- reportText = platform
54
- output+=createTableRow(testName,reportText,solutionLink,condition)
55
- testName = "Filter test"
56
- solutionLink = ""
57
- condition = true
58
- p = PropertiesTools::newProperties()
59
- PropertiesTools::setProperty(p,"savemode","safeXml")
60
- s2 = StringTools::replace(mml,"<",Std::fromCharCode(171))
61
- s2 = StringTools::replace(s2,">",Std::fromCharCode(187))
62
- s2 = StringTools::replace(s2,"\"",Std::fromCharCode(168))
63
- reportText = plugin::newTextService()::filter("square root: "+s2,p)
64
- output+=createTableRow(testName,reportText,solutionLink,condition)
65
- testName = "Connecting to www.wiris.net"
66
- solutionLink = ""
67
- condition = true
68
- begin
69
- h = HttpImpl.new("http://www.wiris.net",nil)
70
- h::request(true)
71
- end
72
- reportText = "Checking if WIRIS server is reachable"
73
- output+=createTableRow(testName,reportText,solutionLink,condition)
74
- if Type::resolveClass("com.wiris.editor.services.PublicServices")!=nil
75
- condition = true
76
- testName = "Testing integrated services"
77
- reportText = "WIRIS Services installed"
78
- solutionLink = ""
79
- output+=createTableRow(testName,reportText,solutionLink,condition)
80
- isLicensed = plugin::isEditorLicensed()
81
- condition = false
82
- testName = "WIRIS editor license"
83
- reportText = "Checking WIRIS editor valid license"
84
- output+=createTableRow(testName,reportText,solutionLink,isLicensed)
85
- else
86
- reportText = "WIRIS Services not installed"
87
- end
88
- debug = (plugin::getConfiguration()::getProperty(ConfigurationKeys::DEBUG,"false")=="true")
89
- if debug
90
- testName = "Font family"
91
- solutionLink = ""
92
- condition = true
93
- reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::FONT_FAMILY,"")
94
- output+=createTableRow(testName,reportText,solutionLink,condition)
95
- testName = "Configuration file"
96
- solutionLink = ""
97
- condition = true
98
- reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::CONFIGURATION_PATH,"")+"\\configuration.ini"
99
- output+=createTableRow(testName,reportText,solutionLink,condition)
100
- testName = "Cache path"
101
- solutionLink = ""
102
- condition = true
103
- reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::CACHE_FOLDER,"")
104
- output+=createTableRow(testName,reportText,solutionLink,condition)
105
- testName = "Formula path"
106
- solutionLink = ""
107
- condition = true
108
- reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::FORMULA_FOLDER,"")
109
- output+=createTableRow(testName,reportText,solutionLink,condition)
110
- testName = "Integration path"
111
- solutionLink = ""
112
- condition = true
113
- reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::INTEGRATION_PATH,"")
114
- output+=createTableRow(testName,reportText,solutionLink,condition)
115
- testName = "Context path"
116
- solutionLink = ""
117
- condition = true
118
- reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"")
119
- output+=createTableRow(testName,reportText,solutionLink,condition)
120
- testName = "default-configuration.ini load"
121
- solutionLink = ""
122
- defaultConfiguration = Storage::newResourceStorage("default-configuration.ini")::read()
123
- condition = (defaultConfiguration!=nil)&&(defaultConfiguration::length()>0)
124
- if condition
125
- reportText = "Length: "+defaultConfiguration::length().to_s
126
- else
127
- reportText = "Not found!"
14
+ attr_accessor :plugin
15
+ attr_accessor :conf
16
+ def initialize(plugin)
17
+ super()
18
+ self.plugin = plugin
128
19
  end
129
- output+=createTableRow(testName,reportText,solutionLink,condition)
130
- testName = "cas.png load"
131
- solutionLink = ""
132
- casPng = Storage::newResourceStorage("cas.png")::readBinary()
133
- casPngLength = 0
134
- if casPng!=nil
135
- casPngLength = Bytes::ofData(casPng)::length()
136
- condition = casPngLength>0
137
- else
138
- condition = false
20
+ def getTestPage()
21
+ random = "" + (Math::random()*9999).to_s
22
+ mml = ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><msqrt><mn>" + random) + "</mn></msqrt></mrow></math>"
23
+ self.conf = self.plugin::getConfiguration()
24
+ output = ""
25
+ output += "<html><head>\r\n"
26
+ output += "<title>MathType integration test page</title><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /><style type=\"text/css\">/*<!--*/html {font-family: sans-serif;}h2 {margin-left: 1em;}h3 {margin-left: 2em;}p {margin-left: 3em;}p.concrete {margin-left: 4em;}.ok {font-weight: bold;color: #0c0;}.error {font-weight: bold;color: #f00;}/*-->*/</style><style type=\"text/css\">body{font-family: Arial;}span{font-weight: bold;}span.ok {color: #009900;}span.error {color: #dd0000;}table, th, td, tr {border: solid 1px #000000;border-collapse:collapse;padding: 5px;}th{background-color: #eeeeee;}img{border:none;}</style>\r\n"
27
+ output += "<script src=\"../core/WIRISplugins.js?viewer=image\" ></script>\r\n"
28
+ output += "</head><body><h1>MathType integration test page</h1>\r\n"
29
+ output += "<table><tr><th>Test</th><th>Report</th><th>Status</th></tr>\r\n"
30
+ testName = "MathType integration version"
31
+ begin
32
+ s = Storage::newResourceStorage("VERSION")::read()
33
+ reportText = ("<b>" + s) + "</b>"
34
+ solutionLink = ""
35
+ condition = true
36
+ end
37
+ output += createTableRow(testName,reportText,solutionLink,condition)
38
+ testName = "Creating and storing data"
39
+ solutionLink = ""
40
+ param = PropertiesTools::newProperties()
41
+ outp = PropertiesTools::newProperties()
42
+ provider = @plugin::newGenericParamsProvider(param)
43
+ imageUrl = self.plugin::newRender()::createImage(mml,provider,outp)
44
+ reportText = ((("<a href=\"" + imageUrl) + "\" />") + imageUrl) + "</a>"
45
+ condition = true
46
+ output += createTableRow(testName,reportText,solutionLink,condition)
47
+ testName = "Retrieving data"
48
+ solutionLink = ""
49
+ if (self.conf::getProperty("wirispluginperformance","false") == "true")
50
+ self.plugin::newRender()::showImage(nil,mml,provider)
51
+ digest = self.plugin::newRender()::computeDigest(mml,provider::getRenderParameters(self.plugin::getConfiguration()))
52
+ imageUrlJson = self.plugin::newRender()::showImageJson(digest,"en")
53
+ imageJson = (JSon::decode(imageUrlJson))
54
+ result = (imageJson::get("result"))
55
+ content = (result::get("content"))
56
+ if (self.conf::getProperty("wirisimageformat","svg") == "svg")
57
+ reportText = (("<img src=\"" + "data:image/svg+xml;charset=utf8,") + UrlUtils::urlComponentEncode(content)) + "\" />"
58
+ else
59
+ reportText = (("<img src=\'" + "data:image/png;base64,") + content) + "\' />"
60
+ end
61
+ else
62
+ reportText = ("<img src=\'" + imageUrl) + "\' />"
63
+ end
64
+ output += createTableRow(testName,reportText,solutionLink,condition)
65
+ testName = "JavaScript MathML filter"
66
+ solutionLink = ""
67
+ reportText = mml
68
+ output += createTableRow(testName,reportText,solutionLink,condition)
69
+ testName = "Host platform"
70
+ solutionLink = ""
71
+ platform = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::HOST_PLATFORM,"failed")
72
+ reportText = platform
73
+ output += createTableRow(testName,reportText,solutionLink,condition)
74
+ testName = "Filter test"
75
+ solutionLink = ""
76
+ condition = true
77
+ p = PropertiesTools::newProperties()
78
+ PropertiesTools::setProperty(p,"savemode","safeXml")
79
+ s2 = StringTools::replace(mml,"<",Std::fromCharCode(171))
80
+ s2 = StringTools::replace(s2,">",Std::fromCharCode(187))
81
+ s2 = StringTools::replace(s2,"\"",Std::fromCharCode(168))
82
+ reportText = self.plugin::newTextService()::filter("square root: " + s2,p)
83
+ output += createTableRow(testName,reportText,solutionLink,condition)
84
+ testName = "Connecting to www.wiris.net"
85
+ solutionLink = ""
86
+ condition = true
87
+ begin
88
+ h = HttpImpl.new("http://www.wiris.net",nil)
89
+ h::request(true)
90
+ end
91
+ reportText = "Checking if server is reachable"
92
+ output += createTableRow(testName,reportText,solutionLink,condition)
93
+ if Type::resolveClass("com.wiris.editor.services.PublicServices") != nil
94
+ condition = true
95
+ testName = "Testing integrated services"
96
+ reportText = "WIRIS Services installed"
97
+ solutionLink = ""
98
+ output += createTableRow(testName,reportText,solutionLink,condition)
99
+ isLicensed = self.plugin::isEditorLicensed()
100
+ condition = false
101
+ testName = "MathType license"
102
+ reportText = "Checking MathType valid license"
103
+ output += createTableRow(testName,reportText,solutionLink,isLicensed)
104
+ else
105
+ reportText = "MathType services not installed"
106
+ end
107
+ debug = (self.plugin::getConfiguration()::getProperty(ConfigurationKeys::DEBUG,"false") == "true")
108
+ if debug
109
+ testName = "Font family"
110
+ solutionLink = ""
111
+ condition = true
112
+ reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::FONT_FAMILY,"")
113
+ output += createTableRow(testName,reportText,solutionLink,condition)
114
+ testName = "Configuration file"
115
+ solutionLink = ""
116
+ condition = true
117
+ reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::CONFIGURATION_PATH,"") + "\\configuration.ini"
118
+ output += createTableRow(testName,reportText,solutionLink,condition)
119
+ testName = "Cache path"
120
+ solutionLink = ""
121
+ condition = true
122
+ reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::CACHE_FOLDER,"")
123
+ output += createTableRow(testName,reportText,solutionLink,condition)
124
+ testName = "Formula path"
125
+ solutionLink = ""
126
+ condition = true
127
+ reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::FORMULA_FOLDER,"")
128
+ output += createTableRow(testName,reportText,solutionLink,condition)
129
+ testName = "Integration path"
130
+ solutionLink = ""
131
+ condition = true
132
+ reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::INTEGRATION_PATH,"")
133
+ output += createTableRow(testName,reportText,solutionLink,condition)
134
+ testName = "Context path"
135
+ solutionLink = ""
136
+ condition = true
137
+ reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"")
138
+ output += createTableRow(testName,reportText,solutionLink,condition)
139
+ testName = "default-configuration.ini load"
140
+ solutionLink = ""
141
+ defaultConfiguration = Storage::newResourceStorage("default-configuration.ini")::read()
142
+ condition = (defaultConfiguration != nil) && (defaultConfiguration::length() > 0)
143
+ if condition
144
+ reportText = "Length: " + defaultConfiguration::length().to_s
145
+ else
146
+ reportText = "Not found!"
147
+ end
148
+ output += createTableRow(testName,reportText,solutionLink,condition)
149
+ testName = "cas.png load"
150
+ solutionLink = ""
151
+ casPng = Storage::newResourceStorage("cas.png")::readBinary()
152
+ casPngLength = 0
153
+ if casPng != nil
154
+ casPngLength = Bytes::ofData(casPng)::length()
155
+ condition = casPngLength > 0
156
+ else
157
+ condition = false
158
+ end
159
+ if condition
160
+ reportText = "Length: " + casPngLength.to_s
161
+ else
162
+ reportText = "Not found!"
163
+ end
164
+ output += createTableRow(testName,reportText,solutionLink,condition)
165
+ end
166
+ output += "<div id=\"haxe:trace\"></div>"
167
+ return output
139
168
  end
140
- if condition
141
- reportText = "Length: "+casPngLength.to_s
142
- else
143
- reportText = "Not found!"
169
+ def createTableRow(testName, reportText, solutionLink, condition)
170
+ output = ""
171
+ output += "<tr>"
172
+ output += ("<td>" + testName) + "</td>"
173
+ output += ("<td>" + reportText) + "</td>"
174
+ output += "<td>"
175
+ if condition
176
+ output += "<span class=\"ok\">OK</span><br/>"
177
+ else
178
+ output += "<span class=\"error\">ERROR</span><br/>"
179
+ end
180
+ output += "</td>"
181
+ output += "</tr>\r\n"
182
+ return output
144
183
  end
145
- output+=createTableRow(testName,reportText,solutionLink,condition)
146
- end
147
- output+="<div id=\"haxe:trace\"></div>"
148
- return output
149
- end
150
- def createTableRow(testName,reportText,solutionLink,condition)
151
- output = ""
152
- output+="<tr>"
153
- output+=("<td>"+testName)+"</td>"
154
- output+=("<td>"+reportText)+"</td>"
155
- output+="<td>"
156
- if condition
157
- output+="<span class=\"ok\">OK</span><br/>"
158
- else
159
- output+="<span class=\"error\">ERROR</span><br/>"
160
- end
161
- output+="</td>"
162
- output+="</tr>\r\n"
163
- return output
184
+
164
185
  end
165
- end
166
186
  end
@@ -1,211 +1,227 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
- require('com/wiris/plugin/impl/TextFilterTags.rb')
5
- require('com/wiris/util/json/JSon.rb')
6
- class TextFilter
7
- include Wiris
3
+ require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
+ require('com/wiris/plugin/impl/TextFilterTags.rb')
5
+ require('com/wiris/util/type/UrlUtils.rb')
6
+ require('com/wiris/util/json/JSon.rb')
7
+ class TextFilter
8
+ include Wiris
8
9
 
9
- attr_accessor :plugin
10
- attr_accessor :render
11
- attr_accessor :service
12
- attr_accessor :fixUrl
13
- NBSP = Std::fromCharCode(160)
14
- def initialize(plugin)
15
- super()
16
- @plugin = plugin
17
- @render = plugin::newRender()
18
- @service = plugin::newTextService()
19
- @fixUrl = nil
20
- end
21
- def filter(str,prop)
22
- saveMode = nil
23
- if prop!=nil
24
- saveMode = PropertiesTools::getProperty(prop,"savemode")
25
- end
26
- if saveMode==nil
27
- saveMode = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml")
28
- end
29
- b = (saveMode=="safeXml")
30
- if b
31
- tags = TextFilterTags::newSafeXml()
32
- else
33
- tags = TextFilterTags::newXml()
34
- end
35
- str = filterMath(tags,str,prop,b)
36
- str = filterApplet(tags,str,prop,b)
37
- return str
38
- end
39
- def filterMath(tags,text,prop,safeXML)
40
- output = StringBuf.new()
41
- n0 = 0
42
- n1 = text::indexOf(tags::in_mathopen,n0)
43
- tag = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_MATHML_ATTRIBUTE,"data-mathml")
44
- dataMathml = text::indexOf(tag,0)
45
- while n1>=0
46
- m0 = n0
47
- output::add(Std::substr(text,n0,n1-n0))
48
- n0 = n1
49
- n1 = text::indexOf(tags::in_mathclose,n0)
50
- if n1>=0
51
- n1 = n1+tags::in_mathclose::length()
52
- sub = Std::substr(text,n0,n1-n0)
53
- if safeXML
54
- if dataMathml!=-1
55
- m1 = text::indexOf("/>",n1)
56
- if (m1>=0)&&((text::indexOf("<img",n1)==-1)||(text::indexOf("<img",n1)>m1))
57
- m0 = Std::substr(text,m0,n0-m0)::lastIndexOf("<img")
58
- if m0>=0
59
- if (text::indexOf(tag,m0)>0)&&(text::indexOf(tag,m0)<n1)
10
+ attr_accessor :plugin
11
+ attr_accessor :render
12
+ attr_accessor :service
13
+ attr_accessor :fixUrl
14
+ NBSP = Std::fromCharCode(160)
15
+ def initialize(plugin)
16
+ super()
17
+ self.plugin = plugin
18
+ self.render = plugin::newRender()
19
+ self.service = plugin::newTextService()
20
+ self.fixUrl = nil
21
+ end
22
+ def filter(str, prop)
23
+ saveMode = nil
24
+ if prop != nil
25
+ saveMode = PropertiesTools::getProperty(prop,"savemode")
26
+ end
27
+ if saveMode == nil
28
+ saveMode = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml")
29
+ end
30
+ b = (saveMode == "safeXml")
31
+ mathNamespace = nil
32
+ namespaceIndex = str::indexOf(":math")
33
+ if namespaceIndex >= 0
34
+ mathNamespace = Std::substr(str,str::lastIndexOf("<",namespaceIndex) + 1,namespaceIndex - (str::lastIndexOf("<",namespaceIndex) + 1))
35
+ end
36
+ if b
37
+ tags = TextFilterTags::newSafeXml()
38
+ else
39
+ tags = TextFilterTags::newXml(mathNamespace)
40
+ end
41
+ str = filterMath(tags,str,prop,b)
42
+ str = filterApplet(tags,str,prop,b)
43
+ return str
44
+ end
45
+ def filterMath(tags, text, prop, safeXML)
46
+ output = StringBuf.new()
47
+ n0 = 0
48
+ n1 = text::indexOf(tags::in_mathopen,n0)
49
+ tag = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_MATHML_ATTRIBUTE,"data-mathml")
50
+ dataMathml = text::indexOf(tag,0)
51
+ while n1 >= 0
52
+ m0 = n0
53
+ output::add(Std::substr(text,n0,n1 - n0))
54
+ n0 = n1
55
+ n1 = text::indexOf(tags::in_mathclose,n0)
56
+ if n1 >= 0
57
+ n1 = n1 + tags::in_mathclose::length()
58
+ sub = Std::substr(text,n0,n1 - n0)
59
+ if safeXML
60
+ if dataMathml != -1
61
+ m1 = text::indexOf("/>",n1)
62
+ if m1 == -1
63
+ m1 = text::indexOf(">",n1)
64
+ end
65
+ if (m1 >= 0) && ((text::indexOf("<img",n1) == -1) || (text::indexOf("<img",n1) > m1))
66
+ m0 = Std::substr(text,m0,n0 - m0)::lastIndexOf("<img")
67
+ if m0 >= 0
68
+ if (text::indexOf(tag,m0) > 0) && (text::indexOf(tag,m0) < n1)
69
+ n0 = n1
70
+ output::add(sub)
71
+ n1 = text::indexOf(tags::in_mathopen,n0)
72
+ m0 = m1
73
+ next
74
+ end
75
+ end
76
+ end
77
+ end
78
+ if @fixUrl == nil
79
+ @fixUrl = EReg.new("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">","")
80
+ end
81
+ sub = @fixUrl::replace(sub,"$1")
82
+ sub = html_entity_decode(sub)
83
+ sub = StringTools::replace(sub,tags::in_double_quote,tags::out_double_quote)
84
+ sub = StringTools::replace(sub,tags::in_open,tags::out_open)
85
+ sub = StringTools::replace(sub,tags::in_close,tags::out_close)
86
+ sub = StringTools::replace(sub,tags::in_entity,tags::out_entity)
87
+ sub = StringTools::replace(sub,tags::in_quote,tags::out_quote)
88
+ end
89
+ begin
90
+ subtext = math2Img(sub,prop)
91
+ end
92
+ sub = subtext
60
93
  n0 = n1
61
94
  output::add(sub)
62
95
  n1 = text::indexOf(tags::in_mathopen,n0)
63
- m0 = m1
64
- next
65
- end
66
96
  end
67
- end
68
97
  end
69
- if @fixUrl==nil
70
- @fixUrl = EReg.new("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">","")
98
+ output::add(Std::substr(text,n0))
99
+ return output::toString()
100
+ end
101
+ def filterApplet(tags, text, prop, safeXML)
102
+ output = StringBuf.new()
103
+ n0 = 0
104
+ n1 = text::toUpperCase()::indexOf(tags::in_appletopen,n0)
105
+ while n1 >= 0
106
+ output::add(Std::substr(text,n0,n1 - n0))
107
+ n0 = n1
108
+ n1 = text::toUpperCase()::indexOf(tags::in_appletclose,n0)
109
+ if n1 >= 0
110
+ n1 = n1 + tags::in_appletclose::length()
111
+ sub = Std::substr(text,n0,n1 - n0)
112
+ if safeXML
113
+ if @fixUrl == nil
114
+ @fixUrl = EReg.new("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">","")
115
+ end
116
+ sub = @fixUrl::replace(sub,"$1")
117
+ sub = html_entity_decode(sub)
118
+ sub = StringTools::replace(sub,tags::in_double_quote,tags::out_double_quote)
119
+ sub = StringTools::replace(sub,tags::in_open,tags::out_open)
120
+ sub = StringTools::replace(sub,tags::in_close,tags::out_close)
121
+ sub = StringTools::replace(sub,tags::in_entity,tags::out_entity)
122
+ sub = StringTools::replace(sub,tags::in_quote,tags::out_quote)
123
+ end
124
+ n0 = n1
125
+ output::add(sub)
126
+ n1 = text::toUpperCase()::indexOf(tags::in_appletopen,n0)
127
+ end
71
128
  end
72
- sub = @fixUrl::replace(sub,"$1")
73
- sub = html_entity_decode(sub)
74
- sub = StringTools::replace(sub,tags::in_double_quote,tags::out_double_quote)
75
- sub = StringTools::replace(sub,tags::in_open,tags::out_open)
76
- sub = StringTools::replace(sub,tags::in_close,tags::out_close)
77
- sub = StringTools::replace(sub,tags::in_entity,tags::out_entity)
78
- sub = StringTools::replace(sub,tags::in_quote,tags::out_quote)
79
- end
80
- sub = math2Img(sub,prop)
81
- n0 = n1
82
- output::add(sub)
83
- n1 = text::indexOf(tags::in_mathopen,n0)
129
+ output::add(Std::substr(text,n0))
130
+ return output::toString()
84
131
  end
85
- end
86
- output::add(Std::substr(text,n0))
87
- return output::toString()
88
- end
89
- def filterApplet(tags,text,prop,safeXML)
90
- output = StringBuf.new()
91
- n0 = 0
92
- n1 = text::toUpperCase()::indexOf(tags::in_appletopen,n0)
93
- while n1>=0
94
- output::add(Std::substr(text,n0,n1-n0))
95
- n0 = n1
96
- n1 = text::toUpperCase()::indexOf(tags::in_appletclose,n0)
97
- if n1>=0
98
- n1 = n1+tags::in_appletclose::length()
99
- sub = Std::substr(text,n0,n1-n0)
100
- if safeXML
101
- if @fixUrl==nil
102
- @fixUrl = EReg.new("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">","")
132
+ def math2Img(str, prop)
133
+ img = "<img"
134
+ output = PropertiesTools::newProperties()
135
+ PropertiesTools::setProperty(prop,"centerbaseline","false")
136
+ PropertiesTools::setProperty(prop,"accessible","true")
137
+ PropertiesTools::setProperty(prop,"metrics","true")
138
+ provider = @plugin::newGenericParamsProvider(prop)
139
+ if (@plugin::getConfiguration()::getProperty("wirispluginperformance","false") == "false")
140
+ src = @render::createImage(str,provider,output)
141
+ img += (" src=\"" + src) + "\""
142
+ alt = PropertiesTools::getProperty(output,"alt")
143
+ width = PropertiesTools::getProperty(output,"width")
144
+ height = PropertiesTools::getProperty(output,"height")
145
+ baseline = PropertiesTools::getProperty(output,"baseline")
146
+ role = PropertiesTools::getProperty(output,"role")
147
+ else
148
+ digest = @render::computeDigest(str,prop)
149
+ hashImage = @render::showImageHash(digest,PropertiesTools::getProperty(prop,"lang"))
150
+ if hashImage == nil
151
+ @render::showImage(nil,str,provider)
152
+ hashImage = @render::showImageHash(digest,PropertiesTools::getProperty(prop,"lang"))
153
+ end
154
+ content = (hashImage::get("content"))
155
+ if (@plugin::getConfiguration()::getProperty("wirisimageformat","png") == "png")
156
+ img += (" src=\"data:image/png;base64," + content) + "\""
157
+ else
158
+ img += (" src=\"data:image/svg+xml;charset=utf8," + UrlUtils::urlComponentEncode(content)) + "\""
159
+ end
160
+ if hashImage::exists("alt")
161
+ alt = (hashImage::get("alt"))
162
+ else
163
+ alt = @service::mathml2accessible(str,nil,prop)
164
+ end
165
+ width = (hashImage::get("width"))
166
+ height = (hashImage::get("height"))
167
+ baseline = (hashImage::get("baseline"))
168
+ role = (hashImage::get("role"))
169
+ end
170
+ dpi = Std::parseFloat(@plugin::getConfiguration()::getProperty(ConfigurationKeys::WIRIS_DPI,"96"))
171
+ if @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil) != nil
172
+ json = JSon::decode(@plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil))
173
+ decodedHash = (json)
174
+ if decodedHash::exists("dpi")
175
+ dpi = Std::parseFloat((decodedHash::get("dpi")))
176
+ end
103
177
  end
104
- sub = @fixUrl::replace(sub,"$1")
105
- sub = html_entity_decode(sub)
106
- sub = StringTools::replace(sub,tags::in_double_quote,tags::out_double_quote)
107
- sub = StringTools::replace(sub,tags::in_open,tags::out_open)
108
- sub = StringTools::replace(sub,tags::in_close,tags::out_close)
109
- sub = StringTools::replace(sub,tags::in_entity,tags::out_entity)
110
- sub = StringTools::replace(sub,tags::in_quote,tags::out_quote)
111
- end
112
- n0 = n1
113
- output::add(sub)
114
- n1 = text::toUpperCase()::indexOf(tags::in_appletopen,n0)
178
+ mml = (@plugin::getConfiguration()::getProperty(ConfigurationKeys::FILTER_OUTPUT_MATHML,"false") == "true")
179
+ f = 96/dpi
180
+ imageFormatController = @plugin::getImageFormatController()
181
+ metricsHash = Hash.new()
182
+ metricsHash::set("width",Std::parseInt(width))
183
+ metricsHash::set("height",Std::parseInt(height))
184
+ metricsHash::set("baseline",Std::parseInt(baseline))
185
+ imageFormatController::scalateMetrics(dpi,metricsHash)
186
+ alt = html_entity_encode(alt)
187
+ img += " class=\"Wirisformula\""
188
+ img += (" alt=\"" + alt) + "\""
189
+ img += (" width=\"" + (metricsHash::get("width")).to_s) + "\""
190
+ img += (" height=\"" + (metricsHash::get("height")).to_s) + "\""
191
+ verticalAlign = (metricsHash::get("baseline") - metricsHash::get("height"))
192
+ img += (" style=\"vertical-align:" + verticalAlign.to_s) + "px\""
193
+ img += (" role=\"" + role) + "\""
194
+ if mml
195
+ tag = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_MATHML_ATTRIBUTE,"data-mathml")
196
+ img += (((" " + tag) + "=\'") + save_xml_encode(str)) + "\'"
197
+ end
198
+ img += "/>"
199
+ return img
115
200
  end
116
- end
117
- output::add(Std::substr(text,n0))
118
- return output::toString()
119
- end
120
- def math2Img(str,prop)
121
- img = "<img"
122
- output = PropertiesTools::newProperties()
123
- PropertiesTools::setProperty(prop,"centerbaseline","false")
124
- PropertiesTools::setProperty(prop,"accessible","true")
125
- PropertiesTools::setProperty(prop,"metrics","true")
126
- provider = @plugin::newGenericParamsProvider(prop)
127
- if (@plugin::getConfiguration()::getProperty("wirispluginperformance","false")=="false")
128
- src = @render::createImage(str,provider,output)
129
- img+=(" src=\""+src)+"\""
130
- alt = PropertiesTools::getProperty(output,"alt")
131
- width = PropertiesTools::getProperty(output,"width")
132
- height = PropertiesTools::getProperty(output,"height")
133
- baseline = PropertiesTools::getProperty(output,"baseline")
134
- else
135
- digest = @render::computeDigest(str,prop)
136
- json = JSon::decode(@render::showImageJson(digest,PropertiesTools::getProperty(prop,"alt")))
137
- hashImage = (json)
138
- if (hashImage::get("status")=="warning")
139
- @render::showImage(nil,str,provider)
201
+ def html_entity_decode(str)
202
+ str = StringTools::replace(str,"&lt;","<")
203
+ str = StringTools::replace(str,"&gt;",">")
204
+ str = StringTools::replace(str,"&quot;","\"")
205
+ str = StringTools::replace(str,"&nbsp;",NBSP)
206
+ str = StringTools::replace(str,"&amp;","&")
207
+ return str
140
208
  end
141
- json = JSon::decode(@render::showImageJson(digest,"en"))
142
- hashImage = (json)
143
- if (hashImage::get("status")=="ok")
144
- result = (hashImage::get("result"))
145
- base64 = (result::get("base64"))
146
- img+=(" src=\"data:image/png;base64,"+base64)+"\""
147
- if result::exists("alt")
148
- alt = (result::get("alt"))
149
- else
150
- alt = @service::mathml2accessible(str,nil,prop)
151
- end
152
- width = (result::get("width"))
153
- height = (result::get("height"))
154
- baseline = (result::get("baseline"))
155
- else
156
- raise Exception,"Image can\'t be rendererd"
209
+ def html_entity_encode(str)
210
+ str = StringTools::replace(str,"<","&lt;")
211
+ str = StringTools::replace(str,">","&gt;")
212
+ str = StringTools::replace(str,"\"","&quot;")
213
+ str = StringTools::replace(str,"&","&amp;")
214
+ return str
157
215
  end
158
- end
159
- dpi = Std::parseFloat(@plugin::getConfiguration()::getProperty(ConfigurationKeys::WIRIS_DPI,"96"))
160
- if @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil)!=nil
161
- json = JSon::decode(@plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil))
162
- decodedHash = (json)
163
- if decodedHash::exists("dpi")
164
- dpi = Std::parseFloat((decodedHash::get("dpi")))
216
+ def save_xml_encode(str)
217
+ tags = TextFilterTags::newSafeXml()
218
+ str = StringTools::replace(str,tags::out_double_quote,tags::in_double_quote)
219
+ str = StringTools::replace(str,tags::out_open,tags::in_open)
220
+ str = StringTools::replace(str,tags::out_close,tags::in_close)
221
+ str = StringTools::replace(str,tags::out_entity,tags::in_entity)
222
+ str = StringTools::replace(str,tags::out_quote,tags::in_quote)
223
+ return str
165
224
  end
166
- end
167
- mml = (@plugin::getConfiguration()::getProperty(ConfigurationKeys::FILTER_OUTPUT_MATHML,"false")=="true")
168
- f = 96/dpi
169
- dwidth = f*Std::parseFloat(width)
170
- dheight = f*Std::parseFloat(height)
171
- dbaseline = f*Std::parseFloat(baseline)
172
- alt = html_entity_encode(alt)
173
- img+=" class=\"Wirisformula\""
174
- img+=(" alt=\""+alt)+"\""
175
- img+=(" width=\""+(dwidth).to_s)+"\""
176
- img+=(" height=\""+(dheight).to_s)+"\""
177
- d = ((dbaseline-dheight))
178
- img+=(" style=\"vertical-align:"+d.to_s)+"px\""
179
- if mml
180
- tag = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_MATHML_ATTRIBUTE,"data-mathml")
181
- img+=(((" "+tag)+"=\"")+save_xml_encode(str))+"\""
182
- end
183
- img+="/>"
184
- return img
185
- end
186
- def html_entity_decode(str)
187
- str = StringTools::replace(str,"&lt;","<")
188
- str = StringTools::replace(str,"&gt;",">")
189
- str = StringTools::replace(str,"&quot;","\"")
190
- str = StringTools::replace(str,"&nbsp;",NBSP)
191
- str = StringTools::replace(str,"&amp;","&")
192
- return str
193
- end
194
- def html_entity_encode(str)
195
- str = StringTools::replace(str,"<","&lt;")
196
- str = StringTools::replace(str,">","&gt;")
197
- str = StringTools::replace(str,"\"","&quot;")
198
- str = StringTools::replace(str,"&","&amp;")
199
- return str
200
- end
201
- def save_xml_encode(str)
202
- tags = TextFilterTags::newSafeXml()
203
- str = StringTools::replace(str,tags::out_double_quote,tags::in_double_quote)
204
- str = StringTools::replace(str,tags::out_open,tags::in_open)
205
- str = StringTools::replace(str,tags::out_close,tags::in_close)
206
- str = StringTools::replace(str,tags::out_entity,tags::in_entity)
207
- str = StringTools::replace(str,tags::out_quote,tags::in_quote)
208
- return str
225
+
209
226
  end
210
- end
211
227
  end