diff --git a/app/picasa.js b/app/picasa.js new file mode 100644 index 00000000..1fb4c82d --- /dev/null +++ b/app/picasa.js @@ -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); +}; \ No newline at end of file diff --git a/package.json b/package.json index 7150c6f5..dfcba14f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/public/res/core.js b/public/res/core.js index 61946b83..0da279cd 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -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(); }); diff --git a/public/res/mediaImporter.js b/public/res/mediaImporter.js index 43bfdaac..4b5dc3dd 100644 --- a/public/res/mediaImporter.js +++ b/public/res/mediaImporter.js @@ -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; }); \ No newline at end of file