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,52 @@
|
|
|
1
|
+
module WirisPlugin
|
|
2
|
+
include Wiris
|
|
3
|
+
require('com/wiris/plugin/api/ServiceResourceLoader.rb')
|
|
4
|
+
class ServiceResourceLoaderImpl
|
|
5
|
+
extend ServiceResourceLoaderInterface
|
|
6
|
+
|
|
7
|
+
include Wiris
|
|
8
|
+
|
|
9
|
+
def initialize()
|
|
10
|
+
super()
|
|
11
|
+
end
|
|
12
|
+
def getContent(resource)
|
|
13
|
+
return Storage::newResourceStorage(resource)::read()
|
|
14
|
+
end
|
|
15
|
+
def getContentType(name)
|
|
16
|
+
ext = Std::substr(name,name::lastIndexOf(".")+1)
|
|
17
|
+
if (ext=="png")
|
|
18
|
+
return "image/png"
|
|
19
|
+
else
|
|
20
|
+
if (ext=="gif")
|
|
21
|
+
return "image/gif"
|
|
22
|
+
else
|
|
23
|
+
if (ext=="jpg")||(ext=="jpeg")
|
|
24
|
+
return "image/jpeg"
|
|
25
|
+
else
|
|
26
|
+
if (ext=="html")||(ext=="htm")
|
|
27
|
+
return "text/html"
|
|
28
|
+
else
|
|
29
|
+
if (ext=="css")
|
|
30
|
+
return "text/css"
|
|
31
|
+
else
|
|
32
|
+
if (ext=="js")
|
|
33
|
+
return "application/javascript"
|
|
34
|
+
else
|
|
35
|
+
if (ext=="txt")
|
|
36
|
+
return "text/plain"
|
|
37
|
+
else
|
|
38
|
+
if (ext=="ini")
|
|
39
|
+
return "text/plain"
|
|
40
|
+
else
|
|
41
|
+
return "application/octet-stream"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
module WirisPlugin
|
|
2
|
+
include Wiris
|
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
|
4
|
+
require('com/wiris/plugin/impl/HttpImpl.rb')
|
|
5
|
+
require('com/wiris/plugin/api/Test.rb')
|
|
6
|
+
class TestImpl
|
|
7
|
+
extend TestInterface
|
|
8
|
+
|
|
9
|
+
include Wiris
|
|
10
|
+
|
|
11
|
+
attr_accessor :plugin
|
|
12
|
+
def initialize(plugin)
|
|
13
|
+
super()
|
|
14
|
+
@plugin = plugin
|
|
15
|
+
end
|
|
16
|
+
def getTestPage()
|
|
17
|
+
random = ""+(Math::random()*9999).to_s
|
|
18
|
+
mml = ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><msqrt><mn>"+random)+"</mn></msqrt></mrow></math>"
|
|
19
|
+
output = ""
|
|
20
|
+
output+="<html><head>\r\n"
|
|
21
|
+
output+="<title>WIRIS plugin test page</title><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /><style type=\"text/css\">/*<!--*/html {font-family: sans-serif;}h2 {margin-left: 1em;}h3 {margin-left: 2em;}p {margin-left: 3em;}p.concrete {margin-left: 4em;}.ok {font-weight: bold;color: #0c0;}.error {font-weight: bold;color: #f00;}/*-->*/</style><style type=\"text/css\">body{font-family: Arial;}span{font-weight: bold;}span.ok {color: #009900;}span.error {color: #dd0000;}table, th, td, tr {border: solid 1px #000000;border-collapse:collapse;padding: 5px;}th{background-color: #eeeeee;}img{border:none;}</style>\r\n"
|
|
22
|
+
output+="<script src=\"../core/WIRISplugins.js?viewer=image\" ></script>\r\n"
|
|
23
|
+
output+="</head><body><h1>WIRIS plugin test page</h1>\r\n"
|
|
24
|
+
output+="<table><tr><th>Test</th><th>Report</th><th>Status</th></tr>\r\n"
|
|
25
|
+
testName = "WIRIS plugin version"
|
|
26
|
+
begin
|
|
27
|
+
s = Storage::newResourceStorage("VERSION")::read()
|
|
28
|
+
reportText = ("<b>"+s)+"</b>"
|
|
29
|
+
solutionLink = ""
|
|
30
|
+
condition = true
|
|
31
|
+
end
|
|
32
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
33
|
+
testName = "Creating and storing data"
|
|
34
|
+
solutionLink = ""
|
|
35
|
+
param = PropertiesTools::newProperties()
|
|
36
|
+
outp = PropertiesTools::newProperties()
|
|
37
|
+
provider = @plugin::newGenericParamsProvider(param)
|
|
38
|
+
imageUrl = plugin::newRender()::createImage(mml,provider,outp)
|
|
39
|
+
reportText = ((("<a href=\""+imageUrl)+"\" />")+imageUrl)+"</a>"
|
|
40
|
+
condition = true
|
|
41
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
42
|
+
testName = "Retrieving data"
|
|
43
|
+
solutionLink = ""
|
|
44
|
+
reportText = ("<img src=\""+imageUrl)+"\" />"
|
|
45
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
46
|
+
testName = "JavaScript MathML filter"
|
|
47
|
+
solutionLink = ""
|
|
48
|
+
reportText = mml
|
|
49
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
50
|
+
testName = "Host platform"
|
|
51
|
+
solutionLink = ""
|
|
52
|
+
platform = plugin::getConfiguration()::getProperty(ConfigurationKeys::HOST_PLATFORM,"failed")
|
|
53
|
+
reportText = platform
|
|
54
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
55
|
+
testName = "Filter test"
|
|
56
|
+
solutionLink = ""
|
|
57
|
+
condition = true
|
|
58
|
+
p = PropertiesTools::newProperties()
|
|
59
|
+
PropertiesTools::setProperty(p,"savemode","safeXml")
|
|
60
|
+
s2 = StringTools::replace(mml,"<",Std::fromCharCode(171))
|
|
61
|
+
s2 = StringTools::replace(s2,">",Std::fromCharCode(187))
|
|
62
|
+
s2 = StringTools::replace(s2,"\"",Std::fromCharCode(168))
|
|
63
|
+
reportText = plugin::newTextService()::filter("square root: "+s2,p)
|
|
64
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
65
|
+
testName = "Connecting to www.wiris.net"
|
|
66
|
+
solutionLink = ""
|
|
67
|
+
condition = true
|
|
68
|
+
begin
|
|
69
|
+
h = HttpImpl.new("http://www.wiris.net",nil)
|
|
70
|
+
h::request(true)
|
|
71
|
+
end
|
|
72
|
+
reportText = "Checking if WIRIS server is reachable"
|
|
73
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
74
|
+
if Type::resolveClass("com.wiris.editor.services.PublicServices")!=nil
|
|
75
|
+
condition = true
|
|
76
|
+
testName = "Testing integrated services"
|
|
77
|
+
reportText = "WIRIS Services installed"
|
|
78
|
+
solutionLink = ""
|
|
79
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
80
|
+
isLicensed = plugin::isEditorLicensed()
|
|
81
|
+
condition = false
|
|
82
|
+
testName = "WIRIS editor license"
|
|
83
|
+
reportText = "Checking WIRIS editor valid license"
|
|
84
|
+
output+=createTableRow(testName,reportText,solutionLink,isLicensed)
|
|
85
|
+
else
|
|
86
|
+
reportText = "WIRIS Services not installed"
|
|
87
|
+
end
|
|
88
|
+
debug = (plugin::getConfiguration()::getProperty(ConfigurationKeys::DEBUG,"false")=="true")
|
|
89
|
+
if debug
|
|
90
|
+
testName = "Font family"
|
|
91
|
+
solutionLink = ""
|
|
92
|
+
condition = true
|
|
93
|
+
reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::FONT_FAMILY,"")
|
|
94
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
95
|
+
testName = "Configuration file"
|
|
96
|
+
solutionLink = ""
|
|
97
|
+
condition = true
|
|
98
|
+
reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::CONFIGURATION_PATH,"")+"\\configuration.ini"
|
|
99
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
100
|
+
testName = "Cache path"
|
|
101
|
+
solutionLink = ""
|
|
102
|
+
condition = true
|
|
103
|
+
reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::CACHE_FOLDER,"")
|
|
104
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
105
|
+
testName = "Formula path"
|
|
106
|
+
solutionLink = ""
|
|
107
|
+
condition = true
|
|
108
|
+
reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::FORMULA_FOLDER,"")
|
|
109
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
110
|
+
testName = "Integration path"
|
|
111
|
+
solutionLink = ""
|
|
112
|
+
condition = true
|
|
113
|
+
reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::INTEGRATION_PATH,"")
|
|
114
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
115
|
+
testName = "Context path"
|
|
116
|
+
solutionLink = ""
|
|
117
|
+
condition = true
|
|
118
|
+
reportText = plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"")
|
|
119
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
120
|
+
testName = "default-configuration.ini load"
|
|
121
|
+
solutionLink = ""
|
|
122
|
+
defaultConfiguration = Storage::newResourceStorage("default-configuration.ini")::read()
|
|
123
|
+
condition = (defaultConfiguration!=nil)&&(defaultConfiguration::length()>0)
|
|
124
|
+
if condition
|
|
125
|
+
reportText = "Length: "+defaultConfiguration::length().to_s
|
|
126
|
+
else
|
|
127
|
+
reportText = "Not found!"
|
|
128
|
+
end
|
|
129
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
130
|
+
testName = "cas.png load"
|
|
131
|
+
solutionLink = ""
|
|
132
|
+
casPng = Storage::newResourceStorage("cas.png")::readBinary()
|
|
133
|
+
casPngLength = 0
|
|
134
|
+
if casPng!=nil
|
|
135
|
+
casPngLength = Bytes::ofData(casPng)::length()
|
|
136
|
+
condition = casPngLength>0
|
|
137
|
+
else
|
|
138
|
+
condition = false
|
|
139
|
+
end
|
|
140
|
+
if condition
|
|
141
|
+
reportText = "Length: "+casPngLength.to_s
|
|
142
|
+
else
|
|
143
|
+
reportText = "Not found!"
|
|
144
|
+
end
|
|
145
|
+
output+=createTableRow(testName,reportText,solutionLink,condition)
|
|
146
|
+
end
|
|
147
|
+
output+="<div id=\"haxe:trace\"></div>"
|
|
148
|
+
return output
|
|
149
|
+
end
|
|
150
|
+
def createTableRow(testName,reportText,solutionLink,condition)
|
|
151
|
+
output = ""
|
|
152
|
+
output+="<tr>"
|
|
153
|
+
output+=("<td>"+testName)+"</td>"
|
|
154
|
+
output+=("<td>"+reportText)+"</td>"
|
|
155
|
+
output+="<td>"
|
|
156
|
+
if condition
|
|
157
|
+
output+="<span class=\"ok\">OK</span><br/>"
|
|
158
|
+
else
|
|
159
|
+
output+="<span class=\"error\">ERROR</span><br/>"
|
|
160
|
+
end
|
|
161
|
+
output+="</td>"
|
|
162
|
+
output+="</tr>\r\n"
|
|
163
|
+
return output
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
module WirisPlugin
|
|
2
|
+
include Wiris
|
|
3
|
+
require('com/wiris/plugin/api/ConfigurationKeys.rb')
|
|
4
|
+
require('com/wiris/plugin/impl/TextFilterTags.rb')
|
|
5
|
+
require('com/wiris/util/json/JSon.rb')
|
|
6
|
+
class TextFilter
|
|
7
|
+
include Wiris
|
|
8
|
+
|
|
9
|
+
attr_accessor :plugin
|
|
10
|
+
attr_accessor :render
|
|
11
|
+
attr_accessor :service
|
|
12
|
+
attr_accessor :fixUrl
|
|
13
|
+
NBSP = Std::fromCharCode(160)
|
|
14
|
+
def initialize(plugin)
|
|
15
|
+
super()
|
|
16
|
+
@plugin = plugin
|
|
17
|
+
@render = plugin::newRender()
|
|
18
|
+
@service = plugin::newTextService()
|
|
19
|
+
@fixUrl = nil
|
|
20
|
+
end
|
|
21
|
+
def filter(str,prop)
|
|
22
|
+
saveMode = nil
|
|
23
|
+
if prop!=nil
|
|
24
|
+
saveMode = PropertiesTools::getProperty(prop,"savemode")
|
|
25
|
+
end
|
|
26
|
+
if saveMode==nil
|
|
27
|
+
saveMode = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml")
|
|
28
|
+
end
|
|
29
|
+
b = (saveMode=="safeXml")
|
|
30
|
+
if b
|
|
31
|
+
tags = TextFilterTags::newSafeXml()
|
|
32
|
+
else
|
|
33
|
+
tags = TextFilterTags::newXml()
|
|
34
|
+
end
|
|
35
|
+
str = filterMath(tags,str,prop,b)
|
|
36
|
+
str = filterApplet(tags,str,prop,b)
|
|
37
|
+
return str
|
|
38
|
+
end
|
|
39
|
+
def filterMath(tags,text,prop,safeXML)
|
|
40
|
+
output = StringBuf.new()
|
|
41
|
+
n0 = 0
|
|
42
|
+
n1 = text::indexOf(tags::in_mathopen,n0)
|
|
43
|
+
tag = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_MATHML_ATTRIBUTE,"data-mathml")
|
|
44
|
+
dataMathml = text::indexOf(tag,0)
|
|
45
|
+
while n1>=0
|
|
46
|
+
m0 = n0
|
|
47
|
+
output::add(Std::substr(text,n0,n1-n0))
|
|
48
|
+
n0 = n1
|
|
49
|
+
n1 = text::indexOf(tags::in_mathclose,n0)
|
|
50
|
+
if n1>=0
|
|
51
|
+
n1 = n1+tags::in_mathclose::length()
|
|
52
|
+
sub = Std::substr(text,n0,n1-n0)
|
|
53
|
+
if safeXML
|
|
54
|
+
if dataMathml!=-1
|
|
55
|
+
m1 = text::indexOf("/>",n1)
|
|
56
|
+
if (m1>=0)&&((text::indexOf("<img",n1)==-1)||(text::indexOf("<img",n1)>m1))
|
|
57
|
+
m0 = Std::substr(text,m0,n0-m0)::lastIndexOf("<img")
|
|
58
|
+
if m0>=0
|
|
59
|
+
if (text::indexOf(tag,m0)>0)&&(text::indexOf(tag,m0)<n1)
|
|
60
|
+
n0 = n1
|
|
61
|
+
output::add(sub)
|
|
62
|
+
n1 = text::indexOf(tags::in_mathopen,n0)
|
|
63
|
+
m0 = m1
|
|
64
|
+
next
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
if @fixUrl==nil
|
|
70
|
+
@fixUrl = EReg.new("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">","")
|
|
71
|
+
end
|
|
72
|
+
sub = @fixUrl::replace(sub,"$1")
|
|
73
|
+
sub = html_entity_decode(sub)
|
|
74
|
+
sub = StringTools::replace(sub,tags::in_double_quote,tags::out_double_quote)
|
|
75
|
+
sub = StringTools::replace(sub,tags::in_open,tags::out_open)
|
|
76
|
+
sub = StringTools::replace(sub,tags::in_close,tags::out_close)
|
|
77
|
+
sub = StringTools::replace(sub,tags::in_entity,tags::out_entity)
|
|
78
|
+
sub = StringTools::replace(sub,tags::in_quote,tags::out_quote)
|
|
79
|
+
end
|
|
80
|
+
sub = math2Img(sub,prop)
|
|
81
|
+
n0 = n1
|
|
82
|
+
output::add(sub)
|
|
83
|
+
n1 = text::indexOf(tags::in_mathopen,n0)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
output::add(Std::substr(text,n0))
|
|
87
|
+
return output::toString()
|
|
88
|
+
end
|
|
89
|
+
def filterApplet(tags,text,prop,safeXML)
|
|
90
|
+
output = StringBuf.new()
|
|
91
|
+
n0 = 0
|
|
92
|
+
n1 = text::toUpperCase()::indexOf(tags::in_appletopen,n0)
|
|
93
|
+
while n1>=0
|
|
94
|
+
output::add(Std::substr(text,n0,n1-n0))
|
|
95
|
+
n0 = n1
|
|
96
|
+
n1 = text::toUpperCase()::indexOf(tags::in_appletclose,n0)
|
|
97
|
+
if n1>=0
|
|
98
|
+
n1 = n1+tags::in_appletclose::length()
|
|
99
|
+
sub = Std::substr(text,n0,n1-n0)
|
|
100
|
+
if safeXML
|
|
101
|
+
if @fixUrl==nil
|
|
102
|
+
@fixUrl = EReg.new("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">","")
|
|
103
|
+
end
|
|
104
|
+
sub = @fixUrl::replace(sub,"$1")
|
|
105
|
+
sub = html_entity_decode(sub)
|
|
106
|
+
sub = StringTools::replace(sub,tags::in_double_quote,tags::out_double_quote)
|
|
107
|
+
sub = StringTools::replace(sub,tags::in_open,tags::out_open)
|
|
108
|
+
sub = StringTools::replace(sub,tags::in_close,tags::out_close)
|
|
109
|
+
sub = StringTools::replace(sub,tags::in_entity,tags::out_entity)
|
|
110
|
+
sub = StringTools::replace(sub,tags::in_quote,tags::out_quote)
|
|
111
|
+
end
|
|
112
|
+
n0 = n1
|
|
113
|
+
output::add(sub)
|
|
114
|
+
n1 = text::toUpperCase()::indexOf(tags::in_appletopen,n0)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
output::add(Std::substr(text,n0))
|
|
118
|
+
return output::toString()
|
|
119
|
+
end
|
|
120
|
+
def math2Img(str,prop)
|
|
121
|
+
img = "<img"
|
|
122
|
+
output = PropertiesTools::newProperties()
|
|
123
|
+
PropertiesTools::setProperty(prop,"centerbaseline","false")
|
|
124
|
+
PropertiesTools::setProperty(prop,"accessible","true")
|
|
125
|
+
PropertiesTools::setProperty(prop,"metrics","true")
|
|
126
|
+
provider = @plugin::newGenericParamsProvider(prop)
|
|
127
|
+
if (@plugin::getConfiguration()::getProperty("wirispluginperformance","false")=="false")
|
|
128
|
+
src = @render::createImage(str,provider,output)
|
|
129
|
+
img+=(" src=\""+src)+"\""
|
|
130
|
+
alt = PropertiesTools::getProperty(output,"alt")
|
|
131
|
+
width = PropertiesTools::getProperty(output,"width")
|
|
132
|
+
height = PropertiesTools::getProperty(output,"height")
|
|
133
|
+
baseline = PropertiesTools::getProperty(output,"baseline")
|
|
134
|
+
else
|
|
135
|
+
digest = @render::computeDigest(str,prop)
|
|
136
|
+
json = JSon::decode(@render::showImageJson(digest,PropertiesTools::getProperty(prop,"alt")))
|
|
137
|
+
hashImage = (json)
|
|
138
|
+
if (hashImage::get("status")=="warning")
|
|
139
|
+
@render::showImage(nil,str,provider)
|
|
140
|
+
end
|
|
141
|
+
json = JSon::decode(@render::showImageJson(digest,"en"))
|
|
142
|
+
hashImage = (json)
|
|
143
|
+
if (hashImage::get("status")=="ok")
|
|
144
|
+
result = (hashImage::get("result"))
|
|
145
|
+
base64 = (result::get("base64"))
|
|
146
|
+
img+=(" src=\"data:image/png;base64,"+base64)+"\""
|
|
147
|
+
if result::exists("alt")
|
|
148
|
+
alt = (result::get("alt"))
|
|
149
|
+
else
|
|
150
|
+
alt = @service::mathml2accessible(str,nil,prop)
|
|
151
|
+
end
|
|
152
|
+
width = (result::get("width"))
|
|
153
|
+
height = (result::get("height"))
|
|
154
|
+
baseline = (result::get("baseline"))
|
|
155
|
+
else
|
|
156
|
+
raise Exception,"Image can\'t be rendererd"
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
dpi = Std::parseFloat(@plugin::getConfiguration()::getProperty(ConfigurationKeys::WIRIS_DPI,"96"))
|
|
160
|
+
if @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil)!=nil
|
|
161
|
+
json = JSon::decode(@plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_PARAMS,nil))
|
|
162
|
+
decodedHash = (json)
|
|
163
|
+
if decodedHash::exists("dpi")
|
|
164
|
+
dpi = Std::parseFloat((decodedHash::get("dpi")))
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
mml = (@plugin::getConfiguration()::getProperty(ConfigurationKeys::FILTER_OUTPUT_MATHML,"false")=="true")
|
|
168
|
+
f = 96/dpi
|
|
169
|
+
dwidth = f*Std::parseFloat(width)
|
|
170
|
+
dheight = f*Std::parseFloat(height)
|
|
171
|
+
dbaseline = f*Std::parseFloat(baseline)
|
|
172
|
+
alt = html_entity_encode(alt)
|
|
173
|
+
img+=" class=\"Wirisformula\""
|
|
174
|
+
img+=(" alt=\""+alt)+"\""
|
|
175
|
+
img+=(" width=\""+(dwidth).to_s)+"\""
|
|
176
|
+
img+=(" height=\""+(dheight).to_s)+"\""
|
|
177
|
+
d = ((dbaseline-dheight))
|
|
178
|
+
img+=(" style=\"vertical-align:"+d.to_s)+"px\""
|
|
179
|
+
if mml
|
|
180
|
+
tag = @plugin::getConfiguration()::getProperty(ConfigurationKeys::EDITOR_MATHML_ATTRIBUTE,"data-mathml")
|
|
181
|
+
img+=(((" "+tag)+"=\"")+save_xml_encode(str))+"\""
|
|
182
|
+
end
|
|
183
|
+
img+="/>"
|
|
184
|
+
return img
|
|
185
|
+
end
|
|
186
|
+
def html_entity_decode(str)
|
|
187
|
+
str = StringTools::replace(str,"<","<")
|
|
188
|
+
str = StringTools::replace(str,">",">")
|
|
189
|
+
str = StringTools::replace(str,""","\"")
|
|
190
|
+
str = StringTools::replace(str," ",NBSP)
|
|
191
|
+
str = StringTools::replace(str,"&","&")
|
|
192
|
+
return str
|
|
193
|
+
end
|
|
194
|
+
def html_entity_encode(str)
|
|
195
|
+
str = StringTools::replace(str,"<","<")
|
|
196
|
+
str = StringTools::replace(str,">",">")
|
|
197
|
+
str = StringTools::replace(str,"\"",""")
|
|
198
|
+
str = StringTools::replace(str,"&","&")
|
|
199
|
+
return str
|
|
200
|
+
end
|
|
201
|
+
def save_xml_encode(str)
|
|
202
|
+
tags = TextFilterTags::newSafeXml()
|
|
203
|
+
str = StringTools::replace(str,tags::out_double_quote,tags::in_double_quote)
|
|
204
|
+
str = StringTools::replace(str,tags::out_open,tags::in_open)
|
|
205
|
+
str = StringTools::replace(str,tags::out_close,tags::in_close)
|
|
206
|
+
str = StringTools::replace(str,tags::out_entity,tags::in_entity)
|
|
207
|
+
str = StringTools::replace(str,tags::out_quote,tags::in_quote)
|
|
208
|
+
return str
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module WirisPlugin
|
|
2
|
+
include Wiris
|
|
3
|
+
class TextFilterTags
|
|
4
|
+
include Wiris
|
|
5
|
+
|
|
6
|
+
attr_accessor :in_mathopen
|
|
7
|
+
attr_accessor :in_mathclose
|
|
8
|
+
attr_accessor :in_double_quote
|
|
9
|
+
attr_accessor :out_double_quote
|
|
10
|
+
attr_accessor :in_open
|
|
11
|
+
attr_accessor :out_open
|
|
12
|
+
attr_accessor :in_close
|
|
13
|
+
attr_accessor :out_close
|
|
14
|
+
attr_accessor :in_entity
|
|
15
|
+
attr_accessor :out_entity
|
|
16
|
+
attr_accessor :in_quote
|
|
17
|
+
attr_accessor :out_quote
|
|
18
|
+
attr_accessor :in_appletopen
|
|
19
|
+
attr_accessor :in_appletclose
|
|
20
|
+
def initialize()
|
|
21
|
+
super()
|
|
22
|
+
end
|
|
23
|
+
def self.newSafeXml()
|
|
24
|
+
tags = TextFilterTags.new()
|
|
25
|
+
tags::in_open = Std::fromCharCode(171)
|
|
26
|
+
tags::in_close = Std::fromCharCode(187)
|
|
27
|
+
tags::in_entity = Std::fromCharCode(167)
|
|
28
|
+
tags::in_quote = "`"
|
|
29
|
+
tags::in_double_quote = Std::fromCharCode(168)
|
|
30
|
+
tags::init(tags)
|
|
31
|
+
return tags
|
|
32
|
+
end
|
|
33
|
+
def self.newXml()
|
|
34
|
+
tags = TextFilterTags.new()
|
|
35
|
+
tags::in_open = "<"
|
|
36
|
+
tags::in_close = ">"
|
|
37
|
+
tags::in_entity = "&"
|
|
38
|
+
tags::in_quote = "\'"
|
|
39
|
+
tags::in_double_quote = "\""
|
|
40
|
+
tags::init(tags)
|
|
41
|
+
return tags
|
|
42
|
+
end
|
|
43
|
+
def init(tags)
|
|
44
|
+
tags::in_appletopen = @in_open+"APPLET"
|
|
45
|
+
tags::in_appletclose = (@in_open+"/APPLET")+@in_close
|
|
46
|
+
tags::in_mathopen = @in_open+"math"
|
|
47
|
+
tags::in_mathclose = (@in_open+"/math")+@in_close
|
|
48
|
+
tags::out_open = "<"
|
|
49
|
+
tags::out_close = ">"
|
|
50
|
+
tags::out_entity = "&"
|
|
51
|
+
tags::out_quote = "\'"
|
|
52
|
+
tags::out_double_quote = "\""
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|