Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xueyun Qian
erp5
Commits
ac6de042
Commit
ac6de042
authored
Jan 22, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OfficeJS drive: Add draft of vim/cd/ls commands + CSP configuration.
parent
6a6421b2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
56 deletions
+134
-56
bt5/erp5_officejs_drive/PathTemplateItem/web_page_module/gadget_officejs_drive_page_browse_js.xml
.../web_page_module/gadget_officejs_drive_page_browse_js.xml
+97
-20
bt5/erp5_officejs_drive/PathTemplateItem/web_page_module/gadget_officejs_drive_page_edit_js.xml
...em/web_page_module/gadget_officejs_drive_page_edit_js.xml
+21
-34
bt5/erp5_officejs_drive/PathTemplateItem/web_site_module/officejs_drive.xml
...drive/PathTemplateItem/web_site_module/officejs_drive.xml
+16
-2
No files found.
bt5/erp5_officejs_drive/PathTemplateItem/web_page_module/gadget_officejs_drive_page_browse_js.xml
View file @
ac6de042
...
...
@@ -130,39 +130,112 @@
.declareAcquiredMethod("jio_allAttachments", "jio_allAttachments")\n
.declareAcquiredMethod("redirect", "redirect")\n
\n
.declareMethod("parse", function (text) {\n
//XXX use jison here instead of parsing manually\n
var command,\n
args = text.split(\' \'),\n
index;\n
// command is the first token\n
command = args.shift();\n
index = args.length;\n
\n
.declareMethod("render", function (options) {\n
/* begin from the end because removing some values from the list\n
while looping */\n
while (index--) {\n
// only keep useful args (no options, no emtpy string)\n
if (args[index] === \'\' || args[index].startsWith(\'-\')) {\n
args.splice(index, 1);\n
}\n
}\n
return {command: command, args: args};\n
})\n
\n
.declareMethod("browse", function (command, args) {\n
var gadget = this,\n
ul = gadget.props.element.querySelector(\'ul
\'),\n
position = options.position || \'/\'
;\n
position = args[0].split(\'/
\'),\n
resource = position.pop()
;\n
\n
if (!position.startsWith(\'/\')) {\n
position = \'/\' + position;\n
function absolutePosition(current, requested) {\n
var pos;\n
if (requested.startsWith(\'/\')) {\n
pos = \'/\' + requested + \'/\';\n
} else {\n
pos = \'/\' + current + \'/\' + requested + \'/\';\n
}\n
if (!position.endsWith(\'/\')) {\n
position += \'/\';\n
return pos.replace(/\\/+/g, \'/\');\n
}\n
\n
gadget.props.element.querySelector(\'input\').value = position;\n
// if command given: proceed\n
if (command) {\n
switch (command) {\n
case \'cd\':\n
case \'ls\':\n
if (args.length === 1) {\n
return gadget.redirect({\n
position: absolutePosition(gadget.props.currentPosition, args[0])\n
});\n
}\n
throw (\'Usage of \' + command + \' requires a single argument.\');\n
\n
case \'vim\':\n
case \'vi\':\n
if (args.length === 1) {\n
return gadget.redirect({\n
page: \'edit\',\n
position: absolutePosition(\n
gadget.props.currentPosition,\n
position.join(\'/\')\n
),\n
resource: resource\n
});\n
}\n
throw (\'Usage of \' + command + \' requires a single argument.\');\n
default:\n
throw (\'Unknown command: \' + command);\n
}\n
}\n
})\n
\n
.declareMethod("render", function (options) {\n
var gadget = this,\n
ul = gadget.props.element.querySelector(\'ul\');\n
\n
// redirect to root if no position given\n
if (!options.position) {\n
return gadget.redirect({\n
position: \'/\'\n
});\n
}\n
gadget.props.currentPosition = options.position;\n
gadget.props.element.querySelector(\'input\').value = \'\';\n
gadget.props.element.querySelector(\'.position\').value = options.position;\n
\n
// clean previous ul children\n
while (ul.hasChildNodes()) {\n
ul.removeChild(ul.firstChild);\n
}\n
\n
return gadget.jio_allAttachments(position)\n
return gadget.jio_allAttachments(
options.
position)\n
.push(function (all) {\n
var key,\n
li,\n
link;\n
liContent,\n
resourceName;\n
for (key in all) {\n
if (all.hasOwnProperty(key)) {\n
li = document.createElement(\'li\');\n
link = document.createElement(\'a\');\n
link.setAttribute(\'href\', \'#page=edit&resource=\' +\n
key + \'&position=\' + position);\n
link.appendChild(document.createTextNode(key));\n
li.appendChild(link);\n
resourceName = document.createTextNode(key);\n
if (key.endsWith(\'.txt\') || key.endsWith(\'.js\') ||\n
key.endsWith(\'.html\') || key.endsWith(\'.py\')) {\n
liContent = document.createElement(\'a\');\n
\n
liContent.setAttribute(\'href\', \'#page=edit&resource=\' +\n
key + \'&position=\' + options.position);\n
liContent.appendChild(resourceName);\n
} else {\n
liContent = resourceName;\n
}\n
li.appendChild(liContent);\n
ul.appendChild(li);\n
}\n
}\n
...
...
@@ -179,9 +252,13 @@
\'submit\',\n
true,\n
function () {\n
gadget.redirect(\n
{position: gadget.props.element.querySelector(\'input\').value}\n
);\n
var input = gadget.props.element.querySelector(\'input\');\n
return gadget.parse(input.value)\n
.push(function (fullCommand) {\n
var args = fullCommand.args,\n
command = fullCommand.command;\n
gadget.browse(command, args);\n
});\n
}\n
);\n
});\n
...
...
@@ -326,7 +403,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
948.
30407.28943.54340
</string>
</value>
<value>
<string>
948.
41948.13894.58197
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -344,7 +421,7 @@
</tuple>
<state>
<tuple>
<float>
1453
118514.19
</float>
<float>
1453
478465.02
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drive/PathTemplateItem/web_page_module/gadget_officejs_drive_page_edit_js.xml
View file @
ac6de042
...
...
@@ -118,8 +118,8 @@
\n
// allow external use of triggerData, so that editor gadget can save\n
// with its own shortcuts/buttons/whatever.\n
.allowPublicAcquisition(\'trigger
Data
\', function () {\n
this.
props.element.querySelector(\'button\').click
();\n
.allowPublicAcquisition(\'trigger
Submit
\', function () {\n
this.
triggerSubmit
();\n
})\n
\n
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")\n
...
...
@@ -135,13 +135,10 @@
format = \'text\';\n
gadget.props.position = options.position || \'/\';\n
gadget.props.resourceName = options.resource;\n
if (gadget.props.resourceName.endsWith(\'.txt\') ||\n
gadget.props.resourceName.endsWith(\'.html\')) {\n
return gadget.jio_getAttachment(gadget.props.position,\n
gadget.props.resourceName,\n
{format: format})\n
.push(function (data) {\n
// XXX: declare gadget here instead?\n
return gadget.getDeclaredGadget(\'codemirror\')\n
.push(function (editorGadget) {\n
gadget.props.editorGadget = editorGadget;\n
...
...
@@ -159,16 +156,6 @@
save_action: true\n
});\n
});\n
}\n
\n
// otherwise: unsupported format\n
return gadget.getDeclaredGadget(\'codemirror\')\n
.push(function (editorGadget) {\n
gadget.props.element.querySelector(\'.message\').textContent =\n
\'Format not supported (yet?).\';\n
// hide device if not considered editable\n
editorGadget.props.element.className = \'ui-screen-hidden\';\n
});\n
})\n
\n
/////////////////////////////////////////\n
...
...
@@ -334,7 +321,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
948.
35950.62357.43776
</string>
</value>
<value>
<string>
948.
41958.9547.3754
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -352,7 +339,7 @@
</tuple>
<state>
<tuple>
<float>
1453
137582.16
</float>
<float>
1453
478990.59
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drive/PathTemplateItem/web_site_module/officejs_drive.xml
View file @
ac6de042
...
...
@@ -271,6 +271,16 @@
<value>
<string>
string
</string>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
configuration_content_security_policy
</string>
</value>
</item>
<item>
<key>
<string>
type
</string>
</key>
<value>
<string>
string
</string>
</value>
</item>
</dictionary>
</tuple>
</value>
</item>
...
...
@@ -317,6 +327,10 @@
<key>
<string>
configuration_application_title
</string>
</key>
<value>
<string>
ERP5
</string>
</value>
</item>
<item>
<key>
<string>
configuration_content_security_policy
</string>
</key>
<value>
<string>
default-src \'none\'; img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' https://localhost:5000 data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data: ; font-src \'self\' https://netdna.bootstrapcdn.com
</string>
</value>
</item>
<item>
<key>
<string>
configuration_default_view_action_reference
</string>
</key>
<value>
<string>
view
</string>
</value>
...
...
@@ -592,7 +606,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
948.
8646.48310.4590
</string>
</value>
<value>
<string>
948.
37660.22124.61781
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -610,7 +624,7 @@
</tuple>
<state>
<tuple>
<float>
145
1480729.71
</float>
<float>
145
3220992.18
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment