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
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
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
Hide 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 @@
...
@@ -130,39 +130,112 @@
.declareAcquiredMethod("jio_allAttachments", "jio_allAttachments")\n
.declareAcquiredMethod("jio_allAttachments", "jio_allAttachments")\n
.declareAcquiredMethod("redirect", "redirect")\n
.declareAcquiredMethod("redirect", "redirect")\n
\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
\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
var gadget = this,\n
ul = gadget.props.element.querySelector(\'ul
\'),\n
position = args[0].split(\'/
\'),\n
position = options.position || \'/\'
;\n
resource = position.pop()
;\n
\n
\n
if (!position.startsWith(\'/\')) {\n
function absolutePosition(current, requested) {\n
position = \'/\' + position;\n
var pos;\n
if (requested.startsWith(\'/\')) {\n
pos = \'/\' + requested + \'/\';\n
} else {\n
pos = \'/\' + current + \'/\' + requested + \'/\';\n
}\n
return pos.replace(/\\/+/g, \'/\');\n
}\n
}\n
if (!position.endsWith(\'/\')) {\n
\n
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
\n
\n
gadget.props.element.querySelector(\'input\').value = position;\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
\n
// clean previous ul children\n
// clean previous ul children\n
while (ul.hasChildNodes()) {\n
while (ul.hasChildNodes()) {\n
ul.removeChild(ul.firstChild);\n
ul.removeChild(ul.firstChild);\n
}\n
}\n
\n
\n
return gadget.jio_allAttachments(position)\n
return gadget.jio_allAttachments(
options.
position)\n
.push(function (all) {\n
.push(function (all) {\n
var key,\n
var key,\n
li,\n
li,\n
link;\n
liContent,\n
resourceName;\n
for (key in all) {\n
for (key in all) {\n
if (all.hasOwnProperty(key)) {\n
if (all.hasOwnProperty(key)) {\n
li = document.createElement(\'li\');\n
li = document.createElement(\'li\');\n
link = document.createElement(\'a\');\n
resourceName = document.createTextNode(key);\n
link.setAttribute(\'href\', \'#page=edit&resource=\' +\n
if (key.endsWith(\'.txt\') || key.endsWith(\'.js\') ||\n
key + \'&position=\' + position);\n
key.endsWith(\'.html\') || key.endsWith(\'.py\')) {\n
link.appendChild(document.createTextNode(key));\n
liContent = document.createElement(\'a\');\n
li.appendChild(link);\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
ul.appendChild(li);\n
}\n
}\n
}\n
}\n
...
@@ -179,9 +252,13 @@
...
@@ -179,9 +252,13 @@
\'submit\',\n
\'submit\',\n
true,\n
true,\n
function () {\n
function () {\n
gadget.redirect(\n
var input = gadget.props.element.querySelector(\'input\');\n
{position: gadget.props.element.querySelector(\'input\').value}\n
return gadget.parse(input.value)\n
);\n
.push(function (fullCommand) {\n
var args = fullCommand.args,\n
command = fullCommand.command;\n
gadget.browse(command, args);\n
});\n
}\n
}\n
);\n
);\n
});\n
});\n
...
@@ -326,7 +403,7 @@
...
@@ -326,7 +403,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
948.
30407.28943.54340
</string>
</value>
<value>
<string>
948.
41948.13894.58197
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -344,7 +421,7 @@
...
@@ -344,7 +421,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1453
118514.19
</float>
<float>
1453
478465.02
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_officejs_drive/PathTemplateItem/web_page_module/gadget_officejs_drive_page_edit_js.xml
View file @
ac6de042
...
@@ -118,8 +118,8 @@
...
@@ -118,8 +118,8 @@
\n
\n
// allow external use of triggerData, so that editor gadget can save\n
// allow external use of triggerData, so that editor gadget can save\n
// with its own shortcuts/buttons/whatever.\n
// with its own shortcuts/buttons/whatever.\n
.allowPublicAcquisition(\'trigger
Data
\', function () {\n
.allowPublicAcquisition(\'trigger
Submit
\', function () {\n
this.
props.element.querySelector(\'button\').click
();\n
this.
triggerSubmit
();\n
})\n
})\n
\n
\n
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")\n
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")\n
...
@@ -135,39 +135,26 @@
...
@@ -135,39 +135,26 @@
format = \'text\';\n
format = \'text\';\n
gadget.props.position = options.position || \'/\';\n
gadget.props.position = options.position || \'/\';\n
gadget.props.resourceName = options.resource;\n
gadget.props.resourceName = options.resource;\n
if (gadget.props.resourceName.endsWith(\'.txt\') ||\n
return gadget.jio_getAttachment(gadget.props.position,\n
gadget.props.resourceName.endsWith(\'.html\')) {\n
gadget.props.resourceName,\n
return gadget.jio_getAttachment(gadget.props.position,\n
{format: format})\n
gadget.props.resourceName,\n
.push(function (data) {\n
{format: format})\n
return gadget.getDeclaredGadget(\'codemirror\')\n
.push(function (data) {\n
.push(function (editorGadget) {\n
// XXX: declare gadget here instead?\n
gadget.props.editorGadget = editorGadget;\n
return gadget.getDeclaredGadget(\'codemirror\')\n
return editorGadget.render({\n
.push(function (editorGadget) {\n
data: data,\n
gadget.props.editorGadget = editorGadget;\n
resource: gadget.props.resourceName\n
return editorGadget.render({\n
data: data,\n
resource: gadget.props.resourceName\n
});\n
});\n
});\n
})\n
\n
.push(function () {\n
return gadget.updateHeader({\n
title: \'Editing \' + gadget.props.resourceName +\n
\' at \' + gadget.props.position,\n
save_action: true\n
});\n
});\n
});\n
})\n
}\n
\n
\n
// otherwise: unsupported format\n
.push(function () {\n
return gadget.getDeclaredGadget(\'codemirror\')\n
return gadget.updateHeader({\n
.push(function (editorGadget) {\n
title: \'Editing \' + gadget.props.resourceName +\n
gadget.props.element.querySelector(\'.message\').textContent =\n
\' at \' + gadget.props.position,\n
\'Format not supported (yet?).\';\n
save_action: true\n
// hide device if not considered editable\n
});\n
editorGadget.props.element.className = \'ui-screen-hidden\';\n
});\n
});\n
})\n
})\n
\n
\n
...
@@ -334,7 +321,7 @@
...
@@ -334,7 +321,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
948.
35950.62357.43776
</string>
</value>
<value>
<string>
948.
41958.9547.3754
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -352,7 +339,7 @@
...
@@ -352,7 +339,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1453
137582.16
</float>
<float>
1453
478990.59
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_officejs_drive/PathTemplateItem/web_site_module/officejs_drive.xml
View file @
ac6de042
...
@@ -271,6 +271,16 @@
...
@@ -271,6 +271,16 @@
<value>
<string>
string
</string>
</value>
<value>
<string>
string
</string>
</value>
</item>
</item>
</dictionary>
</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>
</tuple>
</value>
</value>
</item>
</item>
...
@@ -317,6 +327,10 @@
...
@@ -317,6 +327,10 @@
<key>
<string>
configuration_application_title
</string>
</key>
<key>
<string>
configuration_application_title
</string>
</key>
<value>
<string>
ERP5
</string>
</value>
<value>
<string>
ERP5
</string>
</value>
</item>
</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>
<item>
<key>
<string>
configuration_default_view_action_reference
</string>
</key>
<key>
<string>
configuration_default_view_action_reference
</string>
</key>
<value>
<string>
view
</string>
</value>
<value>
<string>
view
</string>
</value>
...
@@ -592,7 +606,7 @@
...
@@ -592,7 +606,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
948.
8646.48310.4590
</string>
</value>
<value>
<string>
948.
37660.22124.61781
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -610,7 +624,7 @@
...
@@ -610,7 +624,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
145
1480729.71
</float>
<float>
145
3220992.18
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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