diff --git a/.gitignore b/.gitignore
index c03c85c..af2a7fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,22 +2,24 @@ node_modules/
.sass-cache/
.cache/
.nova/
+/*
+!public/
public/*
+!public/favicon.ico
+!public/assets
+public/assets/*
+!public/assets/images
public/assets/images/*
-!public/assets/images/global
+!public/assets/images/global/
+!public/assets/images/global/*
+
content/
.ftpconfig
.vscode/
-config.development.json
*.swp
-/config.json
site/settings.json
site/folks.json
site/pages.json
site/tags.json
site/_backup
-brain/models/_backup/
-/_maintenance/
*.DS_Store
-/forfipamo
-site-settings.json
diff --git a/brain/api/v1/pages.js b/brain/api/v1/pages.js
index d3b2b00..f74a689 100644
--- a/brain/api/v1/pages.js
+++ b/brain/api/v1/pages.js
@@ -37,15 +37,89 @@ var post_upload = multer({
}).array('post_image');
/**
- * Retrieves list of Pages
+ * Retrieves a page of a published entries
* @public
*/
-router.get('/', (req, res) => {
+router.get('/published/:pageNum?', (req, res) => {
+ //console.log('PAGE NUM', req.params.pageNum);
+ let pageNum = req.params.pageNum;
+ if (pageNum === null || pageNum === '' || !pageNum) pageNum = 1;
+ let pages = [];
book.getPage().then(result => {
- res.json(result);
+ result.sort((a, b) => parseFloat(b.metadata.id) - parseFloat(a.metadata.id));
+ let displayed = _.filter(result, page => {
+ return (
+ page.metadata.deleted === false &&
+ page.metadata.published === true &&
+ page.metadata.layout != 'index'
+ );
+ });
+ var pageLimit = 6;
+ var count = Math.ceil(displayed.length / pageLimit);
+ if (pageNum > count || isNaN(pageNum))
+ res.json({ type: DataEvent.REQUEST_LAME, message: "That page doesn't exist, champ." });
+ var rangeIndex = pageNum * pageLimit - pageLimit;
+
+ let meta = [];
+
+ for (let index = 0; index < pageLimit; index++) {
+ const page = displayed[index + rangeIndex];
+ try {
+ if (
+ page.metadata.id != null &&
+ page.metadata.deleted === false &&
+ page.metadata.published === true
+ ) {
+ let entry = page.metadata;
+ entry.content = page.content;
+ //console.log('ENTRY', entry);
+ pages.push({
+ page: entry,
+ displayDate: moment(page.metadata.created).fromNow()
+ });
+ }
+ } catch (e) {
+ //console.log("NO POST", e)
+ }
+ }
+ meta.push({ currentPage: pageNum, totalPages: count });
+ let data = { pages: pages, meta: meta };
+ res.json({
+ type: DataEvent.REQUEST_GOOD,
+ message: 'This is Page ' + pageNum + ' of ' + count,
+ data: data
+ });
});
});
+/**
+ * Retrieves single entry
+ * @public
+ */
+
+router.get('/single/:id', (req, res) => {
+ let id = req.params.id;
+ if (id === null || id === '')
+ res.json({ type: DataEvent.REQUEST_LAME, message: " Nah, this isn't here." });
+ book.getPage(id)
+ .then(page => {
+ let entry = page.metadata;
+ entry.content = page.content;
+ res.json({
+ type: DataEvent.REQUEST_GOOD,
+ message: 'Found it. Here you go.',
+ data: entry
+ });
+ })
+ .catch(err => {
+ res.json({
+ type: DataEvent.REQUEST_LAME,
+ message: "This doesn't seem to be here, homie.",
+ err: err.message
+ });
+ });
+});
+
/**
* Add/Update Page
*/
@@ -121,7 +195,7 @@ router.post('/write/:task?', feature_upload, (req, res) => {
}
})
.catch(() => {
- console.log();
+ //console.log();
});
res.json(result);
})
diff --git a/brain/app.js b/brain/app.js
index 13b96b9..b4260b1 100644
--- a/brain/app.js
+++ b/brain/app.js
@@ -8,7 +8,9 @@ var session = require('express-session');
var MemoryStore = require('memorystore')(session);
var flash = require('connect-flash');
var app = express();
-//var request = require('request');
+// favicon stuff
+//app.use(favicon(path.join(__dirname, 'favicons', 'favicon.ico')));
+
// view engine setup
app.set('views', path.join(__dirname, './views'));
app.set('view engine', 'pug');
@@ -23,8 +25,7 @@ app.use(
);
app.use(cookieParser());
app.use(express.static(path.join(__dirname, '../public'), { extensions: ['html'] }));
-//app.use(express.static(path.join(__dirname, '../content')));
-//app.use(express.static(path.join(__dirname, '../themes')));
+
app.use(
session({
store: new MemoryStore({
diff --git a/brain/data/Render.js b/brain/data/Render.js
index 82093e3..e49e6c9 100644
--- a/brain/data/Render.js
+++ b/brain/data/Render.js
@@ -3,6 +3,7 @@ import StringUtils from '../../src/com/utils/StringUtils';
import Settings, { SETTINGS_FILE, SETTINGS_TAG } from './Settings';
import fs from 'fs-extra';
import sanitize from 'sanitize-html';
+import Utils from './Utils';
const pug = require('pug');
const md = require('markdown-it')('commonmark');
const _ = require('lodash');
@@ -137,6 +138,8 @@ export default class Render {
type: DataEvent.PAGES_RENDERED,
message: 'All Pages Rendered. Sweet.'
};
+ //utils.moveAssets();
+ new Utils().moveAssets();
resolve(response);
}
} else {
@@ -184,11 +187,16 @@ export default class Render {
let page = pages[i];
//TODO: filter for deleted and unpublished pages
- if (_.includes(page.metadata.tags, tag.tag_name)) {
- pageList.push({
- title: page.metadata.title,
- slug: page.metadata.slug
- });
+ if (
+ page.metedata.deleted === false &&
+ page.metadata.published === true
+ ) {
+ if (_.includes(page.metadata.tags, tag.tag_name)) {
+ pageList.push({
+ title: page.metadata.title,
+ slug: page.metadata.slug
+ });
+ }
}
}
renderList.push({ tag: tag.tag_name, tag_list: pageList, slug: tag.slug });
diff --git a/brain/data/Utils.js b/brain/data/Utils.js
index dbd1093..498ff20 100644
--- a/brain/data/Utils.js
+++ b/brain/data/Utils.js
@@ -1,4 +1,4 @@
-import Settings from './Settings';
+import Settings, { SETTINGS_FILE } from './Settings';
import Render from './Render';
import StringUtils from '../../src/com/utils/StringUtils';
import _ from 'lodash';
@@ -6,6 +6,7 @@ const settings = new Settings();
const render = new Render();
const stringUtils = new StringUtils();
const moment = require('moment');
+const fs = require('fs-extra');
export default class Utils {
constructor() {}
@@ -93,4 +94,37 @@ export default class Utils {
}
render.publishArchive(archive);
}
+ moveAssets() {
+ settings
+ .load(SETTINGS_FILE)
+ .then(settings => {
+ //move css assets to public directory
+ fs.copy(
+ 'content/themes/' + settings.global.theme + '/assets/css',
+ 'public/assets/css',
+ function (err) {
+ if (err) {
+ //console.log('An error occured while copying the folder.', err);
+ //return console.error(err);
+ }
+ //console.log('Copy completed!');
+ }
+ );
+ //move js assets to public directory
+ fs.copy(
+ 'content/themes/' + settings.global.theme + '/assets/scripts',
+ 'public/assets/scripts',
+ function (err) {
+ if (err) {
+ //console.log('An error occured while copying the folder.', err);
+ //return console.error(err);
+ }
+ //console.log('Copy completed!');
+ }
+ );
+ })
+ .catch(() => {
+ //console.log('ERROR', err);
+ });
+ }
}
diff --git a/package.json b/package.json
index 72f14f1..6e53b21 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"dev": "nodemon -r esm init.js --ignore node_modules/ -e js",
"debug": "nodemon inspect -r esm init.js --ignore node_modules/ -e js",
"prettier-watch": "npx onchange '**/*.js' -- npx prettier --write {{changed}}",
- "watch-back": "stylus -w -m -o public/assets/css src/styles/dash.styl & parcel watch src/com/Start.js --out-dir public/assets/scripts --out-file dash.min.js --public-url /assets/scripts",
+ "watch": "stylus -w -o public/assets/css src/styles/dash.styl & parcel watch src/com/Start.js --out-dir public/assets/scripts --out-file dash.min.js --public-url /assets/scripts",
"build-back-kit": "uglifyjs src/libraries/highlight.pack.js node_modules/sortablejs/Sortable.min.js node_modules/scramble-text/dist/ScrambleText.min.js node_modules/reframe.js/dist/reframe.min.js -c -o public/assets/scripts/dashkit.min.js"
},
"engines": {
@@ -65,4 +65,4 @@
"scramble-text": "0.0.8",
"stylus": "^0.54.7"
}
-}
+}
\ No newline at end of file
diff --git a/public/assets/images/global/default-avi.png b/public/assets/images/global/default-avi.png
new file mode 100644
index 0000000..99ee4bb
Binary files /dev/null and b/public/assets/images/global/default-avi.png differ
diff --git a/public/assets/images/global/default-bg.jpg b/public/assets/images/global/default-bg.jpg
new file mode 100644
index 0000000..ff29737
Binary files /dev/null and b/public/assets/images/global/default-bg.jpg differ
diff --git a/public/assets/images/global/sprite.svg b/public/assets/images/global/sprite.svg
new file mode 100644
index 0000000..565e7ab
--- /dev/null
+++ b/public/assets/images/global/sprite.svg
@@ -0,0 +1,823 @@
+
\ No newline at end of file
diff --git a/public/assets/images/global/the-logo.svg b/public/assets/images/global/the-logo.svg
new file mode 100644
index 0000000..f8d21b5
--- /dev/null
+++ b/public/assets/images/global/the-logo.svg
@@ -0,0 +1,33 @@
+
+
+
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..ab85c7e
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/src/libraries/FipamoAPI.js b/src/libraries/FipamoAPI.js
index 52a729f..48adf2a 100644
--- a/src/libraries/FipamoAPI.js
+++ b/src/libraries/FipamoAPI.js
@@ -7,6 +7,8 @@ export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
export const API_STATUS = '/api/v1/auth/status';
export const API_INIT = '/api/v1/auth/init';
export const API_LOGIN = '/api/v1/auth/login';
+export const API_GET_PAGES = '/api/v1/page/published';
+export const API_GET_PAGE = '/api/v1/page/single';
import * as DataEvent from '../com/events/DataEvent';
export default class APIUtils {
//--------------------------
@@ -44,6 +46,31 @@ export default class APIUtils {
});
});
}
+ getPages(num) {
+ let pageNum = num;
+ if (pageNum === null || pageNum === '' || !pageNum) pageNum = 1;
+ return new Promise((resolve, reject) => {
+ this._request(API_GET_PAGES + '/' + pageNum, DataEvent.API_GET_PAGES, REQUEST_TYPE_GET)
+ .then(result => {
+ resolve(result);
+ })
+ .catch(err => {
+ reject(err);
+ });
+ });
+ }
+
+ getPage(id) {
+ return new Promise((resolve, reject) => {
+ this._request(API_GET_PAGE + '/' + id, DataEvent.API_GET_PAGES, REQUEST_TYPE_GET)
+ .then(result => {
+ resolve(result);
+ })
+ .catch(err => {
+ reject(err);
+ });
+ });
+ }
//--------------------------
// private
//--------------------------
diff --git a/src/styles/dash.styl b/src/styles/dash.styl
index 2aac8b4..6c99863 100644
--- a/src/styles/dash.styl
+++ b/src/styles/dash.styl
@@ -31,7 +31,7 @@
@import 'main/_typography'
/**
-------------------------------
--- Main Structure
+-- Main Structures
-------------------------------
* */
@import 'main/_structure'
diff --git a/src/styles/main/_forms.styl b/src/styles/main/_forms.styl
index a7218a4..0505c2d 100644
--- a/src/styles/main/_forms.styl
+++ b/src/styles/main/_forms.styl
@@ -14,7 +14,7 @@ textarea
border 0
border-radius 3px
color $type02
- font 15px $monoType
+ font 1em $monoType
button, input[type=submit]
background $highlight
diff --git a/src/styles/main/_settings.styl b/src/styles/main/_settings.styl
index 43d4952..28e8481 100644
--- a/src/styles/main/_settings.styl
+++ b/src/styles/main/_settings.styl
@@ -1,7 +1,9 @@
#settings-actions
position fixed
- width 100%
+ width 40%
margin-top -85px
+ left 50%
+ margin-left -20%
#buttons
width 155px
margin 0 auto