diff --git a/css/admin.css b/css/admin.css index 3a961eca..6a5d4af2 100644 --- a/css/admin.css +++ b/css/admin.css @@ -1,3 +1,6 @@ +.rd-settings-documentation { + max-width: 50em; +}; #richdocuments h2 { display: inline-block; -} +} \ No newline at end of file diff --git a/js/admin.js b/js/admin.js index ed381f29..30f6cf89 100644 --- a/js/admin.js +++ b/js/admin.js @@ -72,6 +72,16 @@ var documentsSettings = { ); }, + saveWebroot: function(value) { + var data = { + 'canonical_webroot': value + }; + $.post( + OC.filePath('richdocuments', 'ajax', 'admin.php'), + data + ); + }, + afterSaveExternalApps: function(response) { OC.msg.finishedAction('#enable-external-apps-section-msg', response); }, @@ -233,6 +243,22 @@ var documentsSettings = { $select.change(); }); + $(document).on('change', '#enable_canonical_webroot_cb-richdocuments', function() { + var page = $(this).parent(); + + page.find('#enable-canonical-webroot-section').toggleClass('hidden', !this.checked); + if (!this.checked) { + documentsSettings.saveWebroot(''); + } else { + var val = $('#canonical-webroot').val(); + if (val) + documentsSettings.saveWebroot(); + } + }); + + $(document).on('change', '#canonical-webroot', function() { + documentsSettings.saveWebroot(this.value); + }); } }; diff --git a/js/documents.js b/js/documents.js index de539983..e7900b18 100644 --- a/js/documents.js +++ b/js/documents.js @@ -71,6 +71,19 @@ var documentsMain = { renderComplete: false, // false till page is rendered with all required data about the document(s) toolbar : '
', + // generates docKey for given fileId + _generateDocKey: function(wopiFileId) { + var ocurl = OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: wopiFileId}); + if (richdocuments_canonical_webroot) { + if (!richdocuments_canonical_webroot.startsWith('/')) + richdocuments_canonical_webroot = '/' + richdocuments_canonical_webroot; + + ocurl = ocurl.replace(OC.webroot, richdocuments_canonical_webroot); + } + + return ocurl; + }, + UI : { /* Editor wrapper HTML */ container : '
' + @@ -115,189 +128,9 @@ var documentsMain = { $('#revViewerContainer').prepend($('
')); } + var ocurl = documentsMain._generateDocKey(fileId); // WOPISrc - URL that loolwsd will access (ie. pointing to ownCloud) - var wopiurl = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: fileId}); - var wopisrc = encodeURIComponent(wopiurl); - - // urlsrc - the URL from discovery xml that we access for the particular - // document; we add various parameters to that. - // The discovery is available at - // https://:9980/hosting/discovery - var urlsrc = documentsMain.urlsrc + - "WOPISrc=" + wopisrc + - "&title=" + encodeURIComponent(title) + - "&lang=" + OC.getLocale().replace('_', '-') + // loleaflet expects a BCP47 language tag syntax - "&permission=readonly"; - - // access_token - must be passed via a form post - var access_token = encodeURIComponent(documentsMain.token); - - // form to post the access token for WOPISrc - var form = '
' + - '
'; - - // iframe that contains the Collabora Online Viewer - var frame = '