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