WordPress support
This commit is contained in:
parent
ddd4022287
commit
5a3ce0eacf
@ -1 +1 @@
|
||||
CACHE MANIFEST
# v29
CACHE:
index.html
viewer.html
css/main-min.css
js/main-min.js
js/require.js
img/ajax-loader.gif
img/glyphicons-halflings.png
img/glyphicons-halflings-white.png
img/icons.png
img/stackedit-32.ico
img/stackedit-promo.png
lib/MathJax/MathJax.js?config=TeX-AMS_HTML
lib/MathJax/config/TeX-AMS_HTML.js
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_AMS-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Italic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-BoldItalic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-Italic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Italic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Script-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size1-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size2-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size3-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size4-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Typewriter-Regular.woff
lib/MathJax/images/CloseX-31.png
lib/MathJax/images/MenuArrow-15.png
lib/MathJax/jax/output/HTML-CSS/jax.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/fontdata.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Arrows.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/BBBold.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/BoxDrawing.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/CombDiacritMarks.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Dingbats.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/EnclosedAlphanum.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/GeneralPunctuation.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/GeometricShapes.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/GreekAndCoptic.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Latin1Supplement.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/LatinExtendedA.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/LetterlikeSymbols.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Main.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MathOperators.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MiscMathSymbolsB.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MiscSymbols.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MiscTechnical.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/PUA.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/SpacingModLetters.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/SuppMathOperators.js
NETWORK:
*
|
||||
CACHE MANIFEST
# v30
CACHE:
index.html
viewer.html
css/main-min.css
js/main-min.js
js/require.js
img/ajax-loader.gif
img/glyphicons-halflings.png
img/glyphicons-halflings-white.png
img/icons.png
img/stackedit-32.ico
img/stackedit-promo.png
lib/MathJax/MathJax.js?config=TeX-AMS_HTML
lib/MathJax/config/TeX-AMS_HTML.js
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_AMS-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Italic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-BoldItalic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-Italic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Bold.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Italic.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Script-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size1-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size2-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size3-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size4-Regular.woff
lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Typewriter-Regular.woff
lib/MathJax/images/CloseX-31.png
lib/MathJax/images/MenuArrow-15.png
lib/MathJax/jax/output/HTML-CSS/jax.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/fontdata.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Arrows.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/BBBold.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/BoxDrawing.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/CombDiacritMarks.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Dingbats.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/EnclosedAlphanum.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/GeneralPunctuation.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/GeometricShapes.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/GreekAndCoptic.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Latin1Supplement.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/LatinExtendedA.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/LetterlikeSymbols.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Main.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MathOperators.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MiscMathSymbolsB.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MiscSymbols.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/MiscTechnical.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/PUA.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/SpacingModLetters.js
lib/MathJax/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/SuppMathOperators.js
NETWORK:
*
|
11
index.html
11
index.html
@ -362,8 +362,15 @@
|
||||
placeholder="exemple.tumblr.com">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group modal-publish-wordpress">
|
||||
<label class="control-label" for="input-publish-tumblr-hostname">WordPress site</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="input-publish-wordpress-site"
|
||||
placeholder="exemple.wordpress.com">
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="control-group modal-publish-blogger modal-publish-tumblr">
|
||||
class="control-group modal-publish-blogger modal-publish-tumblr modal-publish-wordpress">
|
||||
<label class="control-label" for="input-publish-postid">Update
|
||||
existing post ID (optional)</label>
|
||||
<div class="controls">
|
||||
@ -378,7 +385,7 @@
|
||||
placeholder="Label1, Label2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group modal-publish-tumblr">
|
||||
<div class="control-group modal-publish-tumblr modal-publish-wordpress">
|
||||
<label class="control-label" for="input-publish-tags">Tags
|
||||
(comma separated)</label>
|
||||
<div class="controls">
|
||||
|
@ -14,9 +14,11 @@ var AJAX_TIMEOUT = 30000;
|
||||
var ASYNC_TASK_DEFAULT_TIMEOUT = 60000;
|
||||
var ASYNC_TASK_LONG_TIMEOUT = 120000;
|
||||
var SYNC_PERIOD = 180000;
|
||||
var USER_IDLE_THRESHOLD = 300000;
|
||||
var USER_IDLE_THRESHOLD = 300000;
|
||||
var WELCOME_DOCUMENT_TITLE = "Welcome document";
|
||||
var DOWNLOAD_PROXY_URL = "http://stackedit-download-proxy.herokuapp.com/";
|
||||
var WORDPRESS_CLIENT_ID = '3185';
|
||||
var WORDPRESS_PROXY_URL = "http://stackedit-wordpress-proxy.herokuapp.com/";
|
||||
|
||||
// Use by Google's client.js
|
||||
var delayedFunction = undefined;
|
||||
|
17
js/core.js
17
js/core.js
@ -487,6 +487,7 @@ define(
|
||||
// Create the PageDown editor
|
||||
var insertLinkCallback = undefined;
|
||||
core.createEditor = function(onTextChange) {
|
||||
var firstChange = true;
|
||||
skipScrollLink = true;
|
||||
lastPreviewScrollTop = -9;
|
||||
$("#wmd-input, #wmd-preview").scrollTop(0);
|
||||
@ -500,14 +501,6 @@ define(
|
||||
}
|
||||
Markdown.Extra.init(converter, options);
|
||||
}
|
||||
var firstChange = true;
|
||||
converter.hooks.chain("preConversion", function(text) {
|
||||
// Used to save changes when typing
|
||||
if (!firstChange) {
|
||||
onTextChange();
|
||||
}
|
||||
return text;
|
||||
});
|
||||
// Convert email addresses (not managed by pagedown)
|
||||
converter.hooks.chain("postConversion", function(text) {
|
||||
return text.replace(/<(mailto\:)?([^\s>]+@[^\s>]+\.\S+?)>/g, function(match, mailto, email) {
|
||||
@ -567,7 +560,12 @@ define(
|
||||
});
|
||||
|
||||
var previewWrapper = function(makePreview) {
|
||||
return makePreview;
|
||||
return function() {
|
||||
if(firstChange !== true) {
|
||||
onTextChange();
|
||||
}
|
||||
makePreview();
|
||||
};
|
||||
};
|
||||
if(core.settings.lazyRendering === true) {
|
||||
previewWrapper = function(makePreview) {
|
||||
@ -577,6 +575,7 @@ define(
|
||||
makePreview();
|
||||
}
|
||||
else {
|
||||
onTextChange();
|
||||
debouncedMakePreview();
|
||||
}
|
||||
};
|
||||
|
2
js/main-min.js
vendored
2
js/main-min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
define(["jquery", "core", "sharing", "blogger-provider", "dropbox-provider", "gist-provider", "github-provider", "gdrive-provider", "tumblr-provider", "underscore"],
|
||||
define(["jquery", "core", "sharing", "blogger-provider", "dropbox-provider", "gist-provider", "github-provider", "gdrive-provider", "tumblr-provider", "wordpress-provider", "underscore"],
|
||||
function($, core, sharing) {
|
||||
|
||||
var publisher = {};
|
||||
|
@ -15,7 +15,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
|
||||
});
|
||||
}
|
||||
|
||||
// Try to authenticate with Oauth
|
||||
// Try to authenticate with OAuth
|
||||
function authenticate(task) {
|
||||
var authWindow = undefined;
|
||||
var intervalId = undefined;
|
||||
|
161
js/wordpress-helper.js
Normal file
161
js/wordpress-helper.js
Normal file
@ -0,0 +1,161 @@
|
||||
define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
|
||||
|
||||
var token = undefined;
|
||||
|
||||
var wordpressHelper = {};
|
||||
|
||||
// Only used to check the offline status
|
||||
function connect(task) {
|
||||
task.onRun(function() {
|
||||
if(core.isOffline === true) {
|
||||
task.error(new Error("Operation not available in offline mode."));
|
||||
return;
|
||||
}
|
||||
task.chain();
|
||||
});
|
||||
}
|
||||
|
||||
// Try to authenticate with OAuth
|
||||
function authenticate(task) {
|
||||
var authWindow = undefined;
|
||||
var intervalId = undefined;
|
||||
task.onRun(function() {
|
||||
token = localStorage["wordpressToken"];
|
||||
if(token !== undefined) {
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
core.showMessage("Please make sure the Wordpress authorization popup is not blocked by your browser.");
|
||||
var errorMsg = "Failed to retrieve a token from Wordpress.";
|
||||
// We add time for user to enter his credentials
|
||||
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
|
||||
var code = undefined;
|
||||
function getCode() {
|
||||
localStorage.removeItem("wordpressCode");
|
||||
authWindow = core.popupWindow(
|
||||
'wordpress-oauth-client.html?client_id=' + WORDPRESS_CLIENT_ID,
|
||||
'stackedit-wordpress-oauth', 960, 600);
|
||||
authWindow.focus();
|
||||
intervalId = setInterval(function() {
|
||||
if(authWindow.closed === true) {
|
||||
clearInterval(intervalId);
|
||||
authWindow = undefined;
|
||||
intervalId = undefined;
|
||||
code = localStorage["wordpressCode"];
|
||||
if(code === undefined) {
|
||||
task.error(new Error(errorMsg));
|
||||
return;
|
||||
}
|
||||
localStorage.removeItem("wordpressCode");
|
||||
task.chain(getToken);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
function getToken() {
|
||||
$.getJSON(WORDPRESS_PROXY_URL + "authenticate/" + code, function(data) {
|
||||
if(data.token !== undefined) {
|
||||
token = data.token;
|
||||
localStorage["wordpressToken"] = token;
|
||||
task.chain();
|
||||
}
|
||||
else {
|
||||
task.error(new Error(errorMsg));
|
||||
}
|
||||
});
|
||||
}
|
||||
task.chain(getCode);
|
||||
});
|
||||
task.onError(function() {
|
||||
if(intervalId !== undefined) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
if(authWindow !== undefined) {
|
||||
authWindow.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
wordpressHelper.upload = function(site, postId, tags, title, content, callback) {
|
||||
callback = callback || core.doNothing;
|
||||
var task = asyncRunner.createTask();
|
||||
connect(task);
|
||||
authenticate(task);
|
||||
task.onRun(function() {
|
||||
var url = WORDPRESS_PROXY_URL + "post";
|
||||
var data = {
|
||||
token: token,
|
||||
site: site,
|
||||
postId: postId,
|
||||
tags: tags,
|
||||
title: title,
|
||||
content: content
|
||||
};
|
||||
$.ajax({
|
||||
url : url,
|
||||
data: data,
|
||||
type: "POST",
|
||||
dataType : "json",
|
||||
timeout : AJAX_TIMEOUT
|
||||
}).done(function(response, textStatus, jqXHR) {
|
||||
if(response.body.ID) {
|
||||
postId = response.body.ID;
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
var error = {
|
||||
code: response.code,
|
||||
message: response.body.error
|
||||
};
|
||||
// Handle error
|
||||
if(error.code === 404) {
|
||||
if(error.message == "unknown_blog") {
|
||||
error = 'Site "' + site + '" not found on WordPress.|removePublish';
|
||||
}
|
||||
else if(error.message == "unknown_post"){
|
||||
error = 'Post ' + postId + ' not found on WordPress.|removePublish';
|
||||
}
|
||||
}
|
||||
handleError(error, task);
|
||||
}).fail(function(jqXHR) {
|
||||
var error = {
|
||||
code: jqXHR.status,
|
||||
message: jqXHR.statusText
|
||||
};
|
||||
handleError(error, task);
|
||||
});
|
||||
});
|
||||
task.onSuccess(function() {
|
||||
callback(undefined, postId);
|
||||
});
|
||||
task.onError(function(error) {
|
||||
callback(error);
|
||||
});
|
||||
asyncRunner.addTask(task);
|
||||
};
|
||||
|
||||
function handleError(error, task) {
|
||||
var errorMsg = undefined;
|
||||
if (error) {
|
||||
console.error(error);
|
||||
// Try to analyze the error
|
||||
if (typeof error === "string") {
|
||||
errorMsg = error;
|
||||
}
|
||||
else {
|
||||
errorMsg = "Could not publish on WordPress.";
|
||||
if ((error.code === 400 && error.message == "invalid_token") || error.code === 401 || error.code === 403) {
|
||||
localStorage.removeItem("wordpressToken");
|
||||
errorMsg = "Access to WordPress account is not authorized.";
|
||||
task.retry(new Error(errorMsg), 1);
|
||||
return;
|
||||
} else if (error.code <= 0) {
|
||||
core.setOffline();
|
||||
errorMsg = "|stopPublish";
|
||||
}
|
||||
}
|
||||
}
|
||||
task.error(new Error(errorMsg));
|
||||
}
|
||||
|
||||
return wordpressHelper;
|
||||
});
|
45
js/wordpress-provider.js
Normal file
45
js/wordpress-provider.js
Normal file
@ -0,0 +1,45 @@
|
||||
define(["jquery", "core", "wordpress-helper"], function($, core, wordpressHelper) {
|
||||
|
||||
var PROVIDER_WORDPRESS = "wordpress";
|
||||
|
||||
var wordpressProvider = {
|
||||
providerId: PROVIDER_WORDPRESS,
|
||||
providerName: "WordPress",
|
||||
defaultPublishFormat: "html"
|
||||
};
|
||||
|
||||
wordpressProvider.publish = function(publishAttributes, title, content, callback) {
|
||||
wordpressHelper.upload(
|
||||
publishAttributes.site,
|
||||
publishAttributes.postId,
|
||||
publishAttributes.tags,
|
||||
title,
|
||||
content,
|
||||
function(error, postId) {
|
||||
if(error) {
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
publishAttributes.postId = postId;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
wordpressProvider.newPublishAttributes = function(event) {
|
||||
var publishAttributes = {};
|
||||
publishAttributes.site = core
|
||||
.getInputValue(
|
||||
$("#input-publish-wordpress-site"),
|
||||
event,
|
||||
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/);
|
||||
publishAttributes.postId = $("#input-publish-postid").val() || undefined;
|
||||
publishAttributes.tags = $("#input-publish-tags").val() || undefined;
|
||||
if(event.isPropagationStopped()) {
|
||||
return undefined;
|
||||
}
|
||||
return publishAttributes;
|
||||
};
|
||||
|
||||
return wordpressProvider;
|
||||
});
|
27
wordpress-oauth-client.html
Normal file
27
wordpress-oauth-client.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
function getParameter(name) {
|
||||
var regex = new RegExp(name + "=(.+?)(&|$)");
|
||||
try {
|
||||
return decodeURI(regex.exec(location.search)[1]);
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
var client_id = getParameter("client_id");
|
||||
var code = getParameter("code");
|
||||
if (client_id) {
|
||||
var redirectURI = location.href.substring(0, location.href.indexOf("?"));
|
||||
window.location.href = "https://public-api.wordpress.com/oauth2/authorize?response_type=code&client_id="
|
||||
+ client_id + "&redirect_uri=" + redirectURI;
|
||||
} else {
|
||||
if (code) {
|
||||
localStorage["wordpressCode"] = code;
|
||||
}
|
||||
//window.close();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user