|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import StringUtils from '../utils/StringUtils';
|
|
|
|
|
import StringUtils from "../utils/StringUtils";
|
|
|
|
|
export default class PostActions {
|
|
|
|
|
//--------------------------
|
|
|
|
|
// constructor
|
|
|
|
@ -10,62 +10,68 @@ export default class PostActions {
|
|
|
|
|
collectInfo(image) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
let pageInfo = new FormData();
|
|
|
|
|
let txt = document.createElement('textarea');
|
|
|
|
|
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
|
|
|
|
|
let txt = document.createElement("textarea");
|
|
|
|
|
txt.innerHTML = document.getElementById("edit-post-text").innerHTML;
|
|
|
|
|
let html = txt.value;
|
|
|
|
|
//html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling
|
|
|
|
|
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
|
|
|
|
|
html = html.replace(/<\/?br[^>]*>/g, "\n"); //convert back to encoded line break for storage
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'id',
|
|
|
|
|
document.getElementById('post-edit-index').getAttribute('data-index')
|
|
|
|
|
"id",
|
|
|
|
|
document.getElementById("post-edit-index").getAttribute("data-index")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'uuid',
|
|
|
|
|
document.getElementById('post-edit-index').getAttribute('data-uuid')
|
|
|
|
|
"uuid",
|
|
|
|
|
document.getElementById("post-edit-index").getAttribute("data-uuid")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'layout',
|
|
|
|
|
document.getElementById('post-edit-index').getAttribute('data-layout')
|
|
|
|
|
"layout",
|
|
|
|
|
document.getElementById("post-edit-index").getAttribute("data-layout")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'current_title',
|
|
|
|
|
document.getElementById('post-edit-index').getAttribute('data-slug')
|
|
|
|
|
"current_title",
|
|
|
|
|
document.getElementById("post-edit-index").getAttribute("data-slug")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append('content', html);
|
|
|
|
|
pageInfo.append('title', document.getElementById('post_title').value);
|
|
|
|
|
pageInfo.append("content", html);
|
|
|
|
|
pageInfo.append("title", document.getElementById("post_title").value);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'created',
|
|
|
|
|
document.getElementById('post-date').getAttribute('data-raw')
|
|
|
|
|
"created",
|
|
|
|
|
document.getElementById("post-date").getAttribute("data-raw")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'slug',
|
|
|
|
|
new StringUtils().cleanString(document.getElementById('post_title').value)
|
|
|
|
|
"slug",
|
|
|
|
|
new StringUtils().cleanString(
|
|
|
|
|
document.getElementById("post_title").value
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append('tags', document.getElementById('post_tags').value);
|
|
|
|
|
pageInfo.append("tags", document.getElementById("post_tags").value);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'menu',
|
|
|
|
|
document.getElementById('option-menu-pin').getAttribute('data-active')
|
|
|
|
|
"menu",
|
|
|
|
|
document.getElementById("option-menu-pin").getAttribute("data-active")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'featured',
|
|
|
|
|
document.getElementById('option-feature').getAttribute('data-active')
|
|
|
|
|
"featured",
|
|
|
|
|
document.getElementById("option-feature").getAttribute("data-active")
|
|
|
|
|
);
|
|
|
|
|
pageInfo.append(
|
|
|
|
|
'published',
|
|
|
|
|
document.getElementById('option-published').getAttribute('data-active')
|
|
|
|
|
"published",
|
|
|
|
|
document.getElementById("option-published").getAttribute("data-active")
|
|
|
|
|
);
|
|
|
|
|
if (image != null || image != undefined) {
|
|
|
|
|
if (image.type.match('image.*')) {
|
|
|
|
|
pageInfo.append('feature_image', image, image.name);
|
|
|
|
|
if (image.type.match("image.*")) {
|
|
|
|
|
pageInfo.append("feature_image", image, image.name);
|
|
|
|
|
} else {
|
|
|
|
|
reject('Not an image file');
|
|
|
|
|
reject("Not an image file");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//check to see if image exists
|
|
|
|
|
var imageURL = document.getElementById('featured-image').src;
|
|
|
|
|
if (document.getElementById("featured-image")) {
|
|
|
|
|
var imageURL = document.getElementById("featured-image").src;
|
|
|
|
|
imageURL != null || imageURL != undefined
|
|
|
|
|
? pageInfo.append('feature_image', imageURL)
|
|
|
|
|
: pageInfo.append('feature_image', null);
|
|
|
|
|
? pageInfo.append("feature_image", imageURL)
|
|
|
|
|
: pageInfo.append("feature_image", null);
|
|
|
|
|
} else {
|
|
|
|
|
//pageInfo.append("feature_image", null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve(pageInfo);
|
|
|
|
|