Work on All Pages section

This commit is contained in:
NGPixel 2017-04-17 22:44:04 -04:00
parent d02b4a3591
commit 1d8285fb6a
9 changed files with 122 additions and 126 deletions

28
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach (Inspector Protocol)",
"port": 9229,
"protocol": "inspector"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}\\server.js"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Port",
"address": "localhost",
"port": 9222
}
]
}

View File

@ -1,9 +1,39 @@
'use strict' 'use strict'
import $ from 'jquery' import $ from 'jquery'
import Vue from 'vue'
import _ from 'lodash'
module.exports = (alerts, socket) => { module.exports = (alerts, socket) => {
if ($('#page-type-all').length) { if ($('#page-type-all').length) {
let vueAllPages = new Vue({ // eslint-disable-line no-unused-vars
el: '#page-type-all',
data: {
tree: []
},
methods: {
fetch: function (basePath) {
let self = this
$('#notifload').addClass('active')
Vue.nextTick(() => {
socket.emit('treeFetch', { basePath }, (data) => {
if (self.tree.length > 0) {
let curTree = _.last(self.tree)
curTree.hasChildren = true
_.find(curTree.pages, { _id: basePath }).isActive = true
}
self.tree.push({
hasChildren: false,
pages: data
})
$('#notifload').removeClass('active')
})
})
}
},
mounted: function () {
this.fetch('')
}
})
} }
} }

View File

@ -135,18 +135,10 @@ router.put('/create/*', (req, res, next) => {
// ========================================== // ==========================================
/** /**
* View list view of all pages * View tree view of all pages
*/ */
router.get('/all', (req, res, next) => { router.get('/all', (req, res, next) => {
entries.getFromTree('/').then((pageData) => { res.render('pages/all')
res.render('pages/all', { pageData })
return true
}).catch((err) => {
res.render('error', {
message: err.message,
error: {}
})
})
}) })
// ========================================== // ==========================================

View File

@ -18,6 +18,19 @@ module.exports = (socket) => {
}) })
} }
// -----------------------------------------
// TREE VIEW (LIST ALL PAGES)
// -----------------------------------------
if (socket.request.user.logged_in) {
socket.on('treeFetch', (data, cb) => {
cb = cb || _.noop
entries.getFromTree(data.basePath).then((f) => {
return cb(f) || true
})
})
}
// ----------------------------------------- // -----------------------------------------
// UPLOADS // UPLOADS
// ----------------------------------------- // -----------------------------------------

View File

@ -30,6 +30,12 @@ const args = require('yargs')
describe: 'Start in Configure Developer mode', describe: 'Start in Configure Developer mode',
type: 'boolean' type: 'boolean'
}) })
.option('i', {
alias: 'inspect',
describe: 'Enable Inspector for debugging',
type: 'boolean',
implies: 'd'
})
.help('h') .help('h')
.alias('h', 'help') .alias('h', 'help')
.argv .argv
@ -204,8 +210,7 @@ globalTasks.then(() => {
_.delay(() => { _.delay(() => {
nodemon({ nodemon({
script: './server.js', exec: (args.i) ? 'node --inspect server' : 'node server',
args: [],
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'], ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
ext: 'js json', ext: 'js json',
watch: [ watch: [

View File

@ -272,7 +272,7 @@ module.exports = {
}, },
/** /**
* Update local cache and search index * Update local cache
* *
* @param {String} entryPath The entry path * @param {String} entryPath The entry path
* @return {Promise} Promise of the operation * @return {Promise} Promise of the operation
@ -301,13 +301,14 @@ module.exports = {
winston.error(err) winston.error(err)
return err return err
}).then((content) => { }).then((content) => {
// let entryPaths = _.split(content.entryPath, '/')
return db.Entry.findOneAndUpdate({ return db.Entry.findOneAndUpdate({
_id: content.entryPath _id: content.entryPath
}, { }, {
_id: content.entryPath, _id: content.entryPath,
title: content.meta.title || content.entryPath, title: content.meta.title || content.entryPath,
subtitle: content.meta.subtitle || '', subtitle: content.meta.subtitle || '',
parent: content.parent.title || '', parentTitle: content.parent.title || '',
parentPath: content.parent.path || '' parentPath: content.parent.path || ''
}, { }, {
new: true, new: true,
@ -416,6 +417,6 @@ module.exports = {
* @return {Promise<Array>} List of entries * @return {Promise<Array>} List of entries
*/ */
getFromTree (basePath) { getFromTree (basePath) {
return Promise.resolve([]) return db.Entry.find({ parentPath: basePath })
} }
} }

View File

@ -6,7 +6,6 @@
* @type {<Mongoose.Schema>} * @type {<Mongoose.Schema>}
*/ */
var entrySchema = Mongoose.Schema({ var entrySchema = Mongoose.Schema({
_id: String, _id: String,
title: { title: {
@ -18,17 +17,19 @@ var entrySchema = Mongoose.Schema({
type: String, type: String,
default: '' default: ''
}, },
parent: { parentTitle: {
type: String, type: String,
default: '' default: ''
}, },
parentPath: { parentPath: {
type: String, type: String,
default: '' default: ''
}
}, },
{ isDirectory: {
type: Boolean,
default: false
}
}, {
timestamps: {} timestamps: {}
}) })

View File

@ -26,87 +26,8 @@ block content
a(href='/login') a(href='/login')
i.icon-unlock i.icon-unlock
span Login span Login
ul.collapsable-nav.has-children ul.collapsable-nav(v-for='treeItem in tree', :class='{ "has-children": treeItem.hasChildren }', v-cloak)
li: a li(v-for='page in treeItem.pages', :class='{ "is-active": page.isActive }')
i.icon-file a(v-on:click='fetch(page._id)')
span Page 1 i(:class='{ "icon-folder2": page.isFolder, "icon-file": !page.isFolder }')
li: a span {{ page.title }}
i.icon-file
span Page 2
li: a
i.icon-file
span Page 3
li.is-active: a
i.icon-folder2
span Page 4
li: a
i.icon-file
span Page 5
ul.collapsable-nav.has-children
li.is-title page-4
li: a
i.icon-file
span Page 1
li.is-active: a
i.icon-file
span Page 2
li: a
i.icon-file
span Page 3
li: a
i.icon-file
span Page 4
li: a
i.icon-file
span Page 5
ul.collapsable-nav.has-children
li.is-title page-4
li: a
i.icon-file
span Page 1
li.is-active: a
i.icon-file
span Page 2
li: a
i.icon-file
span Page 3
li: a
i.icon-file
span Page 4
li: a
i.icon-file
span Page 5
ul.collapsable-nav.has-children
li.is-title page-4
li: a
i.icon-file
span Page 1
li.is-active: a
i.icon-file
span Page 2
li: a
i.icon-file
span Page 3
li: a
i.icon-file
span Page 4
li: a
i.icon-file
span Page 5
ul.collapsable-nav
li.is-title Sub-Pages
li: a
i.icon-file
span Page 1
li: a
i.icon-file
span Page 2
li: a
i.icon-file
span Page 3
li: a
i.icon-file
span Page 4
li: a
i.icon-file
span Page 5

View File

@ -21,6 +21,10 @@ cmdr.version(packageObj.version)
cmdr.command('start') cmdr.command('start')
.description('Start Wiki.js process') .description('Start Wiki.js process')
.action(() => { .action(() => {
if (process.env.HEROKU) {
console.info('Initializing Wiki.js for Heroku...')
// todo
} else {
let spinner = ora('Initializing...').start() let spinner = ora('Initializing...').start()
fs.emptyDirAsync(path.join(__dirname, './logs')).then(() => { fs.emptyDirAsync(path.join(__dirname, './logs')).then(() => {
return pm2.connectAsync().then(() => { return pm2.connectAsync().then(() => {
@ -42,6 +46,7 @@ cmdr.command('start')
spinner.fail(err) spinner.fail(err)
process.exit(1) process.exit(1)
}) })
}
}) })
cmdr.command('stop') cmdr.command('stop')