xqcoretools 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/xqcoretools +38 -3
- metadata +1 -1
data/bin/xqcoretools
CHANGED
@@ -114,6 +114,8 @@ class XQCoreTools < Thor
|
|
114
114
|
fileHandle = File.open(subPath)
|
115
115
|
document = Nokogiri::HTML(fileHandle)
|
116
116
|
fileHandle.close
|
117
|
+
|
118
|
+
XQCoreTools::modifyHostEvents(platform, document)
|
117
119
|
|
118
120
|
nodes = document.css('script')
|
119
121
|
|
@@ -135,7 +137,7 @@ class XQCoreTools < Thor
|
|
135
137
|
|
136
138
|
node.set_attribute('src', runtimeFolder)
|
137
139
|
|
138
|
-
XQCoreTools::compileTemplates(subPath, document, scriptVersion, downloadCache, node)
|
140
|
+
XQCoreTools::compileTemplates(platform, subPath, document, scriptVersion, downloadCache, node)
|
139
141
|
|
140
142
|
isDirty = true
|
141
143
|
break;
|
@@ -157,7 +159,7 @@ class XQCoreTools < Thor
|
|
157
159
|
end
|
158
160
|
end
|
159
161
|
|
160
|
-
def self.compileTemplates(fileName, document, version, downloadCache, insertSibling)
|
162
|
+
def self.compileTemplates(platform, fileName, document, version, downloadCache, insertSibling)
|
161
163
|
script = ''
|
162
164
|
|
163
165
|
compilerFile = "compiler.js"
|
@@ -184,7 +186,10 @@ class XQCoreTools < Thor
|
|
184
186
|
|
185
187
|
id = node.get_attribute('id')
|
186
188
|
|
187
|
-
|
189
|
+
template = Nokogiri::XML(node.content)
|
190
|
+
XQCoreTools::modifyHostEvents(platform, template)
|
191
|
+
|
192
|
+
script += "XQ.Core.addTemplate('#{id}', Handlebars.template(" + context.call("Handlebars.precompile", template.to_xml) + '));'
|
188
193
|
|
189
194
|
node.remove()
|
190
195
|
end
|
@@ -196,6 +201,36 @@ class XQCoreTools < Thor
|
|
196
201
|
insertSibling.add_next_sibling(templatesNode)
|
197
202
|
end
|
198
203
|
|
204
|
+
def self.modifyHostEvents(platform, document)
|
205
|
+
|
206
|
+
nodes = document.css('a')
|
207
|
+
|
208
|
+
for node in nodes do
|
209
|
+
if node.has_attribute?('href')
|
210
|
+
href = node.get_attribute('href')
|
211
|
+
|
212
|
+
if href.start_with?('#')
|
213
|
+
href = href[1, href.length - 1]
|
214
|
+
|
215
|
+
click = ''
|
216
|
+
|
217
|
+
if node.has_attribute?('onclick')
|
218
|
+
click = node.get_attribute('onclick')
|
219
|
+
|
220
|
+
if !click.end_with?(';')
|
221
|
+
click += ';'
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
click += "'#{href}'"
|
226
|
+
|
227
|
+
node.set_attribute('onclick', "XQ.Core.sendHostEvent(#{click})")
|
228
|
+
node.remove_attribute('href')
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
199
234
|
def self.clearFolder(path)
|
200
235
|
FileUtils.rm_r(path, :force=>true)
|
201
236
|
|