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.
- checksums.yaml +4 -4
- data/Rakefile +34 -34
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
- data/app/controllers/wirispluginengine/application_controller.rb +84 -75
- data/app/helpers/wirispluginengine/application_helper.rb +4 -4
- data/config/routes.rb +4 -4
- data/lib/com/wiris/common/WInteger.rb +52 -51
- data/lib/com/wiris/plugin/api/Cas.rb +5 -5
- data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
- data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
- data/lib/com/wiris/plugin/api/Editor.rb +5 -5
- data/lib/com/wiris/plugin/api/Filter.rb +5 -5
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
- data/lib/com/wiris/plugin/api/Render.rb +5 -5
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
- data/lib/com/wiris/plugin/api/Test.rb +5 -5
- data/lib/com/wiris/plugin/api/TextService.rb +5 -5
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
- data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
- data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
- data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
- data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
- data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
- data/lib/com/wiris/util/json/JSon.rb +505 -493
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
- data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
- data/lib/com/wiris/util/json/StringParser.rb +57 -56
- data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Cache.rb +8 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
- data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
- data/lib/com/wiris/util/sys/IniFile.rb +132 -131
- data/lib/com/wiris/util/sys/Lock.rb +8 -0
- data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Store.rb +126 -101
- data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
- data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
- data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
- data/lib/com/wiris/util/type/Arrays.rb +275 -0
- data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
- data/lib/com/wiris/util/type/Comparator.rb +8 -0
- data/lib/com/wiris/util/type/DataUtils.rb +24 -0
- data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
- data/lib/com/wiris/util/type/HashCache.rb +43 -0
- data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
- data/lib/com/wiris/util/type/Queue.rb +31 -0
- data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
- data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
- data/lib/com/wiris/util/type/SortedHash.rb +45 -0
- data/lib/com/wiris/util/type/Stack.rb +31 -0
- data/lib/com/wiris/util/type/StringUtils.rb +56 -0
- data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
- data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
- data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
- data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
- data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
- data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
- data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
- data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
- data/lib/com/wiris/util/xml/WEntities.rb +11 -9
- data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
- data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
- data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
- data/lib/loader.rb +15 -12
- data/lib/src-generic/Array.rb +22 -22
- data/lib/src-generic/ArrayInt.rb +31 -31
- data/lib/src-generic/Base64.rb +14 -14
- data/lib/src-generic/BaseCode.rb +93 -93
- data/lib/src-generic/Boolean.rb +27 -0
- data/lib/src-generic/Bytes.rb +50 -50
- data/lib/src-generic/BytesInput.rb +37 -37
- data/lib/src-generic/EReg.rb +55 -55
- data/lib/src-generic/File.rb +35 -35
- data/lib/src-generic/FileLock.rb +26 -26
- data/lib/src-generic/FileSystem.rb +37 -37
- data/lib/src-generic/Hash.rb +42 -42
- data/lib/src-generic/Http.rb +111 -107
- data/lib/src-generic/HttpRequest.rb +25 -25
- data/lib/src-generic/HttpResponse.rb +70 -70
- data/lib/src-generic/Iterator.rb +20 -19
- data/lib/src-generic/Math.rb +14 -14
- data/lib/src-generic/Md5.rb +8 -8
- data/lib/src-generic/Md5Tools.rb +11 -11
- data/lib/src-generic/PropertiesTools.rb +32 -32
- data/lib/src-generic/Reflect.rb +16 -16
- data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
- data/lib/src-generic/Serializer.rb +84 -84
- data/lib/src-generic/Std.rb +74 -74
- data/lib/src-generic/Storage.rb +152 -152
- data/lib/src-generic/StringBuf.rb +40 -40
- data/lib/src-generic/StringTools.rb +44 -46
- data/lib/src-generic/Timer.rb +6 -6
- data/lib/src-generic/Type.rb +18 -18
- data/lib/src-generic/TypeTools.rb +31 -31
- data/lib/src-generic/Unserializer.rb +72 -72
- data/lib/src-generic/Utf8.rb +26 -26
- data/lib/src-generic/Xml.rb +199 -198
- data/lib/src-generic/extended/Integer.rb +5 -5
- data/lib/src-generic/extended/Math.rb +6 -6
- data/lib/src-generic/extended/Properties.rb +11 -11
- data/lib/src-generic/extended/String.rb +38 -38
- data/lib/src-generic/settings/PlatformSettings.rb +18 -18
- data/lib/src-generic/system/HttpProxy.rb +23 -0
- data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
- data/lib/wirispluginengine.rb +5 -5
- data/lib/wirispluginengine/engine.rb +5 -5
- data/lib/wirispluginengine/integration/cleancache.rb +8 -8
- data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
- data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
- data/lib/wirispluginengine/integration/createimage.rb +7 -7
- data/lib/wirispluginengine/integration/getmathml.rb +18 -18
- data/lib/wirispluginengine/integration/resource.rb +8 -8
- data/lib/wirispluginengine/integration/service.rb +5 -5
- data/lib/wirispluginengine/integration/showimage.rb +28 -21
- data/lib/wirispluginengine/integration/test.rb +5 -5
- data/lib/wirispluginengine/integration/testfilter.rb +10 -0
- data/lib/wirispluginengine/version.rb +2 -2
- data/resources/VERSION +1 -1
- data/resources/WEB-INF/web.xml +25 -0
- data/resources/WIRISplugins.js +3809 -0
- data/resources/default-configuration.ini +47 -45
- data/resources/tech.txt +1 -1
- data/resources/wirisplugin.css +43 -42
- metadata +40 -4
- data/configuration.ini.dist +0 -104
@@ -1,280 +1,326 @@
|
|
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/util/sys/IniFile.rb')
|
6
|
-
require('com/wiris/
|
7
|
-
require('com/wiris/
|
8
|
-
|
9
|
-
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/impl/HttpImpl.rb')
|
5
|
+
require('com/wiris/util/sys/IniFile.rb')
|
6
|
+
require('com/wiris/plugin/api/Render.rb')
|
7
|
+
require('com/wiris/util/type/UrlUtils.rb')
|
8
|
+
require('com/wiris/util/json/JSon.rb')
|
9
|
+
require('com/wiris/plugin/api/Render.rb')
|
10
|
+
class RenderImpl
|
11
|
+
extend RenderInterface
|
10
12
|
|
11
|
-
|
13
|
+
include Wiris
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
def computeDigest(mml,param)
|
19
|
-
ss = getEditorParametersList()
|
20
|
-
renderParams = Hash.new()
|
21
|
-
for i in 0..ss::length-1
|
22
|
-
key = ss[i]
|
23
|
-
value = PropertiesTools::getProperty(param,key)
|
24
|
-
if value!=nil
|
25
|
-
renderParams::set(key,value)
|
26
|
-
end
|
27
|
-
i+=1
|
15
|
+
attr_accessor :plugin
|
16
|
+
def initialize(plugin)
|
17
|
+
super()
|
18
|
+
self.plugin = plugin
|
28
19
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
if (provider::getParameter("metrics","false")=="true")
|
46
|
-
s = getMetrics(digest,output)
|
47
|
-
end
|
48
|
-
a = ""
|
49
|
-
if (provider::getParameter("accessible","false")=="true")
|
50
|
-
lang = provider::getParameter("lang","en")
|
51
|
-
text = safeMath2Accessible(mml,lang,provider::getParameters())
|
52
|
-
if output==nil
|
53
|
-
a = "&text="+StringTools::urlEncode(text).to_s
|
54
|
-
else
|
55
|
-
PropertiesTools::setProperty(output,"alt",text)
|
20
|
+
def computeDigest(mml, param)
|
21
|
+
ss = getEditorParametersList()
|
22
|
+
renderParams = Hash.new()
|
23
|
+
for i in 0..ss::length - 1
|
24
|
+
key = ss[i]
|
25
|
+
value = PropertiesTools::getProperty(param,key)
|
26
|
+
if value != nil
|
27
|
+
renderParams::set(key,value)
|
28
|
+
end
|
29
|
+
i+=1
|
30
|
+
end
|
31
|
+
if mml != nil
|
32
|
+
renderParams::set("mml",mml)
|
33
|
+
end
|
34
|
+
s = IniFile::propertiesToString(renderParams)
|
35
|
+
return @plugin::getStorageAndCache()::codeDigest(s)
|
56
36
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
for i in 0..ss::length-1
|
97
|
-
key = ss[i]
|
98
|
-
value = PropertiesTools::getProperty(renderParameters,key)
|
99
|
-
if value!=nil
|
100
|
-
atts = true
|
101
|
-
renderParams::set(key,value)
|
37
|
+
def createImage(mml, provider, ref_output)
|
38
|
+
output = ref_output
|
39
|
+
if mml == nil
|
40
|
+
raise Exception,"Missing parameter \'mml\'."
|
41
|
+
end
|
42
|
+
digest = computeDigest(mml,provider::getRenderParameters(@plugin::getConfiguration()))
|
43
|
+
contextPath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/")
|
44
|
+
showImagePath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SHOWIMAGE_PATH,nil)
|
45
|
+
saveMode = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml")
|
46
|
+
s = ""
|
47
|
+
if (provider::getParameter("metrics","false") == "true")
|
48
|
+
s = getMetrics(digest,output)
|
49
|
+
end
|
50
|
+
a = ""
|
51
|
+
if (provider::getParameter("accessible","false") == "true")
|
52
|
+
lang = provider::getParameter("lang","en")
|
53
|
+
text = safeMath2Accessible(mml,lang,provider::getParameters())
|
54
|
+
if output == nil
|
55
|
+
a = "&text=" + UrlUtils::urlComponentEncode(text)
|
56
|
+
else
|
57
|
+
PropertiesTools::setProperty(output,"alt",text)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
rparam = ""
|
61
|
+
if provider::getParameter("refererquery",nil) != nil
|
62
|
+
refererquery = provider::getParameter("refererquery","")
|
63
|
+
rparam = "&refererquery=" + refererquery
|
64
|
+
end
|
65
|
+
if output != nil
|
66
|
+
PropertiesTools::setProperty(output,"role","math")
|
67
|
+
end
|
68
|
+
if (provider::getParameter("base64",nil) != nil) || (saveMode == "base64")
|
69
|
+
bs = showImage(digest,nil,provider)
|
70
|
+
by = Bytes::ofData(bs)
|
71
|
+
b64 = Base64.new()::encodeBytes(by)
|
72
|
+
imageContentType = @plugin::getImageFormatController()::getContentType()
|
73
|
+
return (("data:" + imageContentType) + ";base64,") + b64::toString().to_s
|
74
|
+
else
|
75
|
+
return (((RenderImpl.concatPath(contextPath,showImagePath) + UrlUtils::urlComponentEncode(digest)) + s) + a) + rparam
|
102
76
|
end
|
103
|
-
i+=1
|
104
|
-
end
|
105
|
-
end
|
106
|
-
if atts
|
107
|
-
if mml!=nil
|
108
|
-
digest = computeDigest(mml,PropertiesTools::toProperties(renderParams))
|
109
|
-
else
|
110
|
-
digest = computeDigest(renderParams::get("mml"),PropertiesTools::toProperties(renderParams))
|
111
77
|
end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
bs = store::retreiveData(digest,@plugin::getConfiguration()::getProperty("wirisimageformat","png"))
|
116
|
-
if bs==nil
|
117
|
-
if @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil)!=nil
|
118
|
-
json = JSon::decode(@plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil))
|
119
|
-
decodedHash = (json)
|
120
|
-
keys = decodedHash::keys()
|
121
|
-
notAllowedParams = Std::split(ConfigurationKeys::EDITOR_PARAMETERS_NOTRENDER_LIST,",")
|
122
|
-
while keys::hasNext()
|
123
|
-
key = keys::next()
|
124
|
-
if !notAllowedParams::contains_(key)
|
125
|
-
renderParams::set(key,(decodedHash::get(key)))
|
78
|
+
def showImage(digest, mml, provider)
|
79
|
+
if (digest == nil) && (mml == nil)
|
80
|
+
raise Exception,"Missing parameters \'formula\' or \'mml\'."
|
126
81
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
82
|
+
if (digest != nil) && (mml != nil)
|
83
|
+
raise Exception,"Only one parameter \'formula\' or \'mml\' is valid."
|
84
|
+
end
|
85
|
+
atts = false
|
86
|
+
if ((digest == nil) && (mml != nil)) && (provider != nil)
|
87
|
+
digest = computeDigest(mml,provider::getRenderParameters(@plugin::getConfiguration()))
|
88
|
+
end
|
89
|
+
formula = @plugin::getStorageAndCache()::decodeDigest(digest)
|
90
|
+
if formula == nil
|
91
|
+
raise Exception,"Formula associated to digest not found."
|
92
|
+
end
|
93
|
+
if formula::startsWith("<")
|
94
|
+
raise Exception,"Not implemented."
|
95
|
+
end
|
96
|
+
iniFile = IniFile::newIniFileFromString(formula)
|
97
|
+
renderParams = iniFile::getProperties()
|
98
|
+
ss = getEditorParametersList()
|
99
|
+
if provider != nil
|
100
|
+
renderParameters = provider::getRenderParameters(@plugin::getConfiguration())
|
101
|
+
for i in 0..ss::length - 1
|
102
|
+
key = ss[i]
|
103
|
+
value = PropertiesTools::getProperty(renderParameters,key)
|
104
|
+
if value != nil
|
105
|
+
atts = true
|
106
|
+
renderParams::set(key,value)
|
107
|
+
end
|
108
|
+
i+=1
|
109
|
+
end
|
110
|
+
end
|
111
|
+
if atts
|
112
|
+
if mml != nil
|
113
|
+
digest = computeDigest(mml,PropertiesTools::toProperties(renderParams))
|
114
|
+
else
|
115
|
+
digest = computeDigest(renderParams::get("mml"),PropertiesTools::toProperties(renderParams))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
store = @plugin::getStorageAndCache()
|
119
|
+
bs = nil
|
120
|
+
bs = store::retreiveData(digest,@plugin::getConfiguration()::getProperty("wirisimageformat","png"))
|
121
|
+
if bs == nil
|
122
|
+
if @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil) != nil
|
123
|
+
json = JSon::decode(@plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil))
|
124
|
+
decodedHash = (json)
|
125
|
+
keys = decodedHash::keys()
|
126
|
+
notAllowedParams = Std::split(ConfigurationKeys::EDITOR_PARAMETERS_NOTRENDER_LIST,",")
|
127
|
+
while keys::hasNext()
|
128
|
+
key = keys::next()
|
129
|
+
if !notAllowedParams::contains_(key)
|
130
|
+
renderParams::set(key,(decodedHash::get(key)))
|
131
|
+
end
|
132
|
+
end
|
133
|
+
else
|
134
|
+
for i in 0..ss::length - 1
|
135
|
+
key = ss[i]
|
136
|
+
if !renderParams::exists(key)
|
137
|
+
confKey = ConfigurationKeys::imageConfigProperties::get(key)
|
138
|
+
if confKey != nil
|
139
|
+
value = @plugin::getConfiguration()::getProperty(confKey,nil)
|
140
|
+
if value != nil
|
141
|
+
renderParams::set(key,value)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
i+=1
|
146
|
+
end
|
147
|
+
end
|
148
|
+
renderParams::set("format",@plugin::getConfiguration()::getProperty("wirisimageformat","png"))
|
149
|
+
h = HttpImpl.new(@plugin::getImageServiceURL(nil,true),nil)
|
150
|
+
@plugin::addReferer(h)
|
151
|
+
@plugin::addProxy(h)
|
152
|
+
iter = renderParams::keys()
|
153
|
+
while iter::hasNext()
|
154
|
+
key = iter::next()
|
155
|
+
h::setParameter(key,renderParams::get(key))
|
156
|
+
end
|
157
|
+
h::request(true)
|
158
|
+
b = Bytes::ofString(h::getData())
|
159
|
+
store::storeData(digest,@plugin::getConfiguration()::getProperty("wirisimageformat","png"),b::getData())
|
160
|
+
bs = b::getData()
|
161
|
+
end
|
162
|
+
return bs
|
163
|
+
end
|
164
|
+
def showImageJson(digest, lang)
|
165
|
+
jsonResult = self.showImageHash(digest,lang)
|
166
|
+
if jsonResult != nil
|
167
|
+
jsonSb = StringBuf.new()
|
168
|
+
iter = jsonResult::keys()
|
169
|
+
jsonSb::add("{\"status\":\"ok\",\"result\":{")
|
170
|
+
while iter::hasNext()
|
171
|
+
key = (iter::next())
|
172
|
+
value = (jsonResult::get(key))
|
173
|
+
value = StringTools::replace(value,"\\","\\\\")
|
174
|
+
value = StringTools::replace(value,"\"","\\\"")
|
175
|
+
value = StringTools::replace(value,"\r","\\r")
|
176
|
+
value = StringTools::replace(value,"\n","\\n")
|
177
|
+
value = StringTools::replace(value,"\t","\\t")
|
178
|
+
jsonSb::add((((("\"" + key) + "\":") + "\"") + value) + "\"")
|
179
|
+
if iter::hasNext()
|
180
|
+
jsonSb::add(",")
|
181
|
+
end
|
138
182
|
end
|
139
|
-
|
140
|
-
|
183
|
+
jsonSb::add("}}")
|
184
|
+
return jsonSb::toString()
|
185
|
+
else
|
186
|
+
return "{\"status\":\"warning\"}"
|
141
187
|
end
|
142
188
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
189
|
+
def showImageHash(digest, lang)
|
190
|
+
imageFormat = @plugin::getConfiguration()::getProperty("wirisimageformat","png")
|
191
|
+
store = @plugin::getStorageAndCache()
|
192
|
+
bs = nil
|
193
|
+
bs = store::retreiveData(digest,imageFormat)
|
194
|
+
if bs != nil
|
195
|
+
jsonResult = Hash.new()
|
196
|
+
content = Bytes::ofData(bs)
|
197
|
+
if (imageFormat == "png")
|
198
|
+
content = Base64.new()::encodeBytes(content)
|
199
|
+
end
|
200
|
+
metrics = PropertiesTools::newProperties()
|
201
|
+
self.getMetrics(digest,metrics)
|
202
|
+
if lang == nil
|
203
|
+
lang = "en"
|
204
|
+
end
|
205
|
+
s = store::retreiveData(digest,lang)
|
206
|
+
hashMetrics = PropertiesTools::fromProperties(metrics)
|
207
|
+
keys = hashMetrics::keys()
|
208
|
+
while keys::hasNext()
|
209
|
+
currentKey = keys::next()
|
210
|
+
jsonResult::set(currentKey,hashMetrics::get(currentKey))
|
211
|
+
end
|
212
|
+
if s != nil
|
213
|
+
cachedServiceText = Utf8::fromBytes(s)
|
214
|
+
b = StringTools::endsWith(cachedServiceText,"}") && StringTools::startsWith(cachedServiceText,"{")
|
215
|
+
if b
|
216
|
+
decodedJson = (JSon::decode(cachedServiceText))
|
217
|
+
jsonErrors = (decodedJson::get("errors"))
|
218
|
+
if jsonErrors == nil
|
219
|
+
result = (decodedJson::get("result"))
|
220
|
+
if result != nil
|
221
|
+
jsonResult::set("alt",(result::get("text")))
|
222
|
+
end
|
223
|
+
else
|
224
|
+
jsonResult::set("alt","Error converting from MathML to accessible text.")
|
225
|
+
end
|
226
|
+
else
|
227
|
+
jsonResult::set("alt",cachedServiceText)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
jsonResult::set("content",content::toString())
|
231
|
+
jsonResult::set("format",imageFormat)
|
232
|
+
jsonResult::set("role","math")
|
233
|
+
return jsonResult
|
234
|
+
else
|
235
|
+
return nil
|
236
|
+
end
|
151
237
|
end
|
152
|
-
|
153
|
-
|
154
|
-
store::storeData(digest,@plugin::getConfiguration()::getProperty("wirisimageformat","png"),b::getData())
|
155
|
-
bs = b::getData()
|
156
|
-
end
|
157
|
-
return bs
|
158
|
-
end
|
159
|
-
def showImageJson(digest,lang)
|
160
|
-
imageFormat = @plugin::getConfiguration()::getProperty("wirisimageformat","png")
|
161
|
-
store = @plugin::getStorageAndCache()
|
162
|
-
bs = nil
|
163
|
-
bs = store::retreiveData(digest,imageFormat)
|
164
|
-
jsonOutput = Hash.new()
|
165
|
-
if bs!=nil
|
166
|
-
jsonOutput::set("status","ok")
|
167
|
-
jsonResult = Hash.new()
|
168
|
-
by = Bytes::ofData(bs)
|
169
|
-
b64 = Base64.new()::encodeBytes(by)
|
170
|
-
metrics = PropertiesTools::newProperties()
|
171
|
-
getMetrics(digest,metrics)
|
172
|
-
if lang==nil
|
173
|
-
lang = "en"
|
238
|
+
def getMathml(digest)
|
239
|
+
return nil
|
174
240
|
end
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
while keys::hasNext()
|
179
|
-
currentKey = keys::next()
|
180
|
-
jsonResult::set(currentKey,hashMetrics::get(currentKey))
|
241
|
+
def getEditorParametersList()
|
242
|
+
pl = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMETERS_LIST,ConfigurationKeys::EDITOR_PARAMETERS_DEFAULT_LIST)
|
243
|
+
return pl::split(",")
|
181
244
|
end
|
182
|
-
|
183
|
-
|
245
|
+
def getMetrics(digest, ref_output)
|
246
|
+
output = ref_output
|
247
|
+
begin
|
248
|
+
bs = showImage(digest,nil,nil)
|
249
|
+
end
|
250
|
+
b = Bytes::ofData(bs)
|
251
|
+
return @plugin::getImageFormatController()::getMetrics(b,output)
|
184
252
|
end
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
dpi = (Math::round(dpi/39.37))
|
236
|
-
bi::readInt32()
|
237
|
-
bi::readByte()
|
253
|
+
def getMetricsFromBytes(bs, ref_output)
|
254
|
+
output = ref_output
|
255
|
+
width = 0
|
256
|
+
height = 0
|
257
|
+
dpi = 0
|
258
|
+
baseline = 0
|
259
|
+
bys = Bytes::ofData(bs)
|
260
|
+
bi = BytesInput.new(bys)
|
261
|
+
n = bys::length()
|
262
|
+
alloc = 10
|
263
|
+
b = Bytes::alloc(alloc)
|
264
|
+
bi::readBytes(b,0,8)
|
265
|
+
n -= 8
|
266
|
+
while n > 0
|
267
|
+
len = bi::readInt32()
|
268
|
+
typ = bi::readInt32()
|
269
|
+
if typ == 1229472850
|
270
|
+
width = bi::readInt32()
|
271
|
+
height = bi::readInt32()
|
272
|
+
bi::readInt32()
|
273
|
+
bi::readByte()
|
274
|
+
else
|
275
|
+
if typ == 1650545477
|
276
|
+
baseline = bi::readInt32()
|
277
|
+
else
|
278
|
+
if typ == 1883789683
|
279
|
+
dpi = bi::readInt32()
|
280
|
+
dpi = (Math::round(dpi/39.37))
|
281
|
+
bi::readInt32()
|
282
|
+
bi::readByte()
|
283
|
+
else
|
284
|
+
if len > alloc
|
285
|
+
alloc = len
|
286
|
+
b = Bytes::alloc(alloc)
|
287
|
+
end
|
288
|
+
bi::readBytes(b,0,len)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
bi::readInt32()
|
293
|
+
n -= len + 12
|
294
|
+
end
|
295
|
+
if output != nil
|
296
|
+
PropertiesTools::setProperty(output,"width","" + width.to_s)
|
297
|
+
PropertiesTools::setProperty(output,"height","" + height.to_s)
|
298
|
+
PropertiesTools::setProperty(output,"baseline","" + baseline.to_s)
|
299
|
+
if dpi != 96
|
300
|
+
PropertiesTools::setProperty(output,"dpi","" + dpi.to_s)
|
301
|
+
end
|
302
|
+
r = ""
|
238
303
|
else
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
bi::readBytes(b,0,len)
|
304
|
+
r = (((("&cw=" + width.to_s) + "&ch=") + height.to_s) + "&cb=") + baseline.to_s
|
305
|
+
if dpi != 96
|
306
|
+
r = (r + "&dpi=") + dpi.to_s
|
307
|
+
end
|
244
308
|
end
|
245
|
-
|
309
|
+
return r
|
246
310
|
end
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
PropertiesTools::setProperty(output,"height",""+height.to_s)
|
253
|
-
PropertiesTools::setProperty(output,"baseline",""+baseline.to_s)
|
254
|
-
if dpi!=96
|
255
|
-
PropertiesTools::setProperty(output,"dpi",""+dpi.to_s)
|
311
|
+
def safeMath2Accessible(mml, lang, param)
|
312
|
+
begin
|
313
|
+
text = @plugin::newTextService()::mathml2accessible(mml,lang,param)
|
314
|
+
return text
|
315
|
+
end
|
256
316
|
end
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
317
|
+
def self.concatPath(s1, s2)
|
318
|
+
if s1::lastIndexOf("/") == (s1::length() - 1)
|
319
|
+
return s1 + s2
|
320
|
+
else
|
321
|
+
return (s1 + "/") + s2
|
322
|
+
end
|
262
323
|
end
|
263
|
-
|
264
|
-
return r
|
265
|
-
end
|
266
|
-
def safeMath2Accessible(mml,lang,param)
|
267
|
-
begin
|
268
|
-
text = @plugin::newTextService()::mathml2accessible(mml,lang,param)
|
269
|
-
return text
|
270
|
-
end
|
271
|
-
end
|
272
|
-
def self.concatPath(s1,s2)
|
273
|
-
if s1::lastIndexOf("/")==(s1::length()-1)
|
274
|
-
return s1+s2
|
275
|
-
else
|
276
|
-
return (s1+"/")+s2
|
277
|
-
end
|
324
|
+
|
278
325
|
end
|
279
|
-
end
|
280
326
|
end
|