Skip to content

Commit

Permalink
Added offset columns for page content.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpox committed Oct 12, 2018
1 parent f4fe388 commit 5853a8a
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Index {
.populate('created_by', '-password').populate('image');

if (query) {
const contentFields = ['title', 'content', 'content_column', '_id'];
const contentFields = ['title', 'content', 'content_column', 'content_offset', '_id'];
const contentQuery = await Content.find({ page_id: query._id }).select(contentFields.join(' '));

/*
Expand Down
6 changes: 4 additions & 2 deletions app/controller/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PageC {
try {
const page = await Page.get(req.params.id);
if (page) {
const contentFields = ['title', 'content', 'content_column', '_id'];
const contentFields = ['title', 'content', 'content_column', 'content_offset', '_id'];
const contentQuery = await Content.find({ page_id: req.params.id }).select(contentFields.join(' '));
res.json({
details: page,
Expand All @@ -61,7 +61,7 @@ class PageC {
try {
const page = await Page.fromUrl(req.params.url);
if (page) {
const contentFields = ['title', 'content', 'content_column', '_id'];
const contentFields = ['title', 'content', 'content_column', 'content_offset', '_id'];
const contentQuery = await Content.find({ page_id: page._id }).select(contentFields.join(' '));

/*
Expand Down Expand Up @@ -106,6 +106,7 @@ class PageC {
title: contents[i].title,
content: contents[i].content,
content_column: contents[i].content_column,
content_offset: contents[i].content_offset,
created_by: Db.Types.ObjectId(req.currentUser),
page_id: Db.Types.ObjectId(newPage._id),
});
Expand Down Expand Up @@ -155,6 +156,7 @@ class PageC {
page_id: Db.Types.ObjectId(req.params.id),
content: contents[i].content,
content_column: contents[i].content_column,
content_offset: contents[i].content_offset,
created_by: Db.Types.ObjectId(req.currentUser),
});
}
Expand Down
3 changes: 2 additions & 1 deletion app/model/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const schema = Db.Schema({
title: String,
page_id: { type: ObjectId, ref: 'Page' },
content: String,
content_column: Number,
content_column: { type: Number, default: 1 },
content_offset: { type: Number, default: 0 },
created_by: { type: ObjectId, ref: 'User' },
created_at: { type: Date, default: Date.now },
last_updated: { type: Date, default: Date.now },
Expand Down
5 changes: 1 addition & 4 deletions app/ribbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import Pug from 'pug';

import Moment from 'moment';

import Routes from './route';

class Ribbon {
constructor(express, app, log) {
this.express = express;
Expand Down Expand Up @@ -49,9 +47,8 @@ class Ribbon {

this.setLocals();
this.setHeaders();

this.loadRoutes();
// this.routes = Routes.routes(this.app);
// this.routes = Routes(this.app);
this.loadPlugins();
this.start();
}
Expand Down
5 changes: 3 additions & 2 deletions app/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Obtaining middlewares.
*/
* This file is deprecated.
* Obtaining middlewares.
*/
import { isLogged, notLogged } from './middleware/auth';

import { isAdmin, isEditor } from './middleware/group';
Expand Down
4 changes: 4 additions & 0 deletions app/route/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { avatar } from '../middleware/image_upload';

import { isAdmin } from '../middleware/group';

import navigationMiddleware from '../middleware/navigation';

import Auth from '../controller/authenticate';

import Blog from '../controller/blog';
Expand All @@ -15,6 +17,8 @@ module.exports = (app) => {
const blog = new Blog();
const navigation = new Navigation();

app.use(navigationMiddleware);

app.post('/api/auth', notLogged, auth.signin);
app.post('/api/auth/check', auth.check);
app.post('/api/auth/logout', isLogged, auth.logout);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ribbon",
"version": "2018.10.11",
"version": "2018.10.12",
"description": "A platform to share your stories.",
"main": "dist/ribbon.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion themes/july/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

.row
each box in boxes
div(class="col-md-"+box.content_column)
div(class="col-md-"+box.content_column class=(box.content_offset === 0)? "" : "offset-md-" + box.content_offset)
.card
.card-body
h5.card-title=box.title
Expand Down
5 changes: 4 additions & 1 deletion update.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Prompt from 'prompt';

import User from './app/model/user';

import Content from './app/model/content';

import Session from './app/model/session';

DotEnv.config();
Expand All @@ -20,7 +22,7 @@ const Schema = {
};

console.log('\x1b[47m\x1b[35m', 'ribbon Update', '\x1b[0m');
console.log('\x1b[47m\x1b[35m', 'Note that this upgrade script will only work on an existing ribbon 2018.9.17 installation.', '\x1b[0m');
console.log('\x1b[47m\x1b[35m', 'Note that this upgrade script will only work on ribbon 2018.9.17 or older.', '\x1b[0m');

/*
* Script for future use.
Expand All @@ -29,6 +31,7 @@ console.log('\x1b[47m\x1b[35m', 'Note that this upgrade script will only work on
Prompt.get(Schema, async (prompt_err, prompt) => {
if (prompt.continue.toLowerCase() === 'y') {
await User.updateMany({}, { group: 1 }, { multi: true });
await Content.updateMany({}, { content_offset: 0 }, { multi: true });

/*
* Remove all existing sessions. With the change in usergroup, everyone has to log in again.
Expand Down

0 comments on commit 5853a8a

Please sign in to comment.