wirispluginengine 3.62.0.1322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +2833 -0
- data/app/controllers/wirispluginengine/application_controller.rb +75 -0
- data/app/helpers/wirispluginengine/application_helper.rb +4 -0
- data/config/routes.rb +4 -0
- data/configuration.ini.dist +104 -0
- data/lib/com/wiris/common/WInteger.rb +57 -0
- data/lib/com/wiris/plugin/api/Cas.rb +8 -0
- data/lib/com/wiris/plugin/api/CleanCache.rb +8 -0
- data/lib/com/wiris/plugin/api/Configuration.rb +8 -0
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +96 -0
- data/lib/com/wiris/plugin/api/Editor.rb +8 -0
- data/lib/com/wiris/plugin/api/Filter.rb +8 -0
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +8 -0
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +8 -0
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +79 -0
- data/lib/com/wiris/plugin/api/Render.rb +8 -0
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +8 -0
- data/lib/com/wiris/plugin/api/Test.rb +8 -0
- data/lib/com/wiris/plugin/api/TextService.rb +8 -0
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +8 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +146 -0
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +111 -0
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +176 -0
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +38 -0
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +29 -0
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +86 -0
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +34 -0
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +59 -0
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +144 -0
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +56 -0
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +53 -0
- data/lib/com/wiris/plugin/impl/HttpListener.rb +8 -0
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +73 -0
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +34 -0
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +253 -0
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +280 -0
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +52 -0
- data/lib/com/wiris/plugin/impl/TestImpl.rb +166 -0
- data/lib/com/wiris/plugin/impl/TextFilter.rb +211 -0
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +55 -0
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +118 -0
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +8 -0
- data/lib/com/wiris/util/json/JSon.rb +536 -0
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +21 -0
- data/lib/com/wiris/util/json/StringParser.rb +61 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +18 -0
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +8 -0
- data/lib/com/wiris/util/sys/IniFile.rb +143 -0
- data/lib/com/wiris/util/sys/Store.rb +109 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +20 -0
- data/lib/com/wiris/util/xml/WCharacterBase.rb +634 -0
- data/lib/com/wiris/util/xml/WEntities.rb +14 -0
- data/lib/com/wiris/util/xml/WXmlUtils.rb +515 -0
- data/lib/com/wiris/util/xml/XmlSerializer.rb +485 -0
- data/lib/com/wiris/util/xml/XmlWriter.rb +279 -0
- data/lib/loader.rb +12 -0
- data/lib/src-generic/Array.rb +23 -0
- data/lib/src-generic/ArrayInt.rb +32 -0
- data/lib/src-generic/Base64.rb +15 -0
- data/lib/src-generic/BaseCode.rb +94 -0
- data/lib/src-generic/Bytes.rb +50 -0
- data/lib/src-generic/BytesInput.rb +38 -0
- data/lib/src-generic/EReg.rb +56 -0
- data/lib/src-generic/File.rb +36 -0
- data/lib/src-generic/FileLock.rb +27 -0
- data/lib/src-generic/FileSystem.rb +37 -0
- data/lib/src-generic/Hash.rb +43 -0
- data/lib/src-generic/Http.rb +107 -0
- data/lib/src-generic/HttpRequest.rb +25 -0
- data/lib/src-generic/HttpResponse.rb +71 -0
- data/lib/src-generic/Iterator.rb +20 -0
- data/lib/src-generic/Math.rb +15 -0
- data/lib/src-generic/Md5.rb +8 -0
- data/lib/src-generic/Md5Tools.rb +12 -0
- data/lib/src-generic/PropertiesTools.rb +33 -0
- data/lib/src-generic/Reflect.rb +17 -0
- data/lib/src-generic/RubyConfigurationUpdater.rb +45 -0
- data/lib/src-generic/Serializer.rb +85 -0
- data/lib/src-generic/Std.rb +74 -0
- data/lib/src-generic/Storage.rb +153 -0
- data/lib/src-generic/StringBuf.rb +41 -0
- data/lib/src-generic/StringTools.rb +46 -0
- data/lib/src-generic/Timer.rb +7 -0
- data/lib/src-generic/Type.rb +19 -0
- data/lib/src-generic/TypeTools.rb +32 -0
- data/lib/src-generic/Unserializer.rb +73 -0
- data/lib/src-generic/Utf8.rb +27 -0
- data/lib/src-generic/Xml.rb +199 -0
- data/lib/src-generic/extended/Integer.rb +5 -0
- data/lib/src-generic/extended/Math.rb +7 -0
- data/lib/src-generic/extended/Properties.rb +12 -0
- data/lib/src-generic/extended/String.rb +39 -0
- data/lib/src-generic/settings/PlatformSettings.rb +19 -0
- data/lib/wirispluginengine.rb +5 -0
- data/lib/wirispluginengine/engine.rb +5 -0
- data/lib/wirispluginengine/integration/cleancache.rb +8 -0
- data/lib/wirispluginengine/integration/configurationjs.rb +16 -0
- data/lib/wirispluginengine/integration/configurationjson.rb +7 -0
- data/lib/wirispluginengine/integration/createimage.rb +8 -0
- data/lib/wirispluginengine/integration/getmathml.rb +18 -0
- data/lib/wirispluginengine/integration/resource.rb +8 -0
- data/lib/wirispluginengine/integration/service.rb +6 -0
- data/lib/wirispluginengine/integration/showimage.rb +21 -0
- data/lib/wirispluginengine/integration/test.rb +6 -0
- data/lib/wirispluginengine/version.rb +3 -0
- data/resources/VERSION +1 -0
- data/resources/default-configuration.ini +45 -0
- data/resources/tech.txt +1 -0
- data/resources/wirisplugin.css +43 -0
- metadata +182 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/impl/RenderImpl.rb')
|
5
|
+
require('com/wiris/plugin/api/Cas.rb')
|
6
|
+
class CasImpl
|
7
|
+
extend CasInterface
|
8
|
+
|
9
|
+
include Wiris
|
10
|
+
|
11
|
+
attr_accessor :plugin
|
12
|
+
def initialize(plugin)
|
13
|
+
super()
|
14
|
+
@plugin = plugin
|
15
|
+
end
|
16
|
+
def showCasImage(f,provider)
|
17
|
+
formula = f
|
18
|
+
if formula::endsWith(".png")
|
19
|
+
formula = Std::substr(formula,0,formula::length()-4)
|
20
|
+
end
|
21
|
+
store = plugin::getStorageAndCache()
|
22
|
+
data = store::retreiveData(formula,"png")
|
23
|
+
if data==nil
|
24
|
+
data = Storage::newResourceStorage("cas.png")::readBinary()
|
25
|
+
if data==nil
|
26
|
+
raise Exception,"Missing resource cas.png"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return data
|
30
|
+
end
|
31
|
+
def createCasImage(imageParameter)
|
32
|
+
output = ""
|
33
|
+
contextPath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/")
|
34
|
+
if imageParameter!=nil
|
35
|
+
dataDecoded = self.class.decodeBase64(imageParameter)
|
36
|
+
digest = Md5::encode(imageParameter)
|
37
|
+
store = plugin::getStorageAndCache()
|
38
|
+
store::storeData(digest,"png",dataDecoded::getData())
|
39
|
+
showImagePath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SHOWCASIMAGE_PATH,nil)
|
40
|
+
output+=RenderImpl::concatPath(contextPath,showImagePath)+StringTools::urlEncode(digest+".png").to_s
|
41
|
+
else
|
42
|
+
output+=RenderImpl::concatPath(contextPath,"core/cas.png")
|
43
|
+
end
|
44
|
+
return output
|
45
|
+
end
|
46
|
+
def cas(mode,language)
|
47
|
+
output = StringBuf.new()
|
48
|
+
output::add("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
|
49
|
+
config = plugin::getConfiguration()
|
50
|
+
availableLanguages = getAvailableCASLanguages(config::getProperty(ConfigurationKeys::CAS_LANGUAGES,nil))
|
51
|
+
if (language==nil)||!availableLanguages::contains_(language)
|
52
|
+
language = availableLanguages::_(0)
|
53
|
+
end
|
54
|
+
if (mode!=nil)&&(mode=="applet")
|
55
|
+
codebase = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_CODEBASE,nil),"%LANG",language)
|
56
|
+
archive = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_ARCHIVE,nil),"%LANG",language)
|
57
|
+
className = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_CLASS,nil),"%LANG",language)
|
58
|
+
output::add(printCAS(codebase,archive,className))
|
59
|
+
else
|
60
|
+
output::add(printCASContainer(config,availableLanguages,language))
|
61
|
+
end
|
62
|
+
return output::toString()
|
63
|
+
end
|
64
|
+
def getAvailableCASLanguages(languageString)
|
65
|
+
langs = Std::split(languageString,",")
|
66
|
+
availableLanguages = Array.new()
|
67
|
+
iter = langs::iterator()
|
68
|
+
while iter::hasNext()
|
69
|
+
elem = iter::next()
|
70
|
+
elem = StringTools::trim(elem)
|
71
|
+
availableLanguages::push(elem)
|
72
|
+
end
|
73
|
+
if availableLanguages::length()==0
|
74
|
+
availableLanguages = Array.new()
|
75
|
+
availableLanguages::push("")
|
76
|
+
end
|
77
|
+
return availableLanguages
|
78
|
+
end
|
79
|
+
def printCAS(codebase,archive,className)
|
80
|
+
output = StringBuf.new()
|
81
|
+
output::add("<html><head><style type=\"text/css\">/*<!--*/ html, body { height: 100%; } body { overflow: hidden; margin: 0; } applet { height: 100%; width: 100%; } /*-->*/</style></head>")
|
82
|
+
output::add("<body><applet id=\"applet\" alt=\"WIRIS CAS\" codebase=\"")
|
83
|
+
output::add(htmlentities(codebase,true))
|
84
|
+
output::add("\" archive=\"")
|
85
|
+
output::add(htmlentities(archive,true))
|
86
|
+
output::add("\" code=\"")
|
87
|
+
output::add(htmlentities(className,true))
|
88
|
+
output::add("\"><p>You need JAVA® to use WIRIS tools.<br />FREE download from <a target=\"_blank\" href=\"http://www.java.com\">www.java.com</a></p></applet></body></html>")
|
89
|
+
return output::toString()
|
90
|
+
end
|
91
|
+
def printCASContainer(config,availableLanguages,lang)
|
92
|
+
output = StringBuf.new()
|
93
|
+
output::add("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/><script>")
|
94
|
+
output::add("var lang =\'")
|
95
|
+
output::add(lang)
|
96
|
+
output::add("/strings.js\';")
|
97
|
+
output::add(" ")
|
98
|
+
output::add(" var scriptsrc = window.opener._wrs_conf_path + \'/lang/\' + lang;")
|
99
|
+
output::add(" var script = document.createElement(\'script\'); ")
|
100
|
+
output::add(" script.src = scriptsrc;")
|
101
|
+
output::add(" document.head.appendChild(script);")
|
102
|
+
output::add("</script><script>")
|
103
|
+
output::add("var scriptsrc = window.opener._wrs_conf_path + \'/core/cas.js\'; ")
|
104
|
+
output::add(" var script = document.createElement(\'script\'); ")
|
105
|
+
output::add(" script.src = scriptsrc;")
|
106
|
+
output::add(" document.head.appendChild(script);")
|
107
|
+
output::add("</script>")
|
108
|
+
output::add("<title>WIRIS CAS</title><style type=\"text/css\">")
|
109
|
+
output::add("/*<!--*/ html, body, #optionForm { height: 100%; } body { overflow: hidden; margin: 0; } #controls { width: 100%; } /*-->*/</style></head>")
|
110
|
+
output::add("<body><form id=\"optionForm\"><div id=\"appletContainer\"></div><table id=\"controls\"><tr><td>Width</td><td><input name=\"width\" type=\"text\" value=\"")
|
111
|
+
output::add(config::getProperty(ConfigurationKeys::CAS_WIDTH,nil))
|
112
|
+
output::add("\"/></td><td><input name=\"executeonload\" type=\"checkbox\"/> Calculate on load")
|
113
|
+
output::add("</td><td><input name=\"toolbar\" type=\"checkbox\" checked /> Show toolbar</td><td>Language <select id=\"languageList\">")
|
114
|
+
for i in 0..availableLanguages::length()-1
|
115
|
+
language = htmlentities(availableLanguages::_(i),true)
|
116
|
+
output::add("<option value=\"")
|
117
|
+
output::add(language)
|
118
|
+
output::add("\">")
|
119
|
+
output::add(language)
|
120
|
+
output::add("</option>")
|
121
|
+
i+=1
|
122
|
+
end
|
123
|
+
output::add("</select></td></tr><tr><td>Height</td><td><input name=\"height\" type=\"text\" value=\"")
|
124
|
+
output::add(config::getProperty(ConfigurationKeys::CAS_HEIGHT,nil))
|
125
|
+
output::add("\"/></td><td><input name=\"focusonload\" type=\"checkbox\"/> Focus on load</td><td><input name=\"level\" type=\"checkbox\"/>")
|
126
|
+
output::add("Elementary mode</td><td></td></tr><tr><td colspan=\"5\"><input id=\"submit\" value=\"Accept\" type=\"button\"/>")
|
127
|
+
output::add("<input id=\"cancel\" value=\"Cancel\" type=\"button\"/></td></tr></table></form></body></html>")
|
128
|
+
return output::toString()
|
129
|
+
end
|
130
|
+
def htmlentities(input,entQuotes)
|
131
|
+
returnValue = StringTools::replace(input,"&","&")
|
132
|
+
returnValue = StringTools::replace(returnValue,"<","<")
|
133
|
+
returnValue = StringTools::replace(returnValue,">","gt;")
|
134
|
+
if entQuotes
|
135
|
+
returnValue = StringTools::replace(returnValue,"\"",""")
|
136
|
+
return returnValue
|
137
|
+
end
|
138
|
+
return returnValue
|
139
|
+
end
|
140
|
+
def self.decodeBase64(imageParameter)
|
141
|
+
b = Base64.new()
|
142
|
+
dataDecoded = b::decodeBytes(Bytes::ofString(imageParameter))
|
143
|
+
return dataDecoded
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/util/json/JSon.rb')
|
5
|
+
require('com/wiris/plugin/api/CleanCache.rb')
|
6
|
+
class CleanCacheImpl
|
7
|
+
extend CleanCacheInterface
|
8
|
+
|
9
|
+
include Wiris
|
10
|
+
|
11
|
+
attr_accessor :plugin
|
12
|
+
attr_accessor :token
|
13
|
+
attr_accessor :newToken
|
14
|
+
attr_accessor :wirisCleanCacheToken
|
15
|
+
attr_accessor :validToken
|
16
|
+
attr_accessor :accept
|
17
|
+
attr_accessor :gui
|
18
|
+
attr_accessor :storage
|
19
|
+
attr_accessor :cleanCachePath
|
20
|
+
attr_accessor :resourcePath
|
21
|
+
def initialize(pb)
|
22
|
+
super()
|
23
|
+
@plugin = pb
|
24
|
+
end
|
25
|
+
def init(param)
|
26
|
+
@storage = @plugin::getStorageAndCache()
|
27
|
+
@token = param::getParameter("token",nil)
|
28
|
+
@newToken = param::getParameter("newtoken",nil)
|
29
|
+
@wirisCleanCacheToken = @plugin::getConfiguration()::getProperty(ConfigurationKeys::CLEAN_CACHE_TOKEN,nil)
|
30
|
+
@accept = (param::getParameter("accept",nil)!=nil)&&(param::getParameter("accept","")=="application/json") ? true : false
|
31
|
+
@gui = isGui()
|
32
|
+
@validToken = validateToken(@wirisCleanCacheToken,@token)
|
33
|
+
@cleanCachePath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::CLEAN_CACHE_PATH,"")
|
34
|
+
@resourcePath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::RESOURCE_PATH,"")
|
35
|
+
if (@token!=nil)&&@validToken
|
36
|
+
deleteCache()
|
37
|
+
end
|
38
|
+
end
|
39
|
+
def deleteCache()
|
40
|
+
@storage::deleteCache()
|
41
|
+
end
|
42
|
+
def getCacheOutput()
|
43
|
+
if @gui
|
44
|
+
output = ""
|
45
|
+
output+="<html><head>\r\n"
|
46
|
+
output+="<title>WIRIS plugin clean cache service</title><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\r\n"
|
47
|
+
output+=("<link rel=stylesheet type=text/css href="+@resourcePath)+"?resourcefile=wirisplugin.css />"
|
48
|
+
output+="</head>"
|
49
|
+
output+="<div class=wirismaincontainer>"
|
50
|
+
output+="<body class=wirisplugincleancache>"
|
51
|
+
output+="<h2 class=wirisplugincleancache>WIRIS plugin clean cache service</h2>\r\n"
|
52
|
+
output+="<div class=wirisplugincleancacheform>"
|
53
|
+
if @wirisCleanCacheToken!=nil
|
54
|
+
output+=("<form action="+@cleanCachePath)+" method=post>"
|
55
|
+
output+="<span class=wirisplugincleancachetextform> Security token </span><input type=password autocomplete=off name=token>"
|
56
|
+
output+="<input type=\"submit\" value=\"Submit\">"
|
57
|
+
output+="</form>"
|
58
|
+
end
|
59
|
+
output+=("<form action="+@cleanCachePath)+" method=post>"
|
60
|
+
output+="<span class=wirisplugincleancachetextform> Generate token </span> <input type=text name=newtoken>"
|
61
|
+
output+="<input type=\"submit\" value=\"Submit\">"
|
62
|
+
output+="</form>"
|
63
|
+
output+="</div>"
|
64
|
+
output+="<div class=wirisplugincleancacheresults>"
|
65
|
+
if (@token!=nil)&&!@validToken
|
66
|
+
output+="<span class=wirisplugincleancachewarning> Invalid Token </span>"
|
67
|
+
else
|
68
|
+
if @validToken&&(@token!=nil)
|
69
|
+
output+="<span class=wirisplugincleancachewarning> Cache deleted successfully </span>"
|
70
|
+
else
|
71
|
+
if @newToken!=nil
|
72
|
+
output+=" Your new token is: <br>"
|
73
|
+
output+=("<span class=wirisplugincleancachewarning>"+Md5::encode(@newToken).to_s)+"</span> <br>"
|
74
|
+
output+=" Please copy it to your configuration.ini file <br>"
|
75
|
+
output+=" For more information see <a href=http://www.wiris.com/plugins/docs/resources/configuration-table style=text-decoration:none>Server configuration file documentation</a>"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
output+="</div>"
|
80
|
+
output+="</div>"
|
81
|
+
return output
|
82
|
+
else
|
83
|
+
jsonOutput = Hash.new()
|
84
|
+
if !@validToken
|
85
|
+
jsonOutput::set("status","error")
|
86
|
+
else
|
87
|
+
jsonOutput::set("status","ok")
|
88
|
+
end
|
89
|
+
return JSon::encode(jsonOutput)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
def getContentType()
|
93
|
+
if !@gui
|
94
|
+
return "application/json"
|
95
|
+
else
|
96
|
+
return "text/html charset=UTF-8"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
def validateToken(md5Token,token)
|
100
|
+
if (token!=nil)&&(md5Token!=nil)
|
101
|
+
return (md5Token==Md5Tools::encodeString(token))
|
102
|
+
else
|
103
|
+
return false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
def isGui()
|
107
|
+
wirisCacheGui = (@plugin::getConfiguration()::getProperty(ConfigurationKeys::CLEAN_CACHE_GUI,"false")=="true")
|
108
|
+
return wirisCacheGui&&!@accept
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/impl/CustomConfigurationUpdater.rb')
|
5
|
+
require('com/wiris/util/json/JSon.rb')
|
6
|
+
require('com/wiris/plugin/impl/FileConfigurationUpdater.rb')
|
7
|
+
require('com/wiris/plugin/api/Configuration.rb')
|
8
|
+
class ConfigurationImpl
|
9
|
+
extend ConfigurationInterface
|
10
|
+
|
11
|
+
include Wiris
|
12
|
+
|
13
|
+
attr_accessor :plugin
|
14
|
+
attr_accessor :initObject
|
15
|
+
attr_accessor :props
|
16
|
+
attr_accessor :initialized
|
17
|
+
def initialize()
|
18
|
+
super()
|
19
|
+
@props = PropertiesTools::newProperties()
|
20
|
+
end
|
21
|
+
def getFullConfiguration()
|
22
|
+
initialize0()
|
23
|
+
return @props
|
24
|
+
end
|
25
|
+
def getFullConfigurationAsJson()
|
26
|
+
initialize0()
|
27
|
+
return nil
|
28
|
+
end
|
29
|
+
def getProperty(key,dflt)
|
30
|
+
initialize0()
|
31
|
+
return PropertiesTools::getProperty(@props,key,dflt)
|
32
|
+
end
|
33
|
+
def setProperty(key,value)
|
34
|
+
PropertiesTools::setProperty(@props,key,value)
|
35
|
+
end
|
36
|
+
def setInitObject(context)
|
37
|
+
@initObject = context
|
38
|
+
end
|
39
|
+
def initialize0()
|
40
|
+
if @initialized
|
41
|
+
return
|
42
|
+
end
|
43
|
+
@initialized = true
|
44
|
+
@plugin::addConfigurationUpdater(FileConfigurationUpdater.new())
|
45
|
+
@plugin::addConfigurationUpdater(CustomConfigurationUpdater.new(self))
|
46
|
+
a = @plugin::getConfigurationUpdaterChain()
|
47
|
+
iter = a::iterator()
|
48
|
+
while iter::hasNext()
|
49
|
+
cu = iter::next()
|
50
|
+
initialize_(cu)
|
51
|
+
cu::updateConfiguration(@props)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
def initialize_(cu)
|
55
|
+
cu::init(@initObject)
|
56
|
+
end
|
57
|
+
def setPluginBuilderImpl(plugin)
|
58
|
+
@plugin = plugin
|
59
|
+
end
|
60
|
+
def appendVarJs(sb,varName,value,comment)
|
61
|
+
sb::add("var ")
|
62
|
+
sb::add(varName)
|
63
|
+
sb::add(" = ")
|
64
|
+
sb::add(value)
|
65
|
+
sb::add("; // ")
|
66
|
+
sb::add(comment)
|
67
|
+
sb::add("\r\n")
|
68
|
+
end
|
69
|
+
def appendElement2JavascriptArray(array,value)
|
70
|
+
arrayOpen = array::indexOf("[")
|
71
|
+
arrayClose = array::indexOf("]")
|
72
|
+
if (arrayOpen==-1)||(arrayClose==-1)
|
73
|
+
raise Exception,"Array not valid"
|
74
|
+
end
|
75
|
+
return ((("["+"\'")+value)+"\'")+(array::length()==2 ? "]" : ","+Std::substr(array,arrayOpen+1,arrayClose-arrayOpen).to_s)
|
76
|
+
end
|
77
|
+
def getJavaScriptConfiguration()
|
78
|
+
sb = StringBuf.new()
|
79
|
+
arrayParse = "[]"
|
80
|
+
appendVarJs(sb,"_wrs_conf_editorEnabled",getProperty("wiriseditorenabled",nil),"Specifies if fomula editor is enabled")
|
81
|
+
appendVarJs(sb,"_wrs_conf_imageMathmlAttribute",("\'"+getProperty("wiriseditormathmlattribute",nil))+"\'","Specifies the image tag where we should save the formula editor mathml code")
|
82
|
+
appendVarJs(sb,"_wrs_conf_saveMode",("\'"+getProperty("wiriseditorsavemode",nil))+"\'","This value can be \'xml\', \'safeXml\', \'image\' or \'base64\'")
|
83
|
+
appendVarJs(sb,"_wrs_conf_editMode",("\'"+getProperty("wiriseditoreditmode",nil))+"\'","This value can be \'default\' or \'image\'")
|
84
|
+
if (getProperty("wiriseditorparselatex",nil)=="true")
|
85
|
+
arrayParse = appendElement2JavascriptArray(arrayParse,"latex")
|
86
|
+
end
|
87
|
+
if (getProperty("wiriseditorparsexml",nil)=="true")
|
88
|
+
arrayParse = appendElement2JavascriptArray(arrayParse,"xml")
|
89
|
+
end
|
90
|
+
appendVarJs(sb,"_wrs_conf_parseModes",arrayParse,"This value can contain \'latex\' and \'xml)")
|
91
|
+
appendVarJs(sb,"_wrs_conf_editorAttributes",("\'"+getProperty("wiriseditorwindowattributes",nil))+"\'","Specifies formula editor window options")
|
92
|
+
appendVarJs(sb,"_wrs_conf_editorUrl",("\'"+@plugin::getImageServiceURL("editor",false))+"\'","WIRIS editor")
|
93
|
+
appendVarJs(sb,"_wrs_conf_modalWindow",getProperty("wiriseditormodalwindow",nil),"Editor modal window")
|
94
|
+
appendVarJs(sb,"_wrs_conf_CASEnabled",getProperty("wiriscasenabled",nil),"Specifies if WIRIS cas is enabled")
|
95
|
+
appendVarJs(sb,"_wrs_conf_CASMathmlAttribute",("\'"+getProperty("wiriscasmathmlattribute",nil))+"\'","Specifies the image tag where we should save the WIRIS cas mathml code")
|
96
|
+
appendVarJs(sb,"_wrs_conf_CASAttributes",("\'"+getProperty("wiriscaswindowattributes",nil))+"\'","Specifies WIRIS cas window options")
|
97
|
+
appendVarJs(sb,"_wrs_conf_hostPlatform",("\'"+getProperty("wirishostplatform",nil))+"\'","Specifies host platform")
|
98
|
+
appendVarJs(sb,"_wrs_conf_versionPlatform",("\'"+getProperty("wirisversionplatform","unknown"))+"\'","Specifies host version platform")
|
99
|
+
appendVarJs(sb,"_wrs_conf_enableAccessibility",getProperty("wirisaccessibilityenabled",nil),"Specifies whether accessibility is enabled")
|
100
|
+
appendVarJs(sb,"_wrs_conf_setSize",getProperty("wiriseditorsetsize",nil),"Specifies whether to set the size of the images at edition time")
|
101
|
+
appendVarJs(sb,"_wrs_conf_editorToolbar",("\'"+getProperty(ConfigurationKeys::EDITOR_TOOLBAR,nil))+"\'","Toolbar definition")
|
102
|
+
appendVarJs(sb,"_wrs_conf_chemEnabled",getProperty("wirischemeditorenabled",nil),"Specifies if WIRIS chem editor is enabled")
|
103
|
+
appendVarJs(sb,"_wrs_conf_imageFormat",("\'"+getProperty("wirisimageformat","png"))+"\'","WIRIS Plugin image format")
|
104
|
+
if getProperty(ConfigurationKeys::EDITOR_PARAMS,nil)!=nil
|
105
|
+
appendVarJs(sb,"_wrs_conf_editorParameters",getProperty(ConfigurationKeys::EDITOR_PARAMS,nil),"Editor parameters")
|
106
|
+
else
|
107
|
+
h = ConfigurationKeys::imageConfigPropertiesInv
|
108
|
+
attributes = StringBuf.new()
|
109
|
+
confVal = ""
|
110
|
+
i = 0
|
111
|
+
it = h::keys()
|
112
|
+
while it::hasNext()
|
113
|
+
value = it::next()
|
114
|
+
if getProperty(value,nil)!=nil
|
115
|
+
if i!=0
|
116
|
+
attributes::add(",")
|
117
|
+
end
|
118
|
+
i+=1
|
119
|
+
confVal = getProperty(value,nil)
|
120
|
+
StringTools::replace(confVal,"-","_")
|
121
|
+
StringTools::replace(confVal,"-","_")
|
122
|
+
attributes::add("\'")
|
123
|
+
attributes::add(ConfigurationKeys::imageConfigPropertiesInv::get(value))
|
124
|
+
attributes::add("\' : \'")
|
125
|
+
attributes::add(confVal)
|
126
|
+
attributes::add("\'")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
appendVarJs(sb,"_wrs_conf_editorParameters",("{"+attributes::toString().to_s)+"}","Editor parameters")
|
130
|
+
end
|
131
|
+
appendVarJs(sb,"_wrs_conf_wirisPluginPerformance",getProperty("wirispluginperformance",nil),"Experimental settings to improve performance")
|
132
|
+
sb::add("var _wrs_conf_configuration_loaded = true;\r\n")
|
133
|
+
sb::add("if (typeof _wrs_conf_core_loaded != \'undefined\') _wrs_conf_plugin_loaded = true;\r\n")
|
134
|
+
begin
|
135
|
+
version = Storage::newResourceStorage("VERSION")::read()
|
136
|
+
end
|
137
|
+
sb::add(("var _wrs_conf_version = \'"+version)+"\';\r\n")
|
138
|
+
return sb::toString()
|
139
|
+
end
|
140
|
+
def getJsonConfiguration(configurationKeys)
|
141
|
+
configurationKeysArray = Std::split(configurationKeys,",")
|
142
|
+
iterator = configurationKeysArray::iterator()
|
143
|
+
jsonOutput = Hash.new()
|
144
|
+
jsonVariables = Hash.new()
|
145
|
+
thereIsNullValue = false
|
146
|
+
while iterator::hasNext()
|
147
|
+
key = iterator::next()
|
148
|
+
value = getProperty(key,"null")
|
149
|
+
if (value=="null")
|
150
|
+
thereIsNullValue = true
|
151
|
+
end
|
152
|
+
jsonVariables::set(key,value)
|
153
|
+
end
|
154
|
+
if !thereIsNullValue
|
155
|
+
jsonOutput::set("status","ok")
|
156
|
+
else
|
157
|
+
jsonOutput::set("status","warning")
|
158
|
+
end
|
159
|
+
jsonOutput::set("result",jsonVariables)
|
160
|
+
return JSon::encode(jsonOutput)
|
161
|
+
end
|
162
|
+
def setConfigurations(configurationKeys,configurationValues)
|
163
|
+
configurationKeysArray = Std::split(configurationKeys,",")
|
164
|
+
configurationValuesArray = Std::split(configurationValues,",")
|
165
|
+
keysIterator = configurationKeysArray::iterator()
|
166
|
+
valuesIterator = configurationValuesArray::iterator()
|
167
|
+
while keysIterator::hasNext()&&valuesIterator::hasNext()
|
168
|
+
key = keysIterator::next()
|
169
|
+
value = valuesIterator::next()
|
170
|
+
if getProperty(key,nil)!=nil
|
171
|
+
setProperty(key,value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|