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 : '
' +
@@ -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 = '';
-
- $('#revViewer').append(form);
- $('#revViewer').append(frame);
-
- // submit that
- $('#loleafletform_viewer').submit();
- documentsMain.isViewerMode = true;
-
- // for closing revision mode
- $('#revPanelHeader .closeButton').click(function(e) {
- e.preventDefault();
- documentsMain.onCloseViewer();
- });
- },
-
- addRevision: function(fileId, version, relativeTimestamp, documentPath) {
- var formattedTimestamp = OC.Util.formatDate(parseInt(version) * 1000);
- var fileName = documentsMain.fileName.substring(0, documentsMain.fileName.indexOf('.'));
- var downloadUrl, restoreUrl;
- if (version === 0) {
- formattedTimestamp = t('richdocuments', 'Latest revision');
- downloadUrl = OC.generateUrl('apps/files/download'+ documentPath);
- } else {
- downloadUrl = OC.generateUrl('apps/files_versions/download.php?file={file}&revision={revision}',
- {file: documentPath, revision: version});
- fileId = fileId + '_' + version;
- restoreUrl = OC.generateUrl('apps/files_versions/ajax/rollbackVersion.php?file={file}&revision={revision}',
- {file: documentPath, revision: version});
- }
-
- var revHistoryItemTemplate = Handlebars.compile(documentsMain.UI.revHistoryItemTemplate);
- var html = revHistoryItemTemplate({
- downloadUrl: downloadUrl,
- downloadIconUrl: OC.imagePath('core', 'actions/download'),
- restoreUrl: restoreUrl,
- restoreIconUrl: OC.imagePath('core', 'actions/history'),
- relativeTimestamp: relativeTimestamp,
- formattedTimestamp: formattedTimestamp
- });
-
- html = $(html).attr('data-fileid', fileId)
- .attr('data-title', fileName + ' - ' + formattedTimestamp);
- $('#revisionsContainer ul').append(html);
- },
-
- fetchAndFillRevisions: function(documentPath) {
- // fill #rev-history with file versions
- $.get(OC.generateUrl('apps/files_versions/ajax/getVersions.php?source={documentPath}&start={start}',
- { documentPath: documentPath, start: documentsMain.UI.revisionsStart }),
- function(result) {
- for(var key in result.data.versions) {
- documentsMain.UI.addRevision(documentsMain.fileId,
- result.data.versions[key].version,
- result.data.versions[key].humanReadableTimestamp,
- documentPath);
- }
-
- // owncloud only gives 5 version at max in one go
- documentsMain.UI.revisionsStart += 5;
-
- if (result.data.endReached) {
- // Remove 'More versions' button
- $('#show-more-versions').addClass('hidden');
- }
- });
- },
-
- showRevHistory: function(documentPath) {
- $(document.body).prepend(documentsMain.UI.viewContainer);
-
- var revHistoryContainerTemplate = Handlebars.compile(documentsMain.UI.revHistoryContainerTemplate);
- var revHistoryContainer = revHistoryContainerTemplate({
- filename: documentsMain.fileName,
- moreVersionsLabel: t('richdocuments', 'More versions…'),
- closeButtonUrl: OC.imagePath('core', 'actions/close')
- });
- $('#revViewerContainer').prepend(revHistoryContainer);
-
- documentsMain.UI.revisionsStart = 0;
-
- // append current document first
- documentsMain.UI.addRevision(documentsMain.fileId, 0, t('richdocuments', 'Just now'), documentPath);
-
- // add "Show more versions" button
- $('#show-more-versions').click(function(e) {
- e.preventDefault();
- documentsMain.UI.fetchAndFillRevisions(documentPath);
- });
-
- // fake click to load first 5 versions
- $('#show-more-versions').click();
-
- // make these revisions clickable/attach functionality
- $('#revisionsContainer').on('click', '.versionPreview', function(e) {
- e.preventDefault();
- documentsMain.UI.showViewer(e.currentTarget.parentElement.dataset.fileid,
- e.currentTarget.parentElement.dataset.title);
-
- // mark only current as active
- $(e.currentTarget.parentElement.parentElement).find('li').removeClass('active');
- $(e.currentTarget.parentElement).addClass('active');
- });
-
- $('#revisionsContainer').on('click', '.restoreVersion', function(e) {
- e.preventDefault();
-
- // close the viewer
- documentsMain.onCloseViewer();
-
- // close the editor
- documentsMain.UI.hideEditor();
-
- // If there are changes in the opened editor, we need to wait
- // for sometime before these changes can be saved and a revision is created for it,
- // before restoring to requested version.
- documentsMain.overlay.documentOverlay('show');
- setTimeout(function() {
- // restore selected version
- $.ajax({
- type: 'GET',
- url: e.currentTarget.href,
- success: function(response) {
- if (response.status === 'error') {
- documentsMain.UI.notify(t('richdocuments', 'Failed to revert the document to older version'));
- }
-
- // load the file again, it should get reverted now
- window.location = OC.generateUrl('apps/richdocuments/index#{fileid}', {fileid: e.currentTarget.parentElement.dataset.fileid});
- window.location.reload();
- documentsMain.overlay.documentOverlay('hide');
- }
- });
- }, 1000);
- });
-
- // fake click on first revision (i.e current revision)
- $('#revisionsContainer li').first().find('.versionPreview').click();
- },
-
- showEditor : function(title, fileId, action){
- if (documentsMain.loadError) {
- documentsMain.onEditorShutdown(documentsMain.loadErrorMessage + '\n' + documentsMain.loadErrorHint);
- return;
- }
-
- if (!documentsMain.renderComplete) {
- setTimeout(function() { documentsMain.UI.showEditor(title, action); }, 500);
- console.log('Waiting for page to render…');
- return;
- }
- parent.postMessage('loading', '*');
-
- $(document.body).addClass("claro");
- $(document.body).prepend(documentsMain.UI.container);
-
- parent.document.title = title + ' - ' + documentsMain.UI.mainTitle;
-
- // 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: documentsMain.fileId});
- var wopisrc = encodeURIComponent(wopiurl);
+ var wopiurl = window.location.protocol + '//' + window.location.host + ocurl;
// urlsrc - the URL from discovery xml that we access for the particular
// document; we add various parameters to that.
diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php
index ba316498..c3ef7413 100644
--- a/lib/Controller/DocumentController.php
+++ b/lib/Controller/DocumentController.php
@@ -174,6 +174,7 @@ class DocumentController extends Controller {
'urlsrc' => $urlSrc,
'path' => $folder->getRelativePath($item->getPath()),
'instanceId' => $this->settings->getSystemValue('instanceid'),
+ 'canonical_webroot' => $this->appConfig->getAppValue('canonical_webroot'),
];
$encryptionManager = \OC::$server->getEncryptionManager();
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php
index 60a4c10b..a62afa33 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -64,13 +64,16 @@ class SettingsController extends Controller{
* @param string $edit_groups
* @param string $use_groups
* @param string $doc_format
+ * @param string $external_apps
+ * @param string $canonical_webroot
* @return JSONResponse
*/
public function setSettings($wopi_url,
- $edit_groups,
+ $edit_groups,
$use_groups,
$doc_format,
- $external_apps){
+ $external_apps,
+ $canonical_webroot) {
$message = $this->l10n->t('Saved');
if ($wopi_url !== null){
@@ -98,6 +101,10 @@ class SettingsController extends Controller{
$this->appConfig->setAppValue('external_apps', $external_apps);
}
+ if ($canonical_webroot !== null) {
+ $this->appConfig->setAppValue('canonical_webroot', $canonical_webroot);
+ }
+
$this->discoveryManager->refretch();
$response = [
diff --git a/templates/.#admin.php b/templates/.#admin.php
new file mode 120000
index 00000000..a4639b09
--- /dev/null
+++ b/templates/.#admin.php
@@ -0,0 +1 @@
+pranavk@pranavk.local.me.15425:1516137457
\ No newline at end of file
diff --git a/templates/admin.php b/templates/admin.php
index be3aa36b..df40e1f2 100644
--- a/templates/admin.php
+++ b/templates/admin.php
@@ -26,7 +26,7 @@ script('richdocuments', 'admin');
/>
t('Use OOXML by default for new files')) ?>
- />
+ />
t('Enable access for external apps')) ?>
@@ -36,5 +36,13 @@ script('richdocuments', 'admin');
t('Save')) ?>
t('Add')) ?>
+
+
+
/>
+
t('Use Canonical webroot')) ?>
+
+
+
+
t('Canonical webroot, in case there are multiple, for Collabora to use. Provide the one with least restrictions. Eg: Use non-shibbolized webroot if this instance is accessed by both shibbolized and non-shibbolized webroots. You can ignore this setting if only one webroot is used to access this instance.')) ?>
diff --git a/templates/documents.php b/templates/documents.php
index 528a1505..b34479e5 100644
--- a/templates/documents.php
+++ b/templates/documents.php
@@ -6,6 +6,7 @@
var richdocuments_urlsrc = '';
var richdocuments_path = '';
var instanceId = '';
+ var richdocuments_canonical_webroot = '';