Skip to content

Commit

Permalink
Feed different arguments to Files.Client depending on the user (logge…
Browse files Browse the repository at this point in the history
…d-in/public)
  • Loading branch information
oparoz committed Mar 11, 2016
1 parent a5cf724 commit fe25174
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ $(document).ready(function () {
Gallery.view = new Gallery.View();
Gallery.token = Gallery.utility.getPublicToken();
Gallery.ieVersion = Gallery.utility.getIeVersion();
Gallery.filesClient = new OC.Files.Client({
host: Gallery.utility.getWebdavHost(),
port: OC.getPort(),
root: Gallery.utility.getWebdavRoot(),
useHTTPS: OC.getProtocol() === 'https'
});

// The first thing to do is to detect if we're on IE
if (Gallery.ieVersion === 'unsupportedIe') {
Expand Down
2 changes: 1 addition & 1 deletion js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
activeSlideShow: null,
buttonsWidth: 350,
browserToolbarHeight: 150,
filesClient: OC.Files.getClient(),
filesClient: null,

/**
* Refreshes the view and starts the slideshow if required
Expand Down
30 changes: 30 additions & 0 deletions js/galleryutility.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@ window.Gallery = window.Gallery || {};
return token;
},

/**
* Returns the host we can use for WebDAV
*
* On public galleries, we need to provide the token as authorization
*
* @returns {string}
*/
getWebdavHost: function () {
var host = OC.getHost();
if (Gallery.token) {
host = Gallery.token + '@' + host;
}

return host;
},

/**
* Returns the WebDAV endpoint we can use for files operations
*
* @returns {string}
*/
getWebdavRoot: function () {
var root = OC.linkToRemoteBase('webdav');
if (Gallery.token) {
root = root.replace('remote.php', 'public.php');
}

return root;
},

/**
* Builds the URL which will retrieve a large preview of the file
*
Expand Down

0 comments on commit fe25174

Please sign in to comment.