|
|
@ -6,15 +6,18 @@ import * as DataEvent from '../../src/com/events/DataEvent';
|
|
|
|
import Navigation from './Navigation';
|
|
|
|
import Navigation from './Navigation';
|
|
|
|
import Settings from './Settings';
|
|
|
|
import Settings from './Settings';
|
|
|
|
import StringUtils from '../../src/com/utils/StringUtils';
|
|
|
|
import StringUtils from '../../src/com/utils/StringUtils';
|
|
|
|
|
|
|
|
import Render from './Render';
|
|
|
|
|
|
|
|
const moment = require('moment');
|
|
|
|
const nav = new Navigation();
|
|
|
|
const nav = new Navigation();
|
|
|
|
const settings = new Settings();
|
|
|
|
const settings = new Settings();
|
|
|
|
const utils = new StringUtils();
|
|
|
|
const utils = new StringUtils();
|
|
|
|
const moment = require('moment');
|
|
|
|
const render = new Render();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Class for handling blog content pages
|
|
|
|
* Class for handling blog content pages
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
export default class Pages {
|
|
|
|
export default class Book {
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// constructor
|
|
|
|
// constructor
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
@ -23,7 +26,6 @@ export default class Pages {
|
|
|
|
// methods
|
|
|
|
// methods
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
start() {}
|
|
|
|
start() {}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Retrieves single page or pages
|
|
|
|
* Retrieves single page or pages
|
|
|
|
* @parameter id: optional id if requesting a single Page
|
|
|
|
* @parameter id: optional id if requesting a single Page
|
|
|
@ -187,6 +189,7 @@ export default class Pages {
|
|
|
|
* Retrieves single page or pages
|
|
|
|
* Retrieves single page or pages
|
|
|
|
* @parameter pages: payload of pages
|
|
|
|
* @parameter pages: payload of pages
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
organizeTags(pages) {
|
|
|
|
organizeTags(pages) {
|
|
|
|
let tags = [];
|
|
|
|
let tags = [];
|
|
|
|
for (let index = 0; index < pages.length; index++) {
|
|
|
|
for (let index = 0; index < pages.length; index++) {
|
|
|
@ -194,25 +197,30 @@ export default class Pages {
|
|
|
|
let temp = [];
|
|
|
|
let temp = [];
|
|
|
|
temp = page.metadata.tags.split(',');
|
|
|
|
temp = page.metadata.tags.split(',');
|
|
|
|
for (let i = 0; i < temp.length; i++) {
|
|
|
|
for (let i = 0; i < temp.length; i++) {
|
|
|
|
let label = temp[i];
|
|
|
|
let label = temp[i].trim();
|
|
|
|
if (!_.find(tags, { tag_name: label.trim() })) {
|
|
|
|
if (!_.find(tags, { tag_name: label })) {
|
|
|
|
tags.push({
|
|
|
|
tags.push({
|
|
|
|
tag_name: label.trim(),
|
|
|
|
tag_name: label,
|
|
|
|
slug: utils.cleanString(label.trim()),
|
|
|
|
slug: utils.cleanString(label),
|
|
|
|
count: 1
|
|
|
|
count: 1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
_.find(tags, { tag_name: label.trim() }).count++;
|
|
|
|
_.find(tags, { tag_name: label }).count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tags = _.orderBy(tags, ['tag_name'], ['asc']);
|
|
|
|
tags = _.orderBy(tags, ['tag_name'], ['asc']);
|
|
|
|
settings
|
|
|
|
settings.saveTags(tags).then(response => {
|
|
|
|
.saveTags(tags)
|
|
|
|
console.log('RESPONSE', response);
|
|
|
|
.then(result => {
|
|
|
|
render
|
|
|
|
console.log('RESPONSE', result);
|
|
|
|
.publishTags(pages)
|
|
|
|
|
|
|
|
.then(response => {
|
|
|
|
|
|
|
|
console.log(response);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {});
|
|
|
|
.catch(err => {
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|