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,79 +1,93 @@
|
|
1
1
|
module WirisPlugin
|
2
2
|
include Wiris
|
3
|
-
require('com/wiris/plugin/impl/PluginBuilderImpl.rb')
|
4
|
-
|
5
|
-
|
3
|
+
require('com/wiris/plugin/impl/PluginBuilderImpl.rb')
|
4
|
+
class PluginBuilder
|
5
|
+
include Wiris
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
7
|
+
@@pb;
|
8
|
+
def self.pb
|
9
|
+
@@pb
|
10
|
+
end
|
11
|
+
def self.pb=(pb)
|
12
|
+
@@pb = pb
|
13
|
+
end
|
14
|
+
def initialize()
|
15
|
+
super()
|
16
|
+
end
|
17
|
+
def self.getInstance()
|
18
|
+
if PluginBuilder::pb == nil
|
19
|
+
PluginBuilder::pb = PluginBuilderImpl.new()
|
20
|
+
end
|
21
|
+
return PluginBuilder::pb
|
22
|
+
end
|
23
|
+
def self.newInstance()
|
24
|
+
return PluginBuilderImpl.new()
|
25
|
+
end
|
26
|
+
def addConfigurationUpdater(conf)
|
27
|
+
end
|
28
|
+
def setStorageAndCache(store)
|
29
|
+
end
|
30
|
+
def newRender()
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
def newAsyncRender()
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
def newTextService()
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
def newAsyncTextService()
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
def getConfiguration()
|
43
|
+
return nil
|
44
|
+
end
|
45
|
+
def getStorageAndCache()
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
def setStorageAndCacheInitObject(obj)
|
49
|
+
end
|
50
|
+
def setStorageAndCacheCacheObject(cache)
|
51
|
+
end
|
52
|
+
def setStorageAndCacheCacheFormulaObject(cache)
|
53
|
+
end
|
54
|
+
def newTest()
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
def newCas()
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
def newEditor()
|
61
|
+
return nil
|
62
|
+
end
|
63
|
+
def addCorsHeaders(response, origin)
|
64
|
+
end
|
65
|
+
def newCleanCache()
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
def newResourceLoader()
|
69
|
+
return nil
|
70
|
+
end
|
71
|
+
def isEditorLicensed()
|
72
|
+
return false
|
73
|
+
end
|
74
|
+
def getImageFormatController()
|
75
|
+
return nil
|
76
|
+
end
|
77
|
+
def newGenericParamsProvider(properties)
|
78
|
+
return nil
|
79
|
+
end
|
80
|
+
def setCustomParamsProvider(provider)
|
81
|
+
end
|
82
|
+
def getCustomParamsProvider()
|
83
|
+
return nil
|
84
|
+
end
|
85
|
+
def setAccessProvider(provider)
|
86
|
+
end
|
87
|
+
def getAccessProvider()
|
88
|
+
return nil
|
89
|
+
end
|
90
|
+
|
91
|
+
@@pb = nil
|
77
92
|
end
|
78
|
-
end
|
79
93
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/impl/CacheImpl.rb')
|
5
|
+
require('com/wiris/plugin/impl/CacheImpl.rb')
|
6
|
+
class CacheFormulaImpl < CacheImpl
|
7
|
+
include Wiris
|
8
|
+
|
9
|
+
def initialize(conf)
|
10
|
+
super(conf)
|
11
|
+
self.cacheFolder = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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/util/sys/Cache.rb')
|
6
|
+
require('com/wiris/util/sys/Cache.rb')
|
7
|
+
class CacheImpl
|
8
|
+
extend CacheInterface
|
9
|
+
|
10
|
+
include Wiris
|
11
|
+
|
12
|
+
attr_accessor :conf
|
13
|
+
attr_accessor :cacheFolder
|
14
|
+
@@backwards_compat;
|
15
|
+
def self.backwards_compat
|
16
|
+
@@backwards_compat
|
17
|
+
end
|
18
|
+
def self.backwards_compat=(backwards_compat)
|
19
|
+
@@backwards_compat = backwards_compat
|
20
|
+
end
|
21
|
+
def initialize(conf)
|
22
|
+
super()
|
23
|
+
self.conf = conf
|
24
|
+
self.cacheFolder = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
25
|
+
end
|
26
|
+
def set(key, value)
|
27
|
+
extension = Std::substr(key,key::indexOf("."),key::length() - key::indexOf("."))
|
28
|
+
digest = Std::substr(key,0,key::indexOf(extension))
|
29
|
+
parent = getFolderStore(@cacheFolder,digest)
|
30
|
+
parent::mkdirs()
|
31
|
+
store = getFileStoreWithParent(parent,digest,extension)
|
32
|
+
if !store::exists()
|
33
|
+
store::writeBinary(value)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
def get(key)
|
37
|
+
extension = Std::substr(key,key::indexOf("."),key::length() - key::indexOf("."))
|
38
|
+
digest = Std::substr(key,0,key::indexOf(extension))
|
39
|
+
store = self.getFileStore(@cacheFolder,digest,extension)
|
40
|
+
if @@backwards_compat
|
41
|
+
if !store::exists()
|
42
|
+
oldstore = Store::newStore(((@cacheFolder + "/") + digest) + extension)
|
43
|
+
if !oldstore::exists()
|
44
|
+
return nil
|
45
|
+
end
|
46
|
+
parent = store::getParent()
|
47
|
+
parent::mkdirs()
|
48
|
+
oldstore::moveTo(store)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
if !store::exists()
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
return store::readBinary()
|
56
|
+
end
|
57
|
+
def deleteAll()
|
58
|
+
formulaFolder = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
|
59
|
+
cacheFolder = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
|
60
|
+
includes = Array.new()
|
61
|
+
includes::push("svg")
|
62
|
+
includes::push("png")
|
63
|
+
includes::push("csv")
|
64
|
+
includes::push("txt")
|
65
|
+
if !(PropertiesTools::getProperty(self.conf,ConfigurationKeys::SAVE_MODE,"xml") == "image")
|
66
|
+
includes::push("ini")
|
67
|
+
end
|
68
|
+
Store::deleteDirectory(formulaFolder,includes)
|
69
|
+
Store::deleteDirectory(cacheFolder,includes)
|
70
|
+
end
|
71
|
+
def delete(key)
|
72
|
+
end
|
73
|
+
def getAndCheckFolder(key)
|
74
|
+
folder = PropertiesTools::getProperty(self.conf,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 getFileStoreWithParent(parent, digest, extension)
|
81
|
+
return Store::newStoreWithParent(parent,Std::substr(digest,4).to_s + extension)
|
82
|
+
end
|
83
|
+
def getFileStore(dir, digest, extension)
|
84
|
+
return getFileStoreWithParent(getFolderStore(dir,digest),digest,extension)
|
85
|
+
end
|
86
|
+
def getFolderStore(dir, digest)
|
87
|
+
return Store::newStore((((dir + "/") + Std::substr(digest,0,2).to_s) + "/") + Std::substr(digest,2,2).to_s)
|
88
|
+
end
|
89
|
+
def updateFoldersStructure()
|
90
|
+
updateFolderStructure(getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER))
|
91
|
+
updateFolderStructure(getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER))
|
92
|
+
end
|
93
|
+
def updateFolderStructure(dir)
|
94
|
+
folder = Store::newStore(dir)
|
95
|
+
files = folder::list()
|
96
|
+
if files != nil
|
97
|
+
for i in 0..files::length - 1
|
98
|
+
digest = isFormulaFileName(files[i])
|
99
|
+
if digest != nil
|
100
|
+
newFolder = getFolderStore(dir,digest)
|
101
|
+
newFolder::mkdirs()
|
102
|
+
newFile = getFileStoreWithParent(newFolder,digest,Std::substr(files[i],files[i]::indexOf(".") + 1))
|
103
|
+
file = Store::newStoreWithParent(folder,files[i])
|
104
|
+
file::moveTo(newFile)
|
105
|
+
end
|
106
|
+
i+=1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
def isFormulaFileName(name)
|
111
|
+
i = name::indexOf(".")
|
112
|
+
if i == -1
|
113
|
+
return nil
|
114
|
+
end
|
115
|
+
digest = Std::substr(name,0,i)
|
116
|
+
if digest::length() != 32
|
117
|
+
return nil
|
118
|
+
end
|
119
|
+
return digest
|
120
|
+
end
|
121
|
+
|
122
|
+
@@backwards_compat = true
|
123
|
+
end
|
124
|
+
end
|
@@ -1,146 +1,148 @@
|
|
1
1
|
module WirisPlugin
|
2
2
|
include Wiris
|
3
|
-
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
-
require('com/wiris/plugin/
|
5
|
-
require('com/wiris/plugin/
|
6
|
-
|
7
|
-
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
4
|
+
require('com/wiris/plugin/api/Cas.rb')
|
5
|
+
require('com/wiris/plugin/impl/RenderImpl.rb')
|
6
|
+
require('com/wiris/plugin/api/Cas.rb')
|
7
|
+
class CasImpl
|
8
|
+
extend CasInterface
|
8
9
|
|
9
|
-
|
10
|
+
include Wiris
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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"
|
12
|
+
attr_accessor :plugin
|
13
|
+
def initialize(plugin)
|
14
|
+
super()
|
15
|
+
self.plugin = plugin
|
27
16
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
17
|
+
def showCasImage(f, provider)
|
18
|
+
formula = f
|
19
|
+
if formula::endsWith(".png")
|
20
|
+
formula = Std::substr(formula,0,formula::length() - 4)
|
21
|
+
end
|
22
|
+
store = self.plugin::getStorageAndCache()
|
23
|
+
data = store::retreiveData(formula,"png")
|
24
|
+
if data == nil
|
25
|
+
data = Storage::newResourceStorage("cas.png")::readBinary()
|
26
|
+
if data == nil
|
27
|
+
raise Exception,"Missing resource cas.png"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
return data
|
122
31
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
32
|
+
def createCasImage(imageParameter)
|
33
|
+
output = ""
|
34
|
+
contextPath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/")
|
35
|
+
if imageParameter != nil
|
36
|
+
dataDecoded = CasImpl.decodeBase64(imageParameter)
|
37
|
+
digest = Md5::encode(imageParameter)
|
38
|
+
store = self.plugin::getStorageAndCache()
|
39
|
+
store::storeData(digest,"png",dataDecoded::getData())
|
40
|
+
showImagePath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SHOWCASIMAGE_PATH,nil)
|
41
|
+
output += RenderImpl::concatPath(contextPath,showImagePath) + StringTools::urlEncode(digest + ".png").to_s
|
42
|
+
else
|
43
|
+
output += RenderImpl::concatPath(contextPath,"core/cas.png")
|
44
|
+
end
|
45
|
+
return output
|
46
|
+
end
|
47
|
+
def cas(mode, language)
|
48
|
+
output = StringBuf.new()
|
49
|
+
output::add("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
|
50
|
+
config = self.plugin::getConfiguration()
|
51
|
+
availableLanguages = getAvailableCASLanguages(config::getProperty(ConfigurationKeys::CAS_LANGUAGES,nil))
|
52
|
+
if (language == nil) || !availableLanguages::contains_(language)
|
53
|
+
language = availableLanguages::_(0)
|
54
|
+
end
|
55
|
+
if (mode != nil) && (mode == "applet")
|
56
|
+
codebase = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_CODEBASE,nil),"%LANG",language)
|
57
|
+
archive = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_ARCHIVE,nil),"%LANG",language)
|
58
|
+
className = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_CLASS,nil),"%LANG",language)
|
59
|
+
output::add(printCAS(codebase,archive,className))
|
60
|
+
else
|
61
|
+
output::add(printCASContainer(config,availableLanguages,language))
|
62
|
+
end
|
63
|
+
return output::toString()
|
64
|
+
end
|
65
|
+
def getAvailableCASLanguages(languageString)
|
66
|
+
langs = Std::split(languageString,",")
|
67
|
+
availableLanguages = Array.new()
|
68
|
+
iter = langs::iterator()
|
69
|
+
while iter::hasNext()
|
70
|
+
elem = iter::next()
|
71
|
+
elem = StringTools::trim(elem)
|
72
|
+
availableLanguages::push(elem)
|
73
|
+
end
|
74
|
+
if availableLanguages::length() == 0
|
75
|
+
availableLanguages = Array.new()
|
76
|
+
availableLanguages::push("")
|
77
|
+
end
|
78
|
+
return availableLanguages
|
79
|
+
end
|
80
|
+
def printCAS(codebase, archive, className)
|
81
|
+
output = StringBuf.new()
|
82
|
+
output::add("<html><head><style type=\"text/css\">/*<!--*/ html, body { height: 100%; } body { overflow: hidden; margin: 0; } applet { height: 100%; width: 100%; } /*-->*/</style></head>")
|
83
|
+
output::add("<body><applet id=\"applet\" alt=\"WIRIS CAS\" codebase=\"")
|
84
|
+
output::add(htmlentities(codebase,true))
|
85
|
+
output::add("\" archive=\"")
|
86
|
+
output::add(htmlentities(archive,true))
|
87
|
+
output::add("\" code=\"")
|
88
|
+
output::add(htmlentities(className,true))
|
89
|
+
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>")
|
90
|
+
return output::toString()
|
91
|
+
end
|
92
|
+
def printCASContainer(config, availableLanguages, lang)
|
93
|
+
output = StringBuf.new()
|
94
|
+
output::add("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/><script>")
|
95
|
+
output::add("var lang =\'")
|
96
|
+
output::add(lang)
|
97
|
+
output::add("/strings.js\';")
|
98
|
+
output::add(" ")
|
99
|
+
output::add(" var scriptsrc = window.opener.path + \'/lang/\' + lang;")
|
100
|
+
output::add(" var script = document.createElement(\'script\'); ")
|
101
|
+
output::add(" script.src = scriptsrc;")
|
102
|
+
output::add(" document.head.appendChild(script);")
|
103
|
+
output::add("</script><script>")
|
104
|
+
output::add("var scriptsrc = window.opener.path + \'/core/cas.js\'; ")
|
105
|
+
output::add(" var script = document.createElement(\'script\'); ")
|
106
|
+
output::add(" script.src = scriptsrc;")
|
107
|
+
output::add(" document.head.appendChild(script);")
|
108
|
+
output::add("</script>")
|
109
|
+
output::add("<title>WIRIS CAS</title><style type=\"text/css\">")
|
110
|
+
output::add("/*<!--*/ html, body, #optionForm { height: 100%; } body { overflow: hidden; margin: 0; } #controls { width: 100%; } /*-->*/</style></head>")
|
111
|
+
output::add("<body><form id=\"optionForm\"><div id=\"appletContainer\"></div><table id=\"controls\"><tr><td>Width</td><td><input name=\"width\" type=\"text\" value=\"")
|
112
|
+
output::add(config::getProperty(ConfigurationKeys::CAS_WIDTH,nil))
|
113
|
+
output::add("\"/></td><td><input name=\"executeonload\" type=\"checkbox\"/> Calculate on load")
|
114
|
+
output::add("</td><td><input name=\"toolbar\" type=\"checkbox\" checked /> Show toolbar</td><td>Language <select id=\"languageList\">")
|
115
|
+
for i in 0..availableLanguages::length() - 1
|
116
|
+
language = htmlentities(availableLanguages::_(i),true)
|
117
|
+
output::add("<option value=\"")
|
118
|
+
output::add(language)
|
119
|
+
output::add("\">")
|
120
|
+
output::add(language)
|
121
|
+
output::add("</option>")
|
122
|
+
i+=1
|
123
|
+
end
|
124
|
+
output::add("</select></td></tr><tr><td>Height</td><td><input name=\"height\" type=\"text\" value=\"")
|
125
|
+
output::add(config::getProperty(ConfigurationKeys::CAS_HEIGHT,nil))
|
126
|
+
output::add("\"/></td><td><input name=\"focusonload\" type=\"checkbox\"/> Focus on load</td><td><input name=\"level\" type=\"checkbox\"/>")
|
127
|
+
output::add("Elementary mode</td><td></td></tr><tr><td colspan=\"5\"><input id=\"submit\" value=\"Accept\" type=\"button\"/>")
|
128
|
+
output::add("<input id=\"cancel\" value=\"Cancel\" type=\"button\"/></td></tr></table></form></body></html>")
|
129
|
+
return output::toString()
|
130
|
+
end
|
131
|
+
def htmlentities(input, entQuotes)
|
132
|
+
returnValue = StringTools::replace(input,"&","&")
|
133
|
+
returnValue = StringTools::replace(returnValue,"<","<")
|
134
|
+
returnValue = StringTools::replace(returnValue,">","gt;")
|
135
|
+
if entQuotes
|
136
|
+
returnValue = StringTools::replace(returnValue,"\"",""")
|
137
|
+
return returnValue
|
138
|
+
end
|
139
|
+
return returnValue
|
140
|
+
end
|
141
|
+
def self.decodeBase64(imageParameter)
|
142
|
+
b = Base64.new()
|
143
|
+
dataDecoded = b::decodeBytes(Bytes::ofString(imageParameter))
|
144
|
+
return dataDecoded
|
145
|
+
end
|
146
|
+
|
144
147
|
end
|
145
|
-
end
|
146
148
|
end
|