Commit 70b18284 authored by Romain Courteaud's avatar Romain Courteaud

Rewrite Webscrip's JSLinter as a gadget field

parent 2b89b75e
......@@ -44,7 +44,7 @@
<key> <string>bottom</string> </key>
<value>
<list>
<string>my_syntax</string>
<string>my_text_content</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.getTextContent()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebScript_getTextContent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block tal:define=\'site_root python: here.getWebSiteValue() or here.getPortalObject();\n
portal_url python: site_root.absolute_url();\n
\'>\n
\n
<script type="text/javascript"\n
tal:attributes="src string:${portal_url}/jslint.js"></script>\n
<script type="text/javascript"\n
tal:attributes="src string:${portal_url}/check_code.js"></script>\n
\n
</tal:block>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebScript_renderCheckSyntax</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="DTMLDocument" module="OFS.DTMLDocument"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>check_code.js</string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
$(document).ready(function(){\n
var get_code_url = document.baseURI + \'WebScript_getTextContent\';\n
check_code = function (code_to_check) {\n
\n
var i, len, data, err, table_html;\n
\n
JSLINT(code_to_check, {});\n
data = JSLINT.data();\n
table_html = \'<div class="listbox-container"><div class="listbox-content maximal-width"><div class="listbox-body"><table class="listbox listbox-table"><tbody>\';\n
line_letter = "A";\n
for (i = 0, len = data.errors.length; i < len; i += 1) {\n
console.log("err", err)\n
err = data.errors[i];\n
if (err !== null) {\n
table_html = table_html + \'<tr class="Data\' + line_letter + \'" ><td class="listbox-table-data-cell" >\' + \'line: \' + err.line + \': \' + err.character + \': \' + (err.evidence || \'\') + \'</td><td class="listbox-table-data-cell">\' + err.reason + "</td></tr>";\n
line_letter = line_letter === "A" ? "B": "A";\n
}\n
} \n
table_html = table_html + "</tbody></table></div></div></div>";\n
document.getElementsByClassName("check_code")[0].innerHTML = table_html;\n
};\n
$.get(get_code_url,\n
check_code);\n
});
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts21077282.37</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>gadget_jslint.html</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
<!DOCTYPE html>\n
<html>\n
<head>\n
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<script src="handlebars.js" type="text/javascript"></script>\n
<script src="jslint.js" type="text/javascript"></script>\n
\n
<script id="jslint_template" type="text/x-handlebars-template">\n
{{#each error_list}}\n
{{#if this}}\n
<tr class="Data{{this.line_letter}}">\n
<td class="listbox-table-data-cell">line: {{this.line}}: {{this.character}}: {{this.evidence}}</td>\n
<td class="listbox-table-data-cell">{{this.reason}}</td>\n
</tr>\n
{{/if}}\n
{{else}}\n
<tr class="DataA"><td>No error!</td></tr>\n
{{/each}}\n
</script> \n
\n
<script src="rsvp.js" type="text/javascript"></script>\n
<script src="renderjs.js" type="text/javascript"></script>\n
<script src="gadget_jslint.js" type="text/javascript"></script>\n
</head>\n
<body>\n
<div class="listbox-container">\n
<div class="listbox-content maximal-width">\n
<div class="listbox-body">\n
<table class="listbox listbox-table">\n
<tbody>\n
</tbody>\n
</table>\n
</div>\n
</div>\n
</div>\n
</body>\n
</html>
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1269</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts21077825.13</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>gadget_jslint.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*global window, rJS, JSLINT, Handlebars */\n
/*jslint nomen: true, maxlen:80, indent:2*/\n
(function (rJS, Handlebars, JSLINT, window) {\n
"use strict";\n
var gk = rJS(window),\n
template_source = gk.__template_element\n
.getElementById(\'jslint_template\')\n
.innerHTML,\n
template = Handlebars.compile(template_source);\n
\n
rJS(window)\n
.ready(function (g) {\n
g.props = {};\n
})\n
.ready(function (g) {\n
return g.getElement().push(function (element) {\n
g.props.element = element;\n
});\n
})\n
\n
.declareMethod("render", function (options) {\n
var text_content = options.value,\n
data,\n
html_content,\n
i,\n
line_letter = "A",\n
len,\n
gadget = this;\n
JSLINT(text_content, {});\n
data = JSLINT.data();\n
\n
for (i = 0, len = data.errors.length; i < len; i += 1) {\n
if (data.errors[i] !== null) {\n
data.errors[i].line_letter = line_letter;\n
line_letter = line_letter === "A" ? "B" : "A";\n
}\n
}\n
html_content = template({\n
error_list: data.errors\n
});\n
\n
gadget.props.element.querySelector("tbody")\n
.innerHTML = html_content;\n
});\n
}(rJS, Handlebars, JSLINT, window));
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1278</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,28 +2,28 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="DTMLDocument" module="OFS.DTMLDocument"/>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>jslint.js</string> </value>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts21078299.16</string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
<key> <string>__name__</string> </key>
<value> <string>jslint.js</string> </value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>raw</string> </key>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
// jslint.js\n
......@@ -4303,11 +4303,18 @@ klass: do {\n
itself.edition = \'2014-04-08\';\n
\n
return itself;\n
}());\n
}());
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>144477</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment