From d172aaad1b634865fc8286adbde7da82f656ccc6 Mon Sep 17 00:00:00 2001 From: benweet Date: Sat, 21 Sep 2013 13:04:50 +0100 Subject: [PATCH] Set content type to 'text/html' when publishing to Google Drive using HTML or template output --- res/helpers/googleHelper.js | 4 ++-- res/providers/gdriveProvider.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/res/helpers/googleHelper.js b/res/helpers/googleHelper.js index 9054552c..ca0e2120 100644 --- a/res/helpers/googleHelper.js +++ b/res/helpers/googleHelper.js @@ -99,7 +99,7 @@ define([ task.enqueue(); }; - googleHelper.upload = function(fileId, parentId, title, content, etag, callback) { + googleHelper.upload = function(fileId, parentId, title, content, contentType, etag, callback) { var result = undefined; var task = new AsyncTask(); connect(task); @@ -108,7 +108,7 @@ define([ var boundary = '-------314159265358979323846'; var delimiter = "\r\n--" + boundary + "\r\n"; var close_delim = "\r\n--" + boundary + "--"; - var contentType = 'text/x-markdown'; + contentType = contentType || 'text/x-markdown'; var metadata = { title: title, mimeType: contentType diff --git a/res/providers/gdriveProvider.js b/res/providers/gdriveProvider.js index 00ae8786..09c41f69 100644 --- a/res/providers/gdriveProvider.js +++ b/res/providers/gdriveProvider.js @@ -92,7 +92,7 @@ define([ } } var parentId = utils.getInputTextValue("#input-sync-export-gdrive-parentid"); - googleHelper.upload(fileId, parentId, title, content, undefined, function(error, result) { + googleHelper.upload(fileId, parentId, title, content, undefined, undefined, function(error, result) { if(error) { callback(error); return; @@ -120,7 +120,7 @@ define([ callback(undefined, false); return; } - googleHelper.upload(syncAttributes.id, undefined, uploadTitle, uploadContent, syncAttributes.etag, function(error, result) { + googleHelper.upload(syncAttributes.id, undefined, uploadTitle, uploadContent, undefined, syncAttributes.etag, function(error, result) { if(error) { callback(error, true); return; @@ -245,7 +245,8 @@ define([ }; gdriveProvider.publish = function(publishAttributes, title, content, callback) { - googleHelper.upload(publishAttributes.id, undefined, publishAttributes.fileName || title, content, undefined, function(error, result) { + var contentType = publishAttributes.format != "markdown" ? 'text/html' : undefined; + googleHelper.upload(publishAttributes.id, undefined, publishAttributes.fileName || title, content, contentType, undefined, function(error, result) { if(error) { callback(error); return; @@ -493,7 +494,7 @@ define([ } localStorage.removeItem(PROVIDER_GDRIVE + ".state"); if(state.action == "create") { - googleHelper.upload(undefined, state.folderId, GDRIVE_DEFAULT_FILE_TITLE, settings.defaultContent, undefined, function(error, file) { + googleHelper.upload(undefined, state.folderId, GDRIVE_DEFAULT_FILE_TITLE, settings.defaultContent, undefined, undefined, function(error, file) { if(error) { return; }