Support for Blogger
This commit is contained in:
parent
c5b775f576
commit
ded5975c14
@ -120,7 +120,7 @@ code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 50px 0 20px;
|
margin: 40px 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
53
index.html
53
index.html
@ -88,6 +88,8 @@
|
|||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="#" class="action-publish-github"><i
|
<li><a href="#" class="action-publish-github"><i
|
||||||
class="icon-github"></i> GitHub</a></li>
|
class="icon-github"></i> GitHub</a></li>
|
||||||
|
<li><a href="#" class="action-publish-blogger"><i
|
||||||
|
class="icon-blogger"></i> Blogger</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="#" data-toggle="modal"
|
<li><a href="#" data-toggle="modal"
|
||||||
data-target="#modal-manage-publish" class="action-reset-input"><i
|
data-target="#modal-manage-publish" class="action-reset-input"><i
|
||||||
@ -317,8 +319,8 @@
|
|||||||
</label> <label class="radio"> <input type="radio"
|
</label> <label class="radio"> <input type="radio"
|
||||||
name="radio-publish-format" value="html"> HTML
|
name="radio-publish-format" value="html"> HTML
|
||||||
</label> <label class="radio"> <input type="radio"
|
</label> <label class="radio"> <input type="radio"
|
||||||
name="radio-publish-format" value="template"> Template
|
name="radio-publish-format" value="template"> Template
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -344,7 +346,7 @@
|
|||||||
is not published.
|
is not published.
|
||||||
</p>
|
</p>
|
||||||
<p class="muted"><b>NOTE:</b> You can add locations using
|
<p class="muted"><b>NOTE:</b> You can add locations using
|
||||||
sub-menu "Publish on".</p>
|
"Publish on" sub-menu.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
|
<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
|
||||||
@ -380,17 +382,17 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"
|
<label class="control-label" for="input-settings-converter-type">Converter</label>
|
||||||
for="input-settings-converter-type">Converter</label>
|
<div class="controls">
|
||||||
<div class="controls">
|
<select id="input-settings-converter-type">
|
||||||
<select id="input-settings-converter-type">
|
<option value="markdown">Markdown</option>
|
||||||
<option value="markdown">Markdown</option>
|
<option value="markdown-extra">Markdown Extra</option>
|
||||||
<option value="markdown-extra">Markdown Extra</option>
|
<option value="markdown-extra-prettify">Markdown Extra
|
||||||
<option value="markdown-extra-prettify">Markdown Extra + Prettify</option>
|
+ Prettify</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"
|
<label class="control-label"
|
||||||
for="input-settings-editor-font-size">Editor font size</label>
|
for="input-settings-editor-font-size">Editor font size</label>
|
||||||
@ -412,7 +414,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"
|
<label class="control-label"
|
||||||
for="textarea-settings-publish-template">Template (<a href="#" class="tooltip-template">?</a>)</label>
|
for="textarea-settings-publish-template">Template <a
|
||||||
|
href="#" class="tooltip-template">(?)</a>
|
||||||
|
</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea id="textarea-settings-publish-template"></textarea>
|
<textarea id="textarea-settings-publish-template"></textarea>
|
||||||
</div>
|
</div>
|
||||||
@ -494,16 +498,23 @@
|
|||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="https://code.google.com/p/pagedown/">PageDown</a>
|
<a target="_blank" href="https://code.google.com/p/pagedown/">PageDown</a>
|
||||||
|
/ <a target="_blank"
|
||||||
|
href="https://github.com/jmcmanus/pagedown-extra/">Pagedown-extra</a>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
<a target="_blank"
|
||||||
|
href="https://code.google.com/p/google-code-prettify/">Prettify</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://requirejs.org/">RequireJS</a>
|
<a target="_blank" href="http://requirejs.org/">RequireJS</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://layout.jquery-dev.net/">UI Layout</a>
|
<a target="_blank" href="http://layout.jquery-dev.net/">UI
|
||||||
</dd>
|
Layout</a>
|
||||||
<dd>
|
</dd>
|
||||||
<a target="_blank" href="http://underscorejs.org/">Underscore.js</a>
|
<dd>
|
||||||
</dd>
|
<a target="_blank" href="http://underscorejs.org/">Underscore.js</a>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>Copyright 2013 <a target="_blank"
|
<p>Copyright 2013 <a target="_blank"
|
||||||
href="http://www.benoitschweblin.com">Benoit Schweblin</a><br />
|
href="http://www.benoitschweblin.com">Benoit Schweblin</a><br />
|
||||||
|
45
js/blogger-provider.js
Normal file
45
js/blogger-provider.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
define(["jquery", "google-helper"], function($, googleHelper) {
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
var core = undefined;
|
||||||
|
|
||||||
|
var bloggerProvider = {
|
||||||
|
providerType: PROVIDER_TYPE_PUBLISH_FLAG,
|
||||||
|
providerId: PROVIDER_BLOGGER,
|
||||||
|
providerName: "Blogger",
|
||||||
|
defaultPublishFormat: "html"
|
||||||
|
};
|
||||||
|
|
||||||
|
bloggerProvider.publish = function(publishAttributes, title, content, callback) {
|
||||||
|
googleHelper.uploadBlogger(publishAttributes.blogUrl,
|
||||||
|
publishAttributes.blogId, publishAttributes.postId, title, content,
|
||||||
|
function(blogId, postId) {
|
||||||
|
if(blogId === undefined || postId === undefined) {
|
||||||
|
callback(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
publishAttributes.blogId = blogId;
|
||||||
|
publishAttributes.postId = postId;
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
bloggerProvider.newPublishAttributes = function(event) {
|
||||||
|
var publishAttributes = {};
|
||||||
|
publishAttributes.blogUrl = core.getInputValue($("#input-publish-blogger-url"), event);
|
||||||
|
var postId = $("#input-publish-blogger-postid").val();
|
||||||
|
if(postId) {
|
||||||
|
publishAttributes.postId = postId;
|
||||||
|
}
|
||||||
|
if(event.isPropagationStopped()) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return publishAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
bloggerProvider.init = function(coreModule) {
|
||||||
|
core = coreModule;
|
||||||
|
};
|
||||||
|
|
||||||
|
return bloggerProvider;
|
||||||
|
});
|
@ -370,49 +370,6 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the "New publication" dialog
|
|
||||||
var newPublishProvider = undefined;
|
|
||||||
function initNewPublish(provider, defaultPublishFormat) {
|
|
||||||
defaultPublishFormat = defaultPublishFormat || "markdown";
|
|
||||||
newPublishProvider = provider;
|
|
||||||
|
|
||||||
// Show/hide controls depending on provider
|
|
||||||
$('div[class*=" modal-publish-"]').hide().filter(".modal-publish-" + provider).show();
|
|
||||||
|
|
||||||
// Reset fields
|
|
||||||
core.resetModalInputs();
|
|
||||||
$("input:radio[name=radio-publish-format][value=" + defaultPublishFormat + "]").prop("checked", true);
|
|
||||||
|
|
||||||
// Open dialog box
|
|
||||||
$("#modal-publish").modal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new publication on GitHub
|
|
||||||
function newPublishGithub(event) {
|
|
||||||
var publishAttributes = {};
|
|
||||||
publishAttributes.repository = core.getInputValue($("#input-publish-github-reponame"), event);
|
|
||||||
publishAttributes.branch = core.getInputValue($("#input-publish-github-branch"), event);
|
|
||||||
publishAttributes.path = core.getInputValue($("#input-publish-github-path"), event);
|
|
||||||
publishAttributes.provider = newPublishProvider;
|
|
||||||
if(event.isPropagationStopped()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
publisher.newLocation(publishAttributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new publication on Blogger
|
|
||||||
function newPublishBlogger(event) {
|
|
||||||
var blogUrl = core.getInputValue($("#input-publish-blogger-url"), event);
|
|
||||||
if(event.isPropagationStopped()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
googleHelper.getBlogByUrl(blogUrl, function(blog) {
|
|
||||||
console.log(blog);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fileManager.init = function(coreModule) {
|
fileManager.init = function(coreModule) {
|
||||||
core = coreModule;
|
core = coreModule;
|
||||||
|
|
||||||
@ -497,22 +454,6 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
|
|||||||
var path = core.getInputValue($("#manual-dropbox-path"), event);
|
var path = core.getInputValue($("#manual-dropbox-path"), event);
|
||||||
manualDropbox(path);
|
manualDropbox(path);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish actions
|
|
||||||
$(".action-publish-github").click(function() {
|
|
||||||
initNewPublish(PROVIDER_GITHUB);
|
|
||||||
});
|
|
||||||
$(".action-publish-blogger").click(function() {
|
|
||||||
initNewPublish(PROVIDER_BLOGGER, "html");
|
|
||||||
});
|
|
||||||
$(".action-process-publish").click(function(e) {
|
|
||||||
if(newPublishProvider == PROVIDER_GITHUB) {
|
|
||||||
newPublishGithub(e);
|
|
||||||
}
|
|
||||||
else if(newPublishProvider == PROVIDER_BLOGGER) {
|
|
||||||
newPublishBlogger(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return fileManager;
|
return fileManager;
|
||||||
|
@ -161,7 +161,9 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
|
|||||||
callback(error);
|
callback(error);
|
||||||
};
|
};
|
||||||
asyncTask.onError = function() {
|
asyncTask.onError = function() {
|
||||||
console.error(error);
|
if(error !== undefined) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
var errorMsg = "Could not publish on GitHub.";
|
var errorMsg = "Could not publish on GitHub.";
|
||||||
if(error === 401 || error === 403) {
|
if(error === 401 || error === 403) {
|
||||||
github = undefined;
|
github = undefined;
|
||||||
|
@ -3,21 +3,32 @@ define(["jquery", "github-helper"], function($, githubHelper) {
|
|||||||
// Dependencies
|
// Dependencies
|
||||||
var core = undefined;
|
var core = undefined;
|
||||||
|
|
||||||
var publishGithub = {
|
var githubProvider = {
|
||||||
providerType: PROVIDER_TYPE_PUBLISH_FLAG,
|
providerType: PROVIDER_TYPE_PUBLISH_FLAG,
|
||||||
providerId: PROVIDER_GITHUB,
|
providerId: PROVIDER_GITHUB,
|
||||||
providerName: "GitHub"
|
providerName: "GitHub"
|
||||||
};
|
};
|
||||||
|
|
||||||
publishGithub.publish = function(publishAttributes, title, content, callback) {
|
githubProvider.publish = function(publishAttributes, title, content, callback) {
|
||||||
var commitMsg = core.settings.commitMsg;
|
var commitMsg = core.settings.commitMsg;
|
||||||
githubHelper.upload(publishAttributes.repository, publishAttributes.branch,
|
githubHelper.upload(publishAttributes.repository, publishAttributes.branch,
|
||||||
publishAttributes.path, content, commitMsg, callback);
|
publishAttributes.path, content, commitMsg, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
publishGithub.init = function(coreModule) {
|
githubProvider.newPublishAttributes = function(event) {
|
||||||
|
var publishAttributes = {};
|
||||||
|
publishAttributes.repository = core.getInputValue($("#input-publish-github-reponame"), event);
|
||||||
|
publishAttributes.branch = core.getInputValue($("#input-publish-github-branch"), event);
|
||||||
|
publishAttributes.path = core.getInputValue($("#input-publish-github-path"), event);
|
||||||
|
if(event.isPropagationStopped()) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return publishAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
githubProvider.init = function(coreModule) {
|
||||||
core = coreModule;
|
core = coreModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
return publishGithub;
|
return githubProvider;
|
||||||
});
|
});
|
@ -355,7 +355,8 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleError(error, asyncTask, callback) {
|
function handleError(error, asyncTask, callback, serviceName) {
|
||||||
|
serviceName = serviceName || "Google Drive";
|
||||||
var errorMsg = undefined;
|
var errorMsg = undefined;
|
||||||
asyncTask.onError = function() {
|
asyncTask.onError = function() {
|
||||||
if (errorMsg !== undefined) {
|
if (errorMsg !== undefined) {
|
||||||
@ -370,19 +371,19 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
|
|||||||
errorMsg = error;
|
errorMsg = error;
|
||||||
}
|
}
|
||||||
else if (error.code >= 500 && error.code < 600) {
|
else if (error.code >= 500 && error.code < 600) {
|
||||||
errorMsg = "Google Drive is not accessible.";
|
errorMsg = serviceName + " is not accessible.";
|
||||||
// Retry as described in Google's best practices
|
// Retry as described in Google's best practices
|
||||||
asyncTask.retry();
|
asyncTask.retry();
|
||||||
return;
|
return;
|
||||||
} else if (error.code === 401 || error.code === 403) {
|
} else if (error.code === 401 || error.code === 403) {
|
||||||
authenticated = false;
|
authenticated = false;
|
||||||
errorMsg = "Access to Google Drive is not authorized.";
|
errorMsg = "Access to " + serviceName + " is not authorized.";
|
||||||
} else if (error.code <= 0) {
|
} else if (error.code <= 0) {
|
||||||
connected = false;
|
connected = false;
|
||||||
authenticated = false;
|
authenticated = false;
|
||||||
core.setOffline();
|
core.setOffline();
|
||||||
} else {
|
} else {
|
||||||
errorMsg = "Google Drive error (" + error.code + ": "
|
errorMsg = serviceName + " error (" + error.code + ": "
|
||||||
+ error.message + ").";
|
+ error.message + ").";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,40 +494,91 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
googleHelper.getBlogByUrl = function(url, callback) {
|
googleHelper.uploadBlogger = function(blogUrl, blogId, postId, title, content, callback) {
|
||||||
authenticate(function() {
|
authenticate(function() {
|
||||||
if (connected === false) {
|
if (connected === false) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = undefined;
|
|
||||||
var asyncTask = {};
|
var asyncTask = {};
|
||||||
asyncTask.run = function() {
|
asyncTask.run = function() {
|
||||||
var token = gapi.auth.getToken();
|
var token = gapi.auth.getToken();
|
||||||
var headers = {
|
var headers = {
|
||||||
Authorization : token ? "Bearer " + token.access_token: null
|
Authorization : token ? "Bearer " + token.access_token: null
|
||||||
};
|
};
|
||||||
$.ajax({
|
|
||||||
url : "https://www.googleapis.com/blogger/v3/blogs/byurl",
|
function getBlogId(localCallback) {
|
||||||
data: { url: url },
|
$.ajax({
|
||||||
headers : headers,
|
url : "https://www.googleapis.com/blogger/v3/blogs/byurl",
|
||||||
dataType : "json",
|
data: { url: blogUrl },
|
||||||
timeout : AJAX_TIMEOUT
|
headers : headers,
|
||||||
}).done(function(blog, textStatus, jqXHR) {
|
dataType : "json",
|
||||||
result = blog;
|
timeout : AJAX_TIMEOUT
|
||||||
asyncTask.success();
|
}).done(function(blog, textStatus, jqXHR) {
|
||||||
}).fail(function(jqXHR) {
|
blogId = blog.id;
|
||||||
var error = {
|
localCallback();
|
||||||
code: jqXHR.status,
|
}).fail(function(jqXHR) {
|
||||||
message: jqXHR.statusText
|
var error = {
|
||||||
|
code: jqXHR.status,
|
||||||
|
message: jqXHR.statusText
|
||||||
|
};
|
||||||
|
// Handle error
|
||||||
|
if(error.code === 404) {
|
||||||
|
error = 'Blog "' + blogUrl + '" not found on Blogger.';
|
||||||
|
}
|
||||||
|
handleError(error, asyncTask, callback, "Blogger");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function publish() {
|
||||||
|
var url = "https://www.googleapis.com/blogger/v3/blogs/" + blogId + "/posts/";
|
||||||
|
var data = {
|
||||||
|
kind: "blogger#post",
|
||||||
|
blog: { id: blogId },
|
||||||
|
title: title,
|
||||||
|
content: content
|
||||||
};
|
};
|
||||||
// Handle error
|
var type = "POST";
|
||||||
handleError(error, asyncTask, callback);
|
// If it's an update
|
||||||
});
|
if(postId !== undefined) {
|
||||||
|
url += postId;
|
||||||
|
data.id = postId;
|
||||||
|
type = "PUT";
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url : url,
|
||||||
|
data: JSON.stringify(data),
|
||||||
|
headers : headers,
|
||||||
|
type: type,
|
||||||
|
contentType: "application/json",
|
||||||
|
dataType : "json",
|
||||||
|
timeout : AJAX_TIMEOUT
|
||||||
|
}).done(function(post, textStatus, jqXHR) {
|
||||||
|
postId = post.id;
|
||||||
|
asyncTask.success();
|
||||||
|
}).fail(function(jqXHR) {
|
||||||
|
var error = {
|
||||||
|
code: jqXHR.status,
|
||||||
|
message: jqXHR.statusText
|
||||||
|
};
|
||||||
|
// Handle error
|
||||||
|
if(error.code === 404 && postId !== undefined) {
|
||||||
|
error = 'Post ' + postId + ' not found on Blogger.';
|
||||||
|
}
|
||||||
|
handleError(error, asyncTask, callback, "Blogger");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blogId === undefined) {
|
||||||
|
getBlogId(publish);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
publish();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
asyncTask.onSuccess = function() {
|
asyncTask.onSuccess = function() {
|
||||||
callback(result);
|
callback(blogId, postId);
|
||||||
};
|
};
|
||||||
asyncTask.onError = function() {
|
asyncTask.onError = function() {
|
||||||
callback();
|
callback();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
define(["jquery", "github-provider", "underscore"], function($) {
|
define(["jquery", "github-provider", "blogger-provider", "underscore"], function($) {
|
||||||
|
|
||||||
// Dependencies
|
// Dependencies
|
||||||
var core = undefined;
|
var core = undefined;
|
||||||
@ -91,7 +91,7 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
|||||||
// Call the provider
|
// Call the provider
|
||||||
var provider = providerMap[publishAttributes.provider];
|
var provider = providerMap[publishAttributes.provider];
|
||||||
provider.publish(publishAttributes, publishTitle, content, function(error) {
|
provider.publish(publishAttributes, publishTitle, content, function(error) {
|
||||||
publishLocation(callback, errorFlag);
|
publishLocation(callback, errorFlag || error );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,21 +126,43 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
|||||||
localStorage[fileIndex + ".publish"] += publishIndex + ";";
|
localStorage[fileIndex + ".publish"] += publishIndex + ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize the "New publication" dialog
|
||||||
|
var newLocationProvider = undefined;
|
||||||
|
function initNewLocation(provider) {
|
||||||
|
var defaultPublishFormat = provider.defaultPublishFormat || "markdown";
|
||||||
|
newLocationProvider = provider;
|
||||||
|
|
||||||
|
// Show/hide controls depending on provider
|
||||||
|
$('div[class*=" modal-publish-"]').hide().filter(".modal-publish-" + provider.providerId).show();
|
||||||
|
|
||||||
|
// Reset fields
|
||||||
|
core.resetModalInputs();
|
||||||
|
$("input:radio[name=radio-publish-format][value=" + defaultPublishFormat + "]").prop("checked", true);
|
||||||
|
|
||||||
|
// Open dialog box
|
||||||
|
$("#modal-publish").modal();
|
||||||
|
}
|
||||||
|
|
||||||
// Add a new publish location to a local document
|
// Add a new publish location to a local document
|
||||||
publisher.newLocation = function(publishAttributes) {
|
function performNewLocation(event) {
|
||||||
|
var provider = newLocationProvider;
|
||||||
|
var publishAttributes = provider.newPublishAttributes(event);
|
||||||
|
if(publishAttributes === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var fileIndex = fileManager.getCurrentFileIndex();
|
var fileIndex = fileManager.getCurrentFileIndex();
|
||||||
var title = localStorage[fileIndex + ".title"];
|
var title = localStorage[fileIndex + ".title"];
|
||||||
var content = getPublishContent(publishAttributes);
|
var content = getPublishContent(publishAttributes);
|
||||||
var provider = providerMap[publishAttributes.provider];
|
|
||||||
provider.publish(publishAttributes, title, content, function(error) {
|
provider.publish(publishAttributes, title, content, function(error) {
|
||||||
if(error === undefined) {
|
if(error === undefined) {
|
||||||
|
publishAttributes.provider = provider.providerId;
|
||||||
createPublishIndex(fileIndex, publishAttributes);
|
createPublishIndex(fileIndex, publishAttributes);
|
||||||
publisher.notifyPublish();
|
publisher.notifyPublish();
|
||||||
core.showMessage('"' + title
|
core.showMessage('"' + title
|
||||||
+ '" will now be published on GitHub.');
|
+ '" is now published on ' + provider.providerName + '.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
// Used to populate the "Manage publication" dialog
|
// Used to populate the "Manage publication" dialog
|
||||||
var lineTemplate = ['<div class="input-prepend input-append">',
|
var lineTemplate = ['<div class="input-prepend input-append">',
|
||||||
@ -162,7 +184,7 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
|||||||
_.each(publishIndexList, function(publishIndex) {
|
_.each(publishIndexList, function(publishIndex) {
|
||||||
var serializedObject = localStorage[publishIndex];
|
var serializedObject = localStorage[publishIndex];
|
||||||
var publishAttributes = JSON.parse(serializedObject);
|
var publishAttributes = JSON.parse(serializedObject);
|
||||||
var publishDesc = JSON.stringify(_.omit(publishAttributes, 'provider')).replace(/{|}|"/g, "");
|
var publishDesc = JSON.stringify(publishAttributes).replace(/{|}|"/g, "");
|
||||||
lineElement = $(_.template(lineTemplate, {
|
lineElement = $(_.template(lineTemplate, {
|
||||||
provider: providerMap[publishAttributes.provider],
|
provider: providerMap[publishAttributes.provider],
|
||||||
publishDesc: publishDesc
|
publishDesc: publishDesc
|
||||||
@ -178,11 +200,17 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
|||||||
core = coreModule;
|
core = coreModule;
|
||||||
fileManager = fileManagerModule;
|
fileManager = fileManagerModule;
|
||||||
|
|
||||||
// Init providers
|
// Init each provider
|
||||||
_.each(providerMap, function(provider) {
|
_.each(providerMap, function(provider) {
|
||||||
provider.init(core);
|
provider.init(core);
|
||||||
|
// Publish provider button
|
||||||
|
$(".action-publish-" + provider.providerId).click(function() {
|
||||||
|
initNewLocation(provider);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".action-process-publish").click(performNewLocation);
|
||||||
|
|
||||||
$(".action-force-publish").click(function() {
|
$(".action-force-publish").click(function() {
|
||||||
if(!$(this).hasClass("disabled")) {
|
if(!$(this).hasClass("disabled")) {
|
||||||
publisher.publish();
|
publisher.publish();
|
||||||
|
Loading…
Reference in New Issue
Block a user