mirror of https://github.com/perkeep/perkeep.git
adds support for username and password in camliserver spec
This commit is contained in:
parent
b6a9d5ec10
commit
246cacd2f8
|
@ -29,16 +29,23 @@
|
|||
|
||||
// Preferences
|
||||
var ALBUM_CONFIG = {}; // 'type' -> ('id' -> 'name')
|
||||
var ALBUM_OPTIONS = {}; // 'type' -> ('id' -> optionsDict)
|
||||
|
||||
function loadAlbumConfig() {
|
||||
var newAlbumConfig = localStorage.getItem('config:albums');
|
||||
if (newAlbumConfig) {
|
||||
ALBUM_CONFIG = $.parseJSON(newAlbumConfig);
|
||||
}
|
||||
|
||||
var newAlbumOptions = localStorage.getItem('config:albumOptions');
|
||||
if (newAlbumOptions) {
|
||||
ALBUM_OPTIONS = $.parseJSON(newAlbumOptions);
|
||||
}
|
||||
}
|
||||
|
||||
function saveAlbumConfig() {
|
||||
localStorage.setItem('config:albums', JSON.stringify(ALBUM_CONFIG));
|
||||
localStorage.setItem('config:albumOptions', JSON.stringify(ALBUM_OPTIONS));
|
||||
}
|
||||
|
||||
// Sort albums by name.
|
||||
|
@ -127,6 +134,7 @@
|
|||
dataBuffer, uploadDone) {
|
||||
var hash = Crypto.SHA1(new Uint8Array(dataBuffer, 0));
|
||||
var blobRef = 'sha1-' + hash;
|
||||
var options = ALBUM_OPTIONS[CAMLISTORE][albumId];
|
||||
|
||||
function doUpload(uploadUrl) {
|
||||
// XXX Use real random boundary.
|
||||
|
@ -147,7 +155,8 @@
|
|||
var payload = builder.getBlob(contentType);
|
||||
|
||||
var uploadXhr = new XMLHttpRequest();
|
||||
uploadXhr.open('POST', uploadUrl, true);
|
||||
uploadXhr.open('POST', uploadUrl, true,
|
||||
options.username, options.password);
|
||||
uploadXhr.onreadystatechange = function() {
|
||||
if (uploadXhr.readyState == XMLHttpRequest.DONE &&
|
||||
uploadXhr.status == 200) {
|
||||
|
@ -172,7 +181,8 @@
|
|||
}
|
||||
|
||||
var preUploadXhr = new XMLHttpRequest();
|
||||
preUploadXhr.open('POST', albumId + '/camli/preupload', true);
|
||||
preUploadXhr.open('POST', albumId + '/camli/preupload', true,
|
||||
options.username, options.password);
|
||||
preUploadXhr.onreadystatechange = function() {
|
||||
if (preUploadXhr.readyState == XMLHttpRequest.DONE &&
|
||||
preUploadXhr.status == 200) {
|
||||
|
|
|
@ -208,7 +208,15 @@
|
|||
if (!BG.ALBUM_CONFIG[BG.CAMLISTORE]) {
|
||||
BG.ALBUM_CONFIG[BG.CAMLISTORE] = {};
|
||||
}
|
||||
BG.ALBUM_CONFIG[BG.CAMLISTORE][urlInput.val()] = nameInput.val();
|
||||
if (!BG.ALBUM_OPTIONS[BG.CAMLISTORE]) {
|
||||
BG.ALBUM_OPTIONS[BG.CAMLISTORE] = {};
|
||||
}
|
||||
var albumId = urlInput.val();
|
||||
BG.ALBUM_CONFIG[BG.CAMLISTORE][albumId] = nameInput.val();
|
||||
BG.ALBUM_OPTIONS[BG.CAMLISTORE][albumId] = {
|
||||
'username': $('#camliserver-username').val(),
|
||||
'password': $('#camliserver-password').val()
|
||||
};
|
||||
|
||||
BG.saveAlbumConfig();
|
||||
populateAlbumList();
|
||||
|
@ -259,7 +267,7 @@ Connecting an album to <em>Clip It Good</em> will require giving this extension
|
|||
Extension and source licensed under the
|
||||
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License,
|
||||
Version 2.0</a>. Uses <a href="http://jqueryui.com/">jQuery UI</a> (MIT/GPL),
|
||||
<a href="http://www.json.org/js.html">json2 parser</a> (free domain),
|
||||
<a href="http://www.json.org/js.html">json2 parser</a> (public domain),
|
||||
<a href="http://code.google.com/p/javascriptbase64/">Fred Palmer's Base64</a>
|
||||
(BSD compat), and <a href="http://code.google.com/p/crypto-js/">Jeff
|
||||
Mott's SHA1</a> (BSD compat).
|
||||
|
@ -276,12 +284,20 @@ Connecting an album to <em>Clip It Good</em> will require giving this extension
|
|||
<div id="camliserver-config" style="display: none;">
|
||||
<table width="100%" border="0">
|
||||
<tr>
|
||||
<td><label for="camliserver-url">Blobserver URL:</label></td>
|
||||
<td><input type="text" id="camliserver-url" size="35"></td>
|
||||
<td><label for="camliserver-url">Blobserver URL:</label></td>
|
||||
<td><input type="text" id="camliserver-url" size="30"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="camliserver-name">Pretty name:</label></td>
|
||||
<td><input type="text" id="camliserver-name" size="35"></td>
|
||||
<td><label for="camliserver-name">Pretty name:</label></td>
|
||||
<td><input type="text" id="camliserver-name" size="30"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="camliserver-username">Username:</label></td>
|
||||
<td><input type="text" id="camliserver-username" size="30"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="camliserver-password">Password:</label></td>
|
||||
<td><input type="text" id="camliserver-password" size="30"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue