Skip to content

Commit

Permalink
Add WOPI (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkode authored Sep 19, 2017
1 parent 44d74a0 commit e835e6e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 21 deletions.
10 changes: 9 additions & 1 deletion apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,15 @@
},
function(result) {
if (result.status === 'success') {
self.add(result.data, {animate: true, scrollTo: true});
var tr = self.add(result.data, {animate: true, scrollTo: true});
if(OCA.WOPIViewer) {
var mime = result.data.mimetype;
if (mime === 'application/vnd.ms-excel' ||
mime === 'application/msword' ||
mime === 'application/vnd.ms-powerpoint') {
$(tr).find('span.innernametext').click();
}
}
deferred.resolve(result.status, result.data);
} else {
if (result.data && result.data.message) {
Expand Down
53 changes: 40 additions & 13 deletions apps/files/js/newfilemenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,49 @@
}
else
{
var items = [{
id: 'file',
displayName: t('files', 'Text file'),
templateName: t('files', 'New text file.txt'),
iconClass: 'icon-filetype-text',
fileType: 'file'
}, {
id: 'folder',
displayName: t('files', 'Folder'),
templateName: t('files', 'New folder'),
iconClass: 'icon-folder',
fileType: 'folder'
}];

if(OCA.WOPIViewer) {
items.push(
{
id: 'file',
displayName: t('files', 'Word'),
templateName: t('files', 'New document.docx'),
iconClass: 'icon-filetype-x-office-document',
fileType: 'file'
}, {
id: 'file',
displayName: t('files', 'Excel'),
templateName: t('files', 'New spreadsheet.xlsx'),
iconClass: 'icon-filetype-x-office-spreadsheet',
fileType: 'file'
}, {
id: 'file',
displayName: t('files', 'PowerPoint'),
templateName: t('files', 'New presentation.pptx'),
iconClass: 'icon-filetype-x-office-presentation',
fileType: 'file'

}
);
}

this.$el.html(this.template({
uploadMaxHumanFileSize: 'TODO',
uploadLabel: t('files', 'Upload'),
items: [{
id: 'file',
displayName: t('files', 'Text file'),
templateName: t('files', 'New text file.txt'),
iconClass: 'icon-filetype-text',
fileType: 'file'
}, {
id: 'folder',
displayName: t('files', 'Folder'),
templateName: t('files', 'New folder'),
iconClass: 'icon-folder',
fileType: 'folder'
}]
items: items
}));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/private/files/objectstore/eosutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@ public static function getMimeType($path, $type){
'pptx' => 'application/vnd.ms-powerpoint',

// open office, open with office 365
'odt' => 'application/msword',
'ods' => 'application/vnd.ms-excel',
//'odt' => 'application/msword',
//'ods' => 'application/vnd.ms-excel',
);

$val = explode('.', $path);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ public static function addSecurityHeaders() {
* @see \OCP\AppFramework\Http\Response::getHeaders
*/
$policy = 'default-src \'self\'; '
. 'script-src \'self\' oos.cern.ch cdnjs.cloudflare.com cdn.mathjax.org \'unsafe-eval\' \'unsafe-inline\'; '
. 'script-src \'self\' oos.web.cern.ch cdnjs.cloudflare.com cdn.mathjax.org \'unsafe-eval\' \'unsafe-inline\'; '
. 'style-src \'self\' \'unsafe-inline\'; '
. 'frame-src *; '
. 'img-src * data: blob:; '
. 'font-src \'self\' oos.cern.ch cdn.mathjax.org data: blob:; '
. 'font-src \'self\' oos.web.cern.ch cdn.mathjax.org data: blob:; '
. 'media-src *; '
. 'connect-src *';
header('Content-Security-Policy:' . $policy);
Expand Down
6 changes: 3 additions & 3 deletions lib/public/appframework/http/contentsecuritypolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ContentSecurityPolicy {
/** @var array Domains from which scripts can get loaded */
private $allowedScriptDomains = [
'\'self\'',
'oos.cern.ch',
'oos.web.cern.ch',
'cdnjs.cloudflare.com',
'cdn.mathjax.org',
];
Expand Down Expand Up @@ -82,13 +82,13 @@ class ContentSecurityPolicy {
private $allowedObjectDomains = [];
/** @var array Domains from which iframes can be loaded */
private $allowedFrameDomains = [
'oos.cern.ch',
'oos.web.cern.ch',
];
/** @var array Domains from which fonts can be loaded */
private $allowedFontDomains = [
'\'self\'',
'cdn.mathjax.org',
'oos.cern.ch',
'oos.web.cern.ch',
];
/** @var array Domains from which web-workers and nested browsing content can load elements */
private $allowedChildSrcDomains = [];
Expand Down

0 comments on commit e835e6e

Please sign in to comment.