moved fixes from dev to beta-release branch

b1.2.4
Ro 4 years ago
parent 0dd9d104fa
commit fe6a4eab32

@ -67,7 +67,7 @@ router.post('/sync', (req, res) => {
router.post('/nav-sync', (req, res) => { router.post('/nav-sync', (req, res) => {
auth.authCheck(req) auth.authCheck(req)
.then(() => { .then(() => {
// find removoed menu item page and set menu to false // find removed menu item page and set menu to false
book.getPage(req.body.remove).then(page => { book.getPage(req.body.remove).then(page => {
let body = page.metadata; let body = page.metadata;
body.content = page.content; body.content = page.content;
@ -206,6 +206,31 @@ router.post('/add-feature-background', background_upload, (req, res) => {
} }
}); });
router.post('/reindex', (req, res) => {
auth.authCheck(req)
.then(() => {
book.reindexPages(req)
.then(response => {
//reset settings index
settings.resetLibraryIndex(response.count + 1);
//return success to front end
res.json(response);
})
.catch(err => {
res.json({
type: err.type,
message: err.message
});
});
})
.catch(err => {
res.json({
type: err.type,
message: err.message
});
});
});
module.exports = router; module.exports = router;
function getBookData() { function getBookData() {

@ -51,7 +51,7 @@ export default class Book {
//TODO: Duct tape solution until something better created //TODO: Duct tape solution until something better created
//make check against menu to see if page should be marked as menu item //make check against menu to see if page should be marked as menu item
//if it doesnt' exist in menu change, edit page to //if it doesn't exist in menu change, edit page to
let page = _.find(pages, list => { let page = _.find(pages, list => {
return list.metadata.uuid === id; return list.metadata.uuid === id;
}); });
@ -227,6 +227,46 @@ export default class Book {
}); });
} }
reindexPages(req) {
var response = '';
var self = this;
return new Promise((resolve, reject) => {
self.getPage()
.then(pages => {
let sorted = [];
for (let i = 0; i < pages.length; i++) {
let body = pages[i].metadata;
body.content = pages[i].content;
sorted.push(body);
}
//resorts pages by date created
let byDate = _.sortBy(sorted, page => {
return page.created;
});
//reassigns id sequentially based on sorted pages
for (let index = 0; index < byDate.length; index++) {
byDate[index].id = index;
self.editPage(
byDate[index],
index,
DataEvent.API_PAGE_WRITE,
req.session.user
);
}
response = {
type: DataEvent.API_REINDEX_PAGES,
message: 'Pages re-sorted. Easy peasy.',
count: byDate.length
};
resolve(response);
})
.catch(err => {
response = { type: DataEvent.PAGE_ERROR, message: err };
reject(response);
});
});
}
//-------------------------- //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------

@ -41,7 +41,8 @@ export default class Render {
return ( return (
page.metadata.deleted === false && page.metadata.deleted === false &&
page.metadata.published === true && page.metadata.published === true &&
page.metadata.featured === true page.metadata.featured === true &&
page.metadata.layout !== 'index'
); );
}); });
for (let index = 0; index < pages.length; index++) { for (let index = 0; index < pages.length; index++) {

@ -122,8 +122,32 @@ export default class Settings {
updatePageIndex() { updatePageIndex() {
fs.readJSON('site/settings.json').then(settings => { fs.readJSON('site/settings.json').then(settings => {
settings.library_stats.current_index = ++settings.library_stats.current_index; settings.library_stats.current_index = ++settings.library_stats.current_index;
//settings.library_stats.total_pages = ++settings.library_stats.total_pages; setTimeout(() => {
fs.writeJSON('site/settings.json', settings); //TODO: Duct tape solution until something better created
fs.writeJSON('site/settings.json', settings)
.then(() => {
//console.log('ALL TO THE GOOD');
})
.catch(() => {
//.log('ERR', err);
});
}, 100);
});
}
resetLibraryIndex(index) {
fs.readJSON('site/settings.json').then(settings => {
settings.library_stats.current_index = index;
setTimeout(() => {
//TODO: Duct tape solution until something better created
fs.writeJSON('site/settings.json', settings)
.then(() => {
//console.log('ALL TO THE GOOD');
})
.catch(() => {
//.log('ERR', err);
});
}, 100);
}); });
} }
load(fileToLoad) { load(fileToLoad) {

@ -97,9 +97,6 @@ export default class Utils {
} }
render.publishArchive(archive); render.publishArchive(archive);
} }
reindexPages(pages) {
//let byDate = _.sortBy(pages, ['created']);
}
moveAssets() { moveAssets() {
settings settings
.load(SETTINGS_FILE) .load(SETTINGS_FILE)
@ -128,6 +125,7 @@ export default class Utils {
//console.log('Copy completed!'); //console.log('Copy completed!');
} }
); );
//TODO: Add method to move new logo to public from theme upload
}) })
.catch(() => { .catch(() => {
//console.log('ERROR', err); //console.log('ERROR', err);

@ -56,7 +56,9 @@ block main-content
button#restore-backup(for='backup-upload') RESTORE BACKUP button#restore-backup(for='backup-upload') RESTORE BACKUP
input(id="backup-upload" type="file" name="backup-upload") input(id="backup-upload" type="file" name="backup-upload")
#util-2.column #util-2.column
label MAINTENANCE label MAINTENANCE
br
button#reindex-pages REINDEX PAGES
#option-settings.columns #option-settings.columns
#theme-settings.column #theme-settings.column
label THEMES label THEMES

@ -1,6 +1,6 @@
{ {
"name": "fipamo-beta", "name": "fipamo-beta",
"version": "1.2.3", "version": "1.2.4",
"private": true, "private": true,
"description": "The most chill blog framework ever.", "description": "The most chill blog framework ever.",
"repository": "https://code.playvicio.us/Are0h/Fipamo", "repository": "https://code.playvicio.us/Are0h/Fipamo",

File diff suppressed because it is too large Load Diff

@ -123,7 +123,7 @@ parcelRequire = (function (modules, cache, entry, globalName) {
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = exports.SEND_MAIL = exports.API_INIT_LAME = exports.API_INIT_GOOD = exports.API_INIT = exports.API_RENDER_PAGES = exports.API_IMAGES_UPLOAD = exports.API_BACKUP_RESTORE = exports.API_BACKUP_DOWNLOAD = exports.API_BACKUP_CREATE = exports.API_SETTINGS_WRITE = exports.API_PAGE_DELETE = exports.API_PAGE_CREATE = exports.API_PAGE_WRITE = exports.UPLOAD_PROGRESS = exports.SITE_BACKGROUND_UPLOADED = exports.AVATAR_UPLOADED = exports.MENU_UPDATED = exports.MENU_DELETE_ITEM = exports.MENU_ADD_ITEM = exports.SETTINGS_NOT_UPDATED = exports.SETTINGS_UPDATED = exports.TAG_PAGES_NOT_RENDERED = exports.TAG_PAGES_RENDERED = exports.PAGES_NOT_RENDERED = exports.PAGES_RENDERED = exports.PAGE_DELETED = exports.PAGE_UPDATED = exports.PAGE_ADDED = exports.PAGE_ERROR = exports.FEATURE_IMAGE_ADDED = exports.POST_IMAGE_ADDED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.API_REQUEST_LAME = exports.API_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0; exports.default = exports.SEND_MAIL = exports.API_INIT_LAME = exports.API_INIT_GOOD = exports.API_INIT = exports.API_REINDEX_PAGES = exports.API_RENDER_PAGES = exports.API_IMAGES_UPLOAD = exports.API_BACKUP_RESTORE = exports.API_BACKUP_DOWNLOAD = exports.API_BACKUP_CREATE = exports.API_SETTINGS_WRITE = exports.API_PAGE_DELETE = exports.API_PAGE_CREATE = exports.API_PAGE_WRITE = exports.UPLOAD_PROGRESS = exports.SITE_BACKGROUND_UPLOADED = exports.AVATAR_UPLOADED = exports.MENU_UPDATED = exports.MENU_DELETE_ITEM = exports.MENU_ADD_ITEM = exports.SETTINGS_NOT_UPDATED = exports.SETTINGS_UPDATED = exports.TAG_PAGES_NOT_RENDERED = exports.TAG_PAGES_RENDERED = exports.PAGES_NOT_RENDERED = exports.PAGES_RENDERED = exports.PAGE_DELETED = exports.PAGE_UPDATED = exports.PAGE_ADDED = exports.PAGE_ERROR = exports.FEATURE_IMAGE_ADDED = exports.POST_IMAGE_ADDED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.API_REQUEST_LAME = exports.API_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -195,6 +195,8 @@ var API_IMAGES_UPLOAD = 'uploadProfileImages';
exports.API_IMAGES_UPLOAD = API_IMAGES_UPLOAD; exports.API_IMAGES_UPLOAD = API_IMAGES_UPLOAD;
var API_RENDER_PAGES = 'renderPages'; var API_RENDER_PAGES = 'renderPages';
exports.API_RENDER_PAGES = API_RENDER_PAGES; exports.API_RENDER_PAGES = API_RENDER_PAGES;
var API_REINDEX_PAGES = 'reindexPages';
exports.API_REINDEX_PAGES = API_REINDEX_PAGES;
var API_INIT = 'blogInit'; var API_INIT = 'blogInit';
exports.API_INIT = API_INIT; exports.API_INIT = API_INIT;
var API_INIT_GOOD = 'blogInitGood'; var API_INIT_GOOD = 'blogInitGood';
@ -380,7 +382,7 @@ exports.default = APIUtils;
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = exports.API_SEND_MAIL = exports.API_INIT_RESTORE_BACKUP = exports.API_RESTORE_BACKUP = exports.API_DOWNLOAD_BACKUP = exports.API_CREATE_BACKUP = exports.API_NAV_SYNC = exports.API_PUBLISH_PAGES = exports.API_UPLOAD_BACKGROUND = exports.API_UPLOAD_AVATAR = exports.API_SETTINGS_SYNC = exports.API_IMAGE_UPLOAD = exports.API_DELETE_PAGE = exports.API_EDIT_PAGE = exports.API_NEW_PAGE = exports.API_GET_NAV = exports.API_STATUS = exports.CONTENT_TYPE_FORM = exports.CONTENT_TYPE_JSON = exports.TASK_PAGE_DELETE = exports.TASK_PAGE_EDIT = exports.TASK_PAGE_CREATE = exports.REQUEST_TYPE_DELETE = exports.REQUEST_TYPE_PUT = exports.REQUEST_TYPE_GET = exports.REQUEST_TYPE_POST = void 0; exports.default = exports.API_SEND_MAIL = exports.API_INIT_RESTORE_BACKUP = exports.API_RESTORE_BACKUP = exports.API_DOWNLOAD_BACKUP = exports.API_CREATE_BACKUP = exports.API_REINDEX_PAGES = exports.API_NAV_SYNC = exports.API_PUBLISH_PAGES = exports.API_UPLOAD_BACKGROUND = exports.API_UPLOAD_AVATAR = exports.API_SETTINGS_SYNC = exports.API_IMAGE_UPLOAD = exports.API_DELETE_PAGE = exports.API_EDIT_PAGE = exports.API_NEW_PAGE = exports.API_GET_NAV = exports.API_STATUS = exports.CONTENT_TYPE_FORM = exports.CONTENT_TYPE_JSON = exports.TASK_PAGE_DELETE = exports.TASK_PAGE_EDIT = exports.TASK_PAGE_CREATE = exports.REQUEST_TYPE_DELETE = exports.REQUEST_TYPE_PUT = exports.REQUEST_TYPE_GET = exports.REQUEST_TYPE_POST = void 0;
var DataEvent = _interopRequireWildcard(require("../com/events/DataEvent")); var DataEvent = _interopRequireWildcard(require("../com/events/DataEvent"));
@ -434,6 +436,8 @@ var API_PUBLISH_PAGES = '/api/v1/settings/publish-pages';
exports.API_PUBLISH_PAGES = API_PUBLISH_PAGES; exports.API_PUBLISH_PAGES = API_PUBLISH_PAGES;
var API_NAV_SYNC = '/api/v1/settings/nav-sync'; var API_NAV_SYNC = '/api/v1/settings/nav-sync';
exports.API_NAV_SYNC = API_NAV_SYNC; exports.API_NAV_SYNC = API_NAV_SYNC;
var API_REINDEX_PAGES = '/api/v1/settings/reindex';
exports.API_REINDEX_PAGES = API_REINDEX_PAGES;
var API_CREATE_BACKUP = '/api/v1/backup/create'; var API_CREATE_BACKUP = '/api/v1/backup/create';
exports.API_CREATE_BACKUP = API_CREATE_BACKUP; exports.API_CREATE_BACKUP = API_CREATE_BACKUP;
var API_DOWNLOAD_BACKUP = '/api/v1/backup/download'; var API_DOWNLOAD_BACKUP = '/api/v1/backup/download';
@ -666,6 +670,19 @@ var APIUtils = /*#__PURE__*/function () {
reject(err); reject(err);
}); });
}); });
}
}, {
key: "handleReindex",
value: function handleReindex(data) {
var _this10 = this;
return new Promise(function (resolve, reject) {
_this10._request(API_REINDEX_PAGES, DataEvent.API_REINDEX_PAGES, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, data).then(function (result) {
resolve(result);
}).catch(function (err) {
reject(err);
});
});
} //-------------------------- } //--------------------------
// private // private
//-------------------------- //--------------------------
@ -693,7 +710,7 @@ var APIUtils = /*#__PURE__*/function () {
}; };
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) { if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
if (eventType === DataEvent.API_PAGE_WRITE || eventType === DataEvent.API_IMAGES_UPLOAD || eventType === DataEvent.API_SETTINGS_WRITE || eventType === DataEvent.API_PAGE_DELETE || eventType === DataEvent.API_RENDER_PAGES || eventType === DataEvent.API_BACKUP_CREATE || eventType === DataEvent.API_BACKUP_RESTORE) request.setRequestHeader('x-access-token', self.token); if (eventType === DataEvent.API_PAGE_WRITE || eventType === DataEvent.API_IMAGES_UPLOAD || eventType === DataEvent.API_SETTINGS_WRITE || eventType === DataEvent.API_PAGE_DELETE || eventType === DataEvent.API_RENDER_PAGES || eventType === DataEvent.API_BACKUP_CREATE || eventType === DataEvent.API_BACKUP_RESTORE || eventType === DataEvent.API_REINDEX_PAGES) request.setRequestHeader('x-access-token', self.token);
switch (contentType) { switch (contentType) {
case CONTENT_TYPE_JSON: case CONTENT_TYPE_JSON:
@ -3953,9 +3970,12 @@ var PostEditor = /*#__PURE__*/function () {
key: "handleImageUpload", key: "handleImageUpload",
value: function handleImageUpload(type, files) { value: function handleImageUpload(type, files) {
var self = this; var self = this;
notify.alert('Uploading Image', null);
admin.imageUpload(type, files).then(function (r) { admin.imageUpload(type, files).then(function (r) {
if (r.type == DataEvent.POST_IMAGE_ADDED) self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url); if (r.type == DataEvent.POST_IMAGE_ADDED) self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
}).catch(function () {//console.log('ERROR', err); notify.alert('Image Added to Entry', true);
}).catch(function () {
notify.alert('Uh oh. Image not added', false); //console.log('ERROR', err);
}); });
} }
}]); }]);
@ -4297,6 +4317,9 @@ var SettingsIndex = /*#__PURE__*/function () {
document.getElementById('create-backup').addEventListener('click', function (e) { document.getElementById('create-backup').addEventListener('click', function (e) {
return _this.handleBackup(e); return _this.handleBackup(e);
}); });
document.getElementById('reindex-pages').addEventListener('click', function (e) {
return _this.handleReindex(e);
});
} //-------------------------- } //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------
@ -4413,6 +4436,21 @@ var SettingsIndex = /*#__PURE__*/function () {
notify.alert(err, false); notify.alert(err, false);
}); });
} }
}, {
key: "handleReindex",
value: function handleReindex(e) {
e.preventDefault();
e.stopPropagation();
var task = {
task: 'cleanup pages indexes'
};
notify.alert('Cleaning up page indexes', null);
admin.handleReindex(task).then(function (r) {
notify.alert(r.message, true);
}).catch(function (err) {
notify.alert(err, false);
});
}
}]); }]);
return SettingsIndex; return SettingsIndex;
@ -8574,7 +8612,7 @@ var parent = module.bundle.parent;
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
var hostname = "" || location.hostname; var hostname = "" || location.hostname;
var protocol = location.protocol === 'https:' ? 'wss' : 'ws'; var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
var ws = new WebSocket(protocol + '://' + hostname + ':' + "57701" + '/'); var ws = new WebSocket(protocol + '://' + hostname + ':' + "55198" + '/');
ws.onmessage = function (event) { ws.onmessage = function (event) {
checkedAssets = {}; checkedAssets = {};

Loading…
Cancel
Save