Work on All Pages section

pull/73/head
NGPixel 8 years ago
parent d02b4a3591
commit 1d8285fb6a

@ -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
}
]
}

@ -1,9 +1,39 @@
'use strict'
import $ from 'jquery'
import Vue from 'vue'
import _ from 'lodash'
module.exports = (alerts, socket) => {
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('')
}
})
}
}

@ -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) => {
entries.getFromTree('/').then((pageData) => {
res.render('pages/all', { pageData })
return true
}).catch((err) => {
res.render('error', {
message: err.message,
error: {}
})
})
res.render('pages/all')
})
// ==========================================

@ -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
// -----------------------------------------

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

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

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

@ -26,87 +26,8 @@ block content
a(href='/login')
i.icon-unlock
span Login
ul.collapsable-nav.has-children
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.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
ul.collapsable-nav(v-for='treeItem in tree', :class='{ "has-children": treeItem.hasChildren }', v-cloak)
li(v-for='page in treeItem.pages', :class='{ "is-active": page.isActive }')
a(v-on:click='fetch(page._id)')
i(:class='{ "icon-folder2": page.isFolder, "icon-file": !page.isFolder }')
span {{ page.title }}

@ -21,27 +21,32 @@ cmdr.version(packageObj.version)
cmdr.command('start')
.description('Start Wiki.js process')
.action(() => {
let spinner = ora('Initializing...').start()
fs.emptyDirAsync(path.join(__dirname, './logs')).then(() => {
return pm2.connectAsync().then(() => {
return pm2.startAsync({
name: 'wiki',
script: 'server.js',
cwd: __dirname,
output: path.join(__dirname, './logs/wiki-output.log'),
error: path.join(__dirname, './logs/wiki-error.log'),
minUptime: 5000,
maxRestarts: 5
}).then(() => {
spinner.succeed('Wiki.js has started successfully.')
}).finally(() => {
pm2.disconnect()
if (process.env.HEROKU) {
console.info('Initializing Wiki.js for Heroku...')
// todo
} else {
let spinner = ora('Initializing...').start()
fs.emptyDirAsync(path.join(__dirname, './logs')).then(() => {
return pm2.connectAsync().then(() => {
return pm2.startAsync({
name: 'wiki',
script: 'server.js',
cwd: __dirname,
output: path.join(__dirname, './logs/wiki-output.log'),
error: path.join(__dirname, './logs/wiki-error.log'),
minUptime: 5000,
maxRestarts: 5
}).then(() => {
spinner.succeed('Wiki.js has started successfully.')
}).finally(() => {
pm2.disconnect()
})
})
}).catch(err => {
spinner.fail(err)
process.exit(1)
})
}).catch(err => {
spinner.fail(err)
process.exit(1)
})
}
})
cmdr.command('stop')

Loading…
Cancel
Save