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,38 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/configuration/ConfigurationUpdater.rb')
|
5
|
+
class CustomConfigurationUpdater
|
6
|
+
extend ConfigurationUpdaterInterface
|
7
|
+
|
8
|
+
include Wiris
|
9
|
+
|
10
|
+
attr_accessor :config
|
11
|
+
def initialize(config)
|
12
|
+
super()
|
13
|
+
@config = config
|
14
|
+
end
|
15
|
+
def init(obj)
|
16
|
+
end
|
17
|
+
def updateConfiguration(ref_configuration)
|
18
|
+
configuration = ref_configuration
|
19
|
+
confClass = PropertiesTools::getProperty(configuration,ConfigurationKeys::CONFIGURATION_CLASS)
|
20
|
+
if (confClass!=nil)&&(confClass::indexOf("com.wiris.plugin.servlets.configuration.ParameterServletConfigurationUpdater")!=-1)
|
21
|
+
return
|
22
|
+
end
|
23
|
+
if confClass!=nil
|
24
|
+
cls = Type::resolveClass(confClass)
|
25
|
+
if cls==nil
|
26
|
+
raise Exception,("Class "+confClass)+" not found."
|
27
|
+
end
|
28
|
+
obj = Type::createInstance(cls,Array.new())
|
29
|
+
if obj==nil
|
30
|
+
raise Exception,("Instance from "+cls.to_s)+" cannot be created."
|
31
|
+
end
|
32
|
+
cu = (obj)
|
33
|
+
@config::initialize_(cu)
|
34
|
+
cu::updateConfiguration(configuration)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/sys/IniFile.rb')
|
4
|
+
require('com/wiris/plugin/configuration/ConfigurationUpdater.rb')
|
5
|
+
class DefaultConfigurationUpdater
|
6
|
+
extend ConfigurationUpdaterInterface
|
7
|
+
|
8
|
+
include Wiris
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
super()
|
12
|
+
end
|
13
|
+
def init(obj)
|
14
|
+
end
|
15
|
+
def updateConfiguration(ref_configuration)
|
16
|
+
configuration = ref_configuration
|
17
|
+
s = Storage::newResourceStorage("default-configuration.ini")::read()
|
18
|
+
defaultIniFile = IniFile::newIniFileFromString(s)
|
19
|
+
h = defaultIniFile::getProperties()
|
20
|
+
iter = h::keys()
|
21
|
+
while iter::hasNext()
|
22
|
+
key = iter::next()
|
23
|
+
if PropertiesTools::getProperty(configuration,key)==nil
|
24
|
+
PropertiesTools::setProperty(configuration,key,h::get(key))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/api/Editor.rb')
|
5
|
+
class EditorImpl
|
6
|
+
extend EditorInterface
|
7
|
+
|
8
|
+
include Wiris
|
9
|
+
|
10
|
+
attr_accessor :plugin
|
11
|
+
def initialize(plugin)
|
12
|
+
super()
|
13
|
+
@plugin = plugin
|
14
|
+
end
|
15
|
+
def editor(language,provider)
|
16
|
+
output = StringBuf.new()
|
17
|
+
if (language==nil)||(language::length()==0)
|
18
|
+
language = "en"
|
19
|
+
end
|
20
|
+
language = language::toLowerCase()
|
21
|
+
StringTools::replace(language,"-","_")
|
22
|
+
store = Storage::newResourceStorage(("lang/"+language)+"/strings.js")
|
23
|
+
if !store::exists()
|
24
|
+
store = Storage::newResourceStorage(("lang/"+Std::substr(language,0,2).to_s)+"/strings.js")
|
25
|
+
language = Std::substr(language,0,2)
|
26
|
+
if !store::exists()
|
27
|
+
language = "en"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
attributes = StringBuf.new()
|
31
|
+
attributes::add("")
|
32
|
+
confVal = ""
|
33
|
+
i = 0
|
34
|
+
config = @plugin::getConfiguration()
|
35
|
+
h = ConfigurationKeys::imageConfigPropertiesInv
|
36
|
+
it = h::keys()
|
37
|
+
while it::hasNext()
|
38
|
+
value = it::next()
|
39
|
+
if config::getProperty(value,nil)!=nil
|
40
|
+
if i!=0
|
41
|
+
attributes::add(",")
|
42
|
+
end
|
43
|
+
i+=1
|
44
|
+
confVal = config::getProperty(value,nil)
|
45
|
+
StringTools::replace(confVal,"-","_")
|
46
|
+
StringTools::replace(confVal,"-","_")
|
47
|
+
attributes::add("\'")
|
48
|
+
attributes::add(ConfigurationKeys::imageConfigPropertiesInv::get(value))
|
49
|
+
attributes::add("\' : \'")
|
50
|
+
attributes::add(confVal)
|
51
|
+
attributes::add("\'")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
script = StringBuf.new()
|
55
|
+
if i>0
|
56
|
+
script::add("<script type=\"text/javascript\">window.wrs_attributes = {")
|
57
|
+
script::add(attributes)
|
58
|
+
script::add("};</script>")
|
59
|
+
end
|
60
|
+
editorUrl = @plugin::getImageServiceURL("editor",false)
|
61
|
+
isSegure = (provider::getParameter("secure","false")=="true")
|
62
|
+
if editorUrl::startsWith("http:")&&isSegure
|
63
|
+
editorUrl = "https:"+Std::substr(editorUrl,5).to_s
|
64
|
+
end
|
65
|
+
addLine(output,"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
|
66
|
+
addLine(output,"<html><head>")
|
67
|
+
addLine(output,"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/>")
|
68
|
+
addLine(output,script::toString())
|
69
|
+
addLine(output,((("<script type=\"text/javascript\" src=\""+editorUrl)+"?lang=")+StringTools::urlEncode(language).to_s)+"\"></script>")
|
70
|
+
addLine(output,"<script type=\"text/javascript\" src=\"../core/editor.js\"></script>")
|
71
|
+
addLine(output,("<script type=\"text/javascript\" src=\"../lang/"+StringTools::urlEncode(language).to_s)+"/strings.js\"></script>")
|
72
|
+
addLine(output,"<title>WIRIS editor</title>")
|
73
|
+
addLine(output,"<style type=\"text/css\">/*<!--*/html, body, #container { height: 100%; } body { margin: 0; }")
|
74
|
+
addLine(output,"#links { text-align: right; margin-right: 20px; } #links_rtl {text-align: left; margin-left: 20px;} #controls { float: left; } #controls_rtl {float: right;}/*-->*/</style>")
|
75
|
+
addLine(output,"</head><body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">")
|
76
|
+
addLine(output,"<div id=\"container\"><div id=\"editorContainer\"></div><div id=\"controls\"></div>")
|
77
|
+
addLine(output,"<div id=\"links\"><a href=\"http://www.wiris.com/editor3/docs/manual/latex-support\" id=\"a_latex\" target=\"_blank\">LaTeX</a> | ")
|
78
|
+
addLine(output,"<a href=\"http://www.wiris.com/editor3/docs/manual\" target=\"_blank\" id=\"a_manual\">Manual</a></div></div></body>")
|
79
|
+
return output::toString()
|
80
|
+
end
|
81
|
+
def addLine(output,s)
|
82
|
+
output::add(s)
|
83
|
+
output::add("\r\n")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/util/sys/IniFile.rb')
|
5
|
+
require('com/wiris/plugin/configuration/ConfigurationUpdater.rb')
|
6
|
+
class FileConfigurationUpdater
|
7
|
+
extend ConfigurationUpdaterInterface
|
8
|
+
|
9
|
+
include Wiris
|
10
|
+
|
11
|
+
def initialize()
|
12
|
+
super()
|
13
|
+
end
|
14
|
+
def init(obj)
|
15
|
+
end
|
16
|
+
def updateConfiguration(ref_configuration)
|
17
|
+
configuration = ref_configuration
|
18
|
+
confDir = PropertiesTools::getProperty(configuration,ConfigurationKeys::CONFIGURATION_PATH)
|
19
|
+
if confDir!=nil
|
20
|
+
confFile = confDir+"/configuration.ini"
|
21
|
+
s = Storage::newStorage(confFile)
|
22
|
+
if s::exists()
|
23
|
+
defaultIniFile = IniFile::newIniFileFromFilename(confFile)
|
24
|
+
h = defaultIniFile::getProperties()
|
25
|
+
iter = h::keys()
|
26
|
+
while iter::hasNext()
|
27
|
+
key = iter::next()
|
28
|
+
PropertiesTools::setProperty(configuration,key,h::get(key))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/util/sys/Store.rb')
|
5
|
+
require('com/wiris/plugin/storage/StorageAndCache.rb')
|
6
|
+
class FileStorageAndCache
|
7
|
+
extend StorageAndCacheInterface
|
8
|
+
|
9
|
+
include Wiris
|
10
|
+
|
11
|
+
attr_accessor :config
|
12
|
+
def initialize()
|
13
|
+
super()
|
14
|
+
end
|
15
|
+
def init(obj,config)
|
16
|
+
@config = config
|
17
|
+
end
|
18
|
+
def codeDigest(content)
|
19
|
+
formula = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
|
20
|
+
digest = Md5Tools::encodeString(content)
|
21
|
+
store = Store::newStoreWithParent(Store::newStore(formula),digest+".ini")
|
22
|
+
store::write(content)
|
23
|
+
return digest
|
24
|
+
end
|
25
|
+
def decodeDigest(digest)
|
26
|
+
formula = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
|
27
|
+
store = Store::newStoreWithParent(Store::newStore(formula),digest+".ini")
|
28
|
+
return store::read()
|
29
|
+
end
|
30
|
+
def retreiveData(digest,service)
|
31
|
+
formula = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
32
|
+
store = Store::newStoreWithParent(Store::newStore(formula),digest+getExtension(service))
|
33
|
+
if !store::exists()
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
return store::readBinary()::getData()
|
37
|
+
end
|
38
|
+
def storeData(digest,service,stream)
|
39
|
+
formula = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
40
|
+
store = Store::newStoreWithParent(Store::newStore(formula),digest+getExtension(service))
|
41
|
+
store::writeBinary(Bytes::ofData(stream))
|
42
|
+
end
|
43
|
+
def getAndCheckFolder(key)
|
44
|
+
folder = PropertiesTools::getProperty(@config,key)
|
45
|
+
if (folder==nil)||(folder::trim()::length()==0)
|
46
|
+
raise Exception,"Missing configuration value: "+key
|
47
|
+
end
|
48
|
+
return folder
|
49
|
+
end
|
50
|
+
def getExtension(service)
|
51
|
+
if (service=="png")
|
52
|
+
return ".png"
|
53
|
+
end
|
54
|
+
return ("."+service)+".txt"
|
55
|
+
end
|
56
|
+
def deleteCache()
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/util/sys/Store.rb')
|
5
|
+
require('com/wiris/plugin/storage/StorageAndCache.rb')
|
6
|
+
class FolderTreeStorageAndCache
|
7
|
+
extend StorageAndCacheInterface
|
8
|
+
|
9
|
+
include Wiris
|
10
|
+
|
11
|
+
attr_accessor :config
|
12
|
+
@@backwards_compat = true
|
13
|
+
def self.backwards_compat
|
14
|
+
@@backwards_compat
|
15
|
+
end
|
16
|
+
def self.backwards_compat=(backwards_compat)
|
17
|
+
@@backwards_compat = backwards_compat
|
18
|
+
end
|
19
|
+
def initialize()
|
20
|
+
super()
|
21
|
+
end
|
22
|
+
def init(obj,config)
|
23
|
+
@config = config
|
24
|
+
end
|
25
|
+
def codeDigest(content)
|
26
|
+
digest = Md5Tools::encodeString(content)
|
27
|
+
parent = getFolderStore(getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER),digest)
|
28
|
+
parent::mkdirs()
|
29
|
+
store = getFileStoreWithParent(parent,digest,"ini")
|
30
|
+
store::write(content)
|
31
|
+
return digest
|
32
|
+
end
|
33
|
+
def decodeDigest(digest)
|
34
|
+
formula = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
|
35
|
+
store = getFileStore(formula,digest,"ini")
|
36
|
+
if @@backwards_compat
|
37
|
+
if !store::exists()
|
38
|
+
oldstore = Store::newStore(((formula+"/")+digest)+".ini")
|
39
|
+
parent = store::getParent()
|
40
|
+
parent::mkdirs()
|
41
|
+
oldstore::moveTo(store)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
return store::read()
|
45
|
+
end
|
46
|
+
def retreiveData(digest,service)
|
47
|
+
formula = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
48
|
+
store = getFileStore(formula,digest,getExtension(service))
|
49
|
+
if @@backwards_compat
|
50
|
+
if !store::exists()
|
51
|
+
oldstore = Store::newStore((((formula+"/")+digest)+".")+getExtension(service))
|
52
|
+
if !oldstore::exists()
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
parent = store::getParent()
|
56
|
+
parent::mkdirs()
|
57
|
+
oldstore::moveTo(store)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
if !store::exists()
|
61
|
+
return nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
return store::readBinary()::getData()
|
65
|
+
end
|
66
|
+
def storeData(digest,service,stream)
|
67
|
+
formula = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
68
|
+
parent = getFolderStore(formula,digest)
|
69
|
+
parent::mkdirs()
|
70
|
+
store = getFileStoreWithParent(parent,digest,getExtension(service))
|
71
|
+
store::writeBinary(Bytes::ofData(stream))
|
72
|
+
end
|
73
|
+
def getAndCheckFolder(key)
|
74
|
+
folder = PropertiesTools::getProperty(@config,key)
|
75
|
+
if (folder==nil)||(folder::trim()::length()==0)
|
76
|
+
raise Exception,"Missing configuration value: "+key
|
77
|
+
end
|
78
|
+
return folder
|
79
|
+
end
|
80
|
+
def getExtension(service)
|
81
|
+
if (service=="png")
|
82
|
+
return "png"
|
83
|
+
end
|
84
|
+
if (service=="svg")
|
85
|
+
return "svg"
|
86
|
+
end
|
87
|
+
return service+".txt"
|
88
|
+
end
|
89
|
+
def getFolderStore(dir,digest)
|
90
|
+
return Store::newStore((((dir+"/")+Std::substr(digest,0,2).to_s)+"/")+Std::substr(digest,2,2).to_s)
|
91
|
+
end
|
92
|
+
def getFileStoreWithParent(parent,digest,extension)
|
93
|
+
return Store::newStoreWithParent(parent,(Std::substr(digest,4).to_s+".")+extension)
|
94
|
+
end
|
95
|
+
def getFileStore(dir,digest,extension)
|
96
|
+
return getFileStoreWithParent(getFolderStore(dir,digest),digest,extension)
|
97
|
+
end
|
98
|
+
def updateFoldersStructure()
|
99
|
+
updateFolderStructure(getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER))
|
100
|
+
updateFolderStructure(getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER))
|
101
|
+
end
|
102
|
+
def updateFolderStructure(dir)
|
103
|
+
folder = Store::newStore(dir)
|
104
|
+
files = folder::list()
|
105
|
+
if files!=nil
|
106
|
+
for i in 0..files::length-1
|
107
|
+
digest = isFormulaFileName(files[i])
|
108
|
+
if digest!=nil
|
109
|
+
newFolder = getFolderStore(dir,digest)
|
110
|
+
newFolder::mkdirs()
|
111
|
+
newFile = getFileStoreWithParent(newFolder,digest,Std::substr(files[i],files[i]::indexOf(".")+1))
|
112
|
+
file = Store::newStoreWithParent(folder,files[i])
|
113
|
+
file::moveTo(newFile)
|
114
|
+
end
|
115
|
+
i+=1
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
def isFormulaFileName(name)
|
120
|
+
i = name::indexOf(".")
|
121
|
+
if i==-1
|
122
|
+
return nil
|
123
|
+
end
|
124
|
+
digest = Std::substr(name,0,i)
|
125
|
+
if digest::length()!=32
|
126
|
+
return nil
|
127
|
+
end
|
128
|
+
return digest
|
129
|
+
end
|
130
|
+
def deleteCache()
|
131
|
+
formulaFolder = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
|
132
|
+
cacheFolder = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
133
|
+
includes = Array.new()
|
134
|
+
includes::push("png")
|
135
|
+
includes::push("csv")
|
136
|
+
includes::push("txt")
|
137
|
+
if !(PropertiesTools::getProperty(@config,ConfigurationKeys::SAVE_MODE,"xml")=="image")
|
138
|
+
includes::push("ini")
|
139
|
+
end
|
140
|
+
Store::deleteDirectory(formulaFolder,includes)
|
141
|
+
Store::deleteDirectory(cacheFolder,includes)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/api/ParamsProvider.rb')
|
5
|
+
class GenericParamsProviderImpl
|
6
|
+
extend ParamsProviderInterface
|
7
|
+
|
8
|
+
include Wiris
|
9
|
+
|
10
|
+
attr_accessor :properties
|
11
|
+
def initialize(properties)
|
12
|
+
super()
|
13
|
+
@properties = properties
|
14
|
+
end
|
15
|
+
def getParameter(param,dflt)
|
16
|
+
return PropertiesTools::getProperty(@properties,param,dflt)
|
17
|
+
end
|
18
|
+
def getRequiredParameter(param)
|
19
|
+
parameter = PropertiesTools::getProperty(@properties,param,nil)
|
20
|
+
if parameter!=nil
|
21
|
+
return parameter
|
22
|
+
else
|
23
|
+
raise Exception,("Error: parameter"+param)+"is required"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def getParameters()
|
27
|
+
return @properties
|
28
|
+
end
|
29
|
+
def getRenderParameters(configuration)
|
30
|
+
renderParams = PropertiesTools::newProperties()
|
31
|
+
renderParameterList = configuration::getProperty(ConfigurationKeys::EDITOR_PARAMETERS_LIST,ConfigurationKeys::EDITOR_PARAMETERS_DEFAULT_LIST)::split(",")
|
32
|
+
for i in 0..renderParameterList::length-1
|
33
|
+
key = renderParameterList[i]
|
34
|
+
value = PropertiesTools::getProperty(@properties,key)
|
35
|
+
if value!=nil
|
36
|
+
PropertiesTools::setProperty(renderParams,key,value)
|
37
|
+
end
|
38
|
+
i+=1
|
39
|
+
end
|
40
|
+
return renderParams
|
41
|
+
end
|
42
|
+
def getServiceParameters()
|
43
|
+
serviceParams = PropertiesTools::newProperties()
|
44
|
+
serviceParamListArray = Std::split(ConfigurationKeys::SERVICES_PARAMETERS_LIST,",")
|
45
|
+
for i in 0..serviceParamListArray::length()-1
|
46
|
+
key = serviceParamListArray::_(i)
|
47
|
+
value = PropertiesTools::getProperty(@properties,key)
|
48
|
+
if value!=nil
|
49
|
+
PropertiesTools::setProperty(serviceParams,key,value)
|
50
|
+
end
|
51
|
+
i+=1
|
52
|
+
end
|
53
|
+
return serviceParams
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|