Integrated stackedit-picasa-proxy service
This commit is contained in:
parent
a037fb31a8
commit
3952ab6af1
16
app/picasa.js
Normal file
16
app/picasa.js
Normal file
@ -0,0 +1,16 @@
|
||||
var request = require('request');
|
||||
|
||||
exports.importImg = function(req, res) {
|
||||
var stream = req.pipe(request.post({
|
||||
uri: 'https://picasaweb.google.com/data/feed/api/user/default/albumid/' + req.query.albumId,
|
||||
headers: {
|
||||
'Authorization': req.headers.authorization,
|
||||
'Content-Type': req.headers['content-type'],
|
||||
'Slug': req.headers.slug
|
||||
}
|
||||
}));
|
||||
stream.on('error', function(err) {
|
||||
res.send(400, err);
|
||||
});
|
||||
stream.pipe(res);
|
||||
};
|
@ -13,7 +13,8 @@
|
||||
"dependencies": {
|
||||
"express": "~3.16.6",
|
||||
"ejs": "~0.8.4",
|
||||
"request": "~2.40.0"
|
||||
"request": "~2.40.0",
|
||||
"ssh2": "^0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt-contrib-requirejs": "~0.4.3",
|
||||
|
@ -145,8 +145,6 @@ define([
|
||||
utils.setInputValue("#textarea-settings-pdf-template", settings.pdfTemplate);
|
||||
// PDF options
|
||||
utils.setInputValue("#textarea-settings-pdf-options", settings.pdfOptions);
|
||||
// SSH proxy
|
||||
utils.setInputValue("#input-settings-ssh-proxy", settings.sshProxy);
|
||||
|
||||
// Load extension settings
|
||||
eventMgr.onLoadSettings();
|
||||
@ -192,8 +190,6 @@ define([
|
||||
newSettings.pdfTemplate = utils.getInputTextValue("#textarea-settings-pdf-template", event);
|
||||
// PDF options
|
||||
newSettings.pdfOptions = utils.getInputJSONValue("#textarea-settings-pdf-options", event);
|
||||
// SSH proxy
|
||||
newSettings.sshProxy = utils.checkUrl(utils.getInputTextValue("#input-settings-ssh-proxy", event), true);
|
||||
|
||||
// Save extension settings
|
||||
newSettings.extensionSettings = {};
|
||||
@ -509,9 +505,9 @@ define([
|
||||
storage.clear();
|
||||
var allowedKeys = /^file\.|^folder\.|^publish\.|^settings$|^sync\.|^google\.|^author\.|^themeV4$|^version$/;
|
||||
_.each(newstorage, function(value, key) {
|
||||
//if(allowedKeys.test(key)) {
|
||||
if(allowedKeys.test(key)) {
|
||||
storage[key] = value;
|
||||
//}
|
||||
}
|
||||
});
|
||||
window.location.reload();
|
||||
});
|
||||
|
@ -1,85 +1,85 @@
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"constants",
|
||||
"classes/Provider",
|
||||
"core",
|
||||
"eventMgr",
|
||||
"providers/gplusProvider"
|
||||
"jquery",
|
||||
"underscore",
|
||||
"constants",
|
||||
"classes/Provider",
|
||||
"core",
|
||||
"eventMgr",
|
||||
"providers/gplusProvider"
|
||||
], function($, _, constants, Provider, core, eventMgr) {
|
||||
|
||||
var mediaImporter = {};
|
||||
var mediaImporter = {};
|
||||
|
||||
// Create a map with providerId: providerModule
|
||||
var providerMap = _.chain(arguments).map(function(argument) {
|
||||
return argument instanceof Provider && [
|
||||
argument.providerId,
|
||||
argument
|
||||
];
|
||||
}).compact().object().value();
|
||||
// Create a map with providerId: providerModule
|
||||
var providerMap = _.chain(arguments).map(function(argument) {
|
||||
return argument instanceof Provider && [
|
||||
argument.providerId,
|
||||
argument
|
||||
];
|
||||
}).compact().object().value();
|
||||
|
||||
eventMgr.addListener("onReady", function() {
|
||||
_.each(providerMap, function(provider) {
|
||||
// Import image action links (if any)
|
||||
$(".action-import-image-" + provider.providerId).click(function() {
|
||||
// Take the insertLinkCallback from core module
|
||||
var insertLinkCallback = core.insertLinkCallback;
|
||||
// Unset it to be sure core module will not call it
|
||||
core.insertLinkCallback = undefined;
|
||||
provider.importImage(function(error, imageLink) {
|
||||
if(error) {
|
||||
insertLinkCallback(null);
|
||||
return;
|
||||
}
|
||||
insertLinkCallback(imageLink || null);
|
||||
});
|
||||
});
|
||||
});
|
||||
eventMgr.addListener("onReady", function() {
|
||||
_.each(providerMap, function(provider) {
|
||||
// Import image action links (if any)
|
||||
$(".action-import-image-" + provider.providerId).click(function() {
|
||||
// Take the insertLinkCallback from core module
|
||||
var insertLinkCallback = core.insertLinkCallback;
|
||||
// Unset it to be sure core module will not call it
|
||||
core.insertLinkCallback = undefined;
|
||||
provider.importImage(function(error, imageLink) {
|
||||
if(error) {
|
||||
insertLinkCallback(null);
|
||||
return;
|
||||
}
|
||||
insertLinkCallback(imageLink || null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function handleImgImport(evt) {
|
||||
var files = (evt.dataTransfer || evt.target).files;
|
||||
var file = _.first(files);
|
||||
if(file.name.match(/.(jpe?g|png|gif)$/i)) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
var reader = new FileReader();
|
||||
reader.onload = (function(importedFile) {
|
||||
return function(e) {
|
||||
var content = new Uint8Array(e.target.result);
|
||||
providerMap.gplus.uploadImage(importedFile.name, content, function(error, imageLink) {
|
||||
if(error) {
|
||||
return;
|
||||
}
|
||||
// Generate an insertLinkCallback by clicking the
|
||||
// pagedown button but without showing the dialog
|
||||
core.catchModal = true;
|
||||
$("#wmd-image-button").click();
|
||||
core.catchModal = false;
|
||||
// Take the insertLinkCallback from core module
|
||||
var insertLinkCallback = core.insertLinkCallback;
|
||||
// Unset it to be sure core module will not call it
|
||||
core.insertLinkCallback = undefined;
|
||||
insertLinkCallback(imageLink || null);
|
||||
});
|
||||
};
|
||||
})(file);
|
||||
var blob = file.slice(0, constants.IMPORT_IMG_MAX_CONTENT_SIZE);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
}
|
||||
function handleImgImport(evt) {
|
||||
var files = (evt.dataTransfer || evt.target).files;
|
||||
var file = _.first(files);
|
||||
if(file.name.match(/.(jpe?g|png|gif)$/i)) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
var reader = new FileReader();
|
||||
reader.onload = (function(importedFile) {
|
||||
return function(e) {
|
||||
var content = new Uint8Array(e.target.result);
|
||||
providerMap.gplus.uploadImage(importedFile.name, content, function(error, imageLink) {
|
||||
if(error) {
|
||||
return;
|
||||
}
|
||||
// Generate an insertLinkCallback by clicking the
|
||||
// pagedown button but without showing the dialog
|
||||
core.catchModal = true;
|
||||
$("#wmd-image-button").click();
|
||||
core.catchModal = false;
|
||||
// Take the insertLinkCallback from core module
|
||||
var insertLinkCallback = core.insertLinkCallback;
|
||||
// Unset it to be sure core module will not call it
|
||||
core.insertLinkCallback = undefined;
|
||||
insertLinkCallback(imageLink || null);
|
||||
});
|
||||
};
|
||||
})(file);
|
||||
var blob = file.slice(0, constants.IMPORT_IMG_MAX_CONTENT_SIZE);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDragOver(evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
evt.dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
function handleDragOver(evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
evt.dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
|
||||
$('#wmd-input').each(function() {
|
||||
this.addEventListener('dragover', handleDragOver, false);
|
||||
this.addEventListener('drop', handleImgImport, false);
|
||||
});
|
||||
!window.viewerMode && (function(dragAndDropElt) {
|
||||
dragAndDropElt.addEventListener('dragover', handleDragOver, false);
|
||||
dragAndDropElt.addEventListener('drop', handleImgImport, false);
|
||||
})(document.querySelector('.layout-wrapper-l3'));
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
return mediaImporter;
|
||||
return mediaImporter;
|
||||
});
|
Loading…
Reference in New Issue
Block a user