forked from projects/fipamo
ro
1e37580869
dropped in js from the old site to begin the process of wiring up the API, but this time around, scripts will be served directly in browswer rather than being transpiled through NPM/Babel, eliminating the need for NPM. also scripting will new modularized and served specifically for the requirements of the page loading it. no more front loading everything. only script that is needed for that page will be retrieved. if no scripting is needed, none will be loaded. The only casualty so far has been syntax highlighting due to prismjs still being a common js module, but either this will be replaced with another library or a custom syntax enginge will be created at a later date
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import StringUtils from '../utils/StringUtils.js';
|
|
export default class PostActions {
|
|
//--------------------------
|
|
// constructor
|
|
//--------------------------
|
|
constructor() {}
|
|
//--------------------------
|
|
// methods
|
|
//--------------------------
|
|
collectInfo(files) {
|
|
return new Promise((resolve, reject) => {
|
|
let pageInfo = [];
|
|
let pageRef = document.querySelector('[role="file-manager"]');
|
|
//process html content for storage
|
|
let txt = document.createElement('textarea');
|
|
txt.innerHTML = document.getElementById('highlight-content').innerHTML;
|
|
let html = txt.value;
|
|
html = html.replace(/<\/?span[^>]*>/g, ''); //removes prism styling
|
|
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
|
|
//build data object
|
|
pageInfo = {
|
|
id: pageRef.getAttribute('data-index'),
|
|
uuid: pageRef.getAttribute('data-uuid'),
|
|
layout: document.getElementById('page-templates').value,
|
|
current_title: pageRef.getAttribute('data-slug'),
|
|
content: html,
|
|
title: document.getElementById('post-title-text').value,
|
|
created: document.getElementById('post-date').getAttribute('data-raw'),
|
|
slug: new StringUtils().cleanString(
|
|
document.getElementById('post-title-text').value
|
|
),
|
|
tags: document.getElementById('post-tags').value,
|
|
menu: document
|
|
.getElementById('option-menu-pin')
|
|
.getAttribute('data-active'),
|
|
featured: document
|
|
.getElementById('option-feature')
|
|
.getAttribute('data-active'),
|
|
published: document
|
|
.getElementById('option-published')
|
|
.getAttribute('data-active'),
|
|
form_token: document.getElementById('form_token').value,
|
|
imageList: files.images,
|
|
fileList: files.files
|
|
};
|
|
|
|
resolve(pageInfo);
|
|
});
|
|
}
|
|
//--------------------------
|
|
// event handlers
|
|
//--------------------------
|
|
}
|