Fix a bunch of IE errors
This commit is contained in:
parent
298910198e
commit
bc3aecb5d4
22 changed files with 3327 additions and 135 deletions
|
@ -1,5 +1,5 @@
|
||||||
const { getAllArticlesPagination, removeArticle } = require('../api/article')
|
const Article = require('../api/article')
|
||||||
const { fetchPage } = require('../api/pagination')
|
const pagination = require('../api/pagination')
|
||||||
const Dialogue = require('../widgets/dialogue')
|
const Dialogue = require('../widgets/dialogue')
|
||||||
const Pages = require('../widgets/pages')
|
const Pages = require('../widgets/pages')
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ const AdminArticles = {
|
||||||
this.links = null
|
this.links = null
|
||||||
this.lastpage = m.route.param('page') || '1'
|
this.lastpage = m.route.param('page') || '1'
|
||||||
|
|
||||||
return fetchPage(getAllArticlesPagination({
|
return pagination.fetchPage(Article.getAllArticlesPagination({
|
||||||
per_page: 10,
|
per_page: 10,
|
||||||
page: this.lastpage,
|
page: this.lastpage,
|
||||||
includes: ['parent'],
|
includes: ['parent'],
|
||||||
|
@ -46,7 +46,7 @@ const AdminArticles = {
|
||||||
let removingArticle = this.removeArticle
|
let removingArticle = this.removeArticle
|
||||||
this.removeArticle = null
|
this.removeArticle = null
|
||||||
this.loading = true
|
this.loading = true
|
||||||
removeArticle(removingArticle, removingArticle.id)
|
Article.removeArticle(removingArticle, removingArticle.id)
|
||||||
.then(this.oninit.bind(this, vnode))
|
.then(this.oninit.bind(this, vnode))
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
vnode.state.error = err.message
|
vnode.state.error = err.message
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
const FileUpload = require('../widgets/fileupload')
|
const FileUpload = require('../widgets/fileupload')
|
||||||
const Froala = require('./froala')
|
const Froala = require('./froala')
|
||||||
const { Tree } = require('../api/page')
|
const Page = require('../api/page')
|
||||||
const { uploadFile } = require('../api/file')
|
const File = require('../api/file')
|
||||||
const Fileinfo = require('../widgets/fileinfo')
|
const Fileinfo = require('../widgets/fileinfo')
|
||||||
const { createArticle, updateArticle, getArticle } = require('../api/article')
|
const Article = require('../api/article')
|
||||||
|
|
||||||
const EditArticle = {
|
const EditArticle = {
|
||||||
getFroalaOptions: function() {
|
getFroalaOptions: function() {
|
||||||
|
@ -67,7 +67,7 @@ const EditArticle = {
|
||||||
this.loadedFroala = Froala.loadedFroala
|
this.loadedFroala = Froala.loadedFroala
|
||||||
|
|
||||||
if (this.lastid !== 'add') {
|
if (this.lastid !== 'add') {
|
||||||
getArticle(this.lastid)
|
Article.getArticle(this.lastid)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.editedPath = true
|
vnode.state.editedPath = true
|
||||||
vnode.state.article = result
|
vnode.state.article = result
|
||||||
|
@ -127,7 +127,7 @@ const EditArticle = {
|
||||||
let promise
|
let promise
|
||||||
|
|
||||||
if (this.article.id) {
|
if (this.article.id) {
|
||||||
promise = updateArticle(this.article.id, {
|
promise = Article.updateArticle(this.article.id, {
|
||||||
name: this.article.name,
|
name: this.article.name,
|
||||||
path: this.article.path,
|
path: this.article.path,
|
||||||
parent_id: this.article.parent_id,
|
parent_id: this.article.parent_id,
|
||||||
|
@ -136,7 +136,7 @@ const EditArticle = {
|
||||||
media_id: this.article.media && this.article.media.id,
|
media_id: this.article.media && this.article.media.id,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
promise = createArticle({
|
promise = Article.createArticle({
|
||||||
name: this.article.name,
|
name: this.article.name,
|
||||||
path: this.article.path,
|
path: this.article.path,
|
||||||
parent_id: this.article.parent_id,
|
parent_id: this.article.parent_id,
|
||||||
|
@ -165,12 +165,12 @@ const EditArticle = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadFile(vnode, event) {
|
uploadFile: function(vnode, event) {
|
||||||
if (!event.target.files[0]) return
|
if (!event.target.files[0]) return
|
||||||
vnode.state.error = ''
|
vnode.state.error = ''
|
||||||
vnode.state.loadingFile = true
|
vnode.state.loadingFile = true
|
||||||
|
|
||||||
uploadFile(this.article.id, event.target.files[0])
|
File.uploadFile(this.article.id, event.target.files[0])
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
vnode.state.article.files.push(res)
|
vnode.state.article.files.push(res)
|
||||||
})
|
})
|
||||||
|
@ -186,7 +186,7 @@ const EditArticle = {
|
||||||
|
|
||||||
getFlatTree: function() {
|
getFlatTree: function() {
|
||||||
let out = [{id: null, name: '-- Frontpage --'}]
|
let out = [{id: null, name: '-- Frontpage --'}]
|
||||||
Tree.forEach(function(page) {
|
Page.Tree.forEach(function(page) {
|
||||||
out.push({ id: page.id, name: page.name })
|
out.push({ id: page.id, name: page.name })
|
||||||
if (page.children.length) {
|
if (page.children.length) {
|
||||||
page.children.forEach(function(sub) {
|
page.children.forEach(function(sub) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
const FileUpload = require('../widgets/fileupload')
|
const FileUpload = require('../widgets/fileupload')
|
||||||
const Froala = require('./froala')
|
const Froala = require('./froala')
|
||||||
const { createPage, updatePage, getPage, Tree } = require('../api/page')
|
const Page = require('../api/page')
|
||||||
|
|
||||||
const EditPage = {
|
const EditPage = {
|
||||||
getFroalaOptions: function() {
|
getFroalaOptions: function() {
|
||||||
|
@ -39,7 +39,7 @@ const EditPage = {
|
||||||
this.loadedFroala = Froala.loadedFroala
|
this.loadedFroala = Froala.loadedFroala
|
||||||
|
|
||||||
if (m.route.param('key') !== 'add') {
|
if (m.route.param('key') !== 'add') {
|
||||||
getPage(m.route.param('key'))
|
Page.getPage(m.route.param('key'))
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.editedPath = true
|
vnode.state.editedPath = true
|
||||||
vnode.state.page = result
|
vnode.state.page = result
|
||||||
|
@ -105,7 +105,7 @@ const EditPage = {
|
||||||
let promise
|
let promise
|
||||||
|
|
||||||
if (this.page.id) {
|
if (this.page.id) {
|
||||||
promise = updatePage(this.page.id, {
|
promise = Page.updatePage(this.page.id, {
|
||||||
name: this.page.name,
|
name: this.page.name,
|
||||||
path: this.page.path,
|
path: this.page.path,
|
||||||
parent_id: this.page.parent_id,
|
parent_id: this.page.parent_id,
|
||||||
|
@ -114,7 +114,7 @@ const EditPage = {
|
||||||
media_id: this.page.media && this.page.media.id || null,
|
media_id: this.page.media && this.page.media.id || null,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
promise = createPage({
|
promise = Page.createPage({
|
||||||
name: this.page.name,
|
name: this.page.name,
|
||||||
path: this.page.path,
|
path: this.page.path,
|
||||||
parent_id: this.page.parent_id,
|
parent_id: this.page.parent_id,
|
||||||
|
@ -145,7 +145,7 @@ const EditPage = {
|
||||||
},
|
},
|
||||||
|
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
const parents = [{id: null, name: '-- Frontpage --'}].concat(Tree).filter(function (page) { return !vnode.state.page || page.id !== vnode.state.page.id})
|
const parents = [{id: null, name: '-- Frontpage --'}].concat(Page.Tree).filter(function (page) { return !vnode.state.page || page.id !== vnode.state.page.id})
|
||||||
return (
|
return (
|
||||||
this.loading ?
|
this.loading ?
|
||||||
m('div.loading-spinner')
|
m('div.loading-spinner')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { createStaff, updateStaff, getStaff } = require('../api/staff')
|
const Staff = require('../api/staff')
|
||||||
|
|
||||||
const EditStaff = {
|
const EditStaff = {
|
||||||
oninit: function(vnode) {
|
oninit: function(vnode) {
|
||||||
|
@ -24,7 +24,7 @@ const EditStaff = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lastid !== 'add') {
|
if (this.lastid !== 'add') {
|
||||||
getStaff(this.lastid)
|
Staff.getStaff(this.lastid)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.editedPath = true
|
vnode.state.editedPath = true
|
||||||
vnode.state.staff = result
|
vnode.state.staff = result
|
||||||
|
@ -61,14 +61,14 @@ const EditStaff = {
|
||||||
let promise
|
let promise
|
||||||
|
|
||||||
if (this.staff.id) {
|
if (this.staff.id) {
|
||||||
promise = updateStaff(this.staff.id, {
|
promise = Staff.updateStaff(this.staff.id, {
|
||||||
fullname: this.staff.fullname,
|
fullname: this.staff.fullname,
|
||||||
email: this.staff.email,
|
email: this.staff.email,
|
||||||
level: this.staff.level,
|
level: this.staff.level,
|
||||||
password: this.staff.password,
|
password: this.staff.password,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
promise = createStaff({
|
promise = Staff.createStaff({
|
||||||
fullname: this.staff.fullname,
|
fullname: this.staff.fullname,
|
||||||
email: this.staff.email,
|
email: this.staff.email,
|
||||||
level: this.staff.level,
|
level: this.staff.level,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { getAllPages, removePage } = require('../api/page')
|
const Page = require('../api/page')
|
||||||
const Dialogue = require('../widgets/dialogue')
|
const Dialogue = require('../widgets/dialogue')
|
||||||
|
|
||||||
const AdminPages = {
|
const AdminPages = {
|
||||||
|
@ -24,7 +24,7 @@ const AdminPages = {
|
||||||
this.pages = []
|
this.pages = []
|
||||||
this.removePage = null
|
this.removePage = null
|
||||||
|
|
||||||
getAllPages()
|
Page.getAllPages()
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.pages = AdminPages.parseTree(result)
|
vnode.state.pages = AdminPages.parseTree(result)
|
||||||
})
|
})
|
||||||
|
@ -41,7 +41,7 @@ const AdminPages = {
|
||||||
let removingPage = this.removePage
|
let removingPage = this.removePage
|
||||||
this.removePage = null
|
this.removePage = null
|
||||||
this.loading = true
|
this.loading = true
|
||||||
removePage(removingPage, removingPage.id)
|
Page.removePage(removingPage, removingPage.id)
|
||||||
.then(this.oninit.bind(this, vnode))
|
.then(this.oninit.bind(this, vnode))
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
vnode.state.error = err.message
|
vnode.state.error = err.message
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { getAllStaff, removeStaff } = require('../api/staff')
|
const Staff = require('../api/staff')
|
||||||
const Dialogue = require('../widgets/dialogue')
|
const Dialogue = require('../widgets/dialogue')
|
||||||
const Pages = require('../widgets/pages')
|
const Pages = require('../widgets/pages')
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ const AdminStaffList = {
|
||||||
fetchStaffs: function(vnode) {
|
fetchStaffs: function(vnode) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
return getAllStaff()
|
return Staff.getAllStaff()
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.staff = result
|
vnode.state.staff = result
|
||||||
})
|
})
|
||||||
|
@ -32,7 +32,7 @@ const AdminStaffList = {
|
||||||
let removingStaff = this.removeStaff
|
let removingStaff = this.removeStaff
|
||||||
this.removeStaff = null
|
this.removeStaff = null
|
||||||
this.loading = true
|
this.loading = true
|
||||||
removeStaff(removingStaff.id)
|
Staff.removeStaff(removingStaff.id)
|
||||||
.then(this.oninit.bind(this, vnode))
|
.then(this.oninit.bind(this, vnode))
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
vnode.state.error = err.message
|
vnode.state.error = err.message
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { sendRequest } = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
exports.createArticle = function(body) {
|
exports.createArticle = function(body) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/articles',
|
url: '/api/articles',
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -9,7 +9,7 @@ exports.createArticle = function(body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.updateArticle = function(id, body) {
|
exports.updateArticle = function(id, body) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: '/api/articles/' + id,
|
url: '/api/articles/' + id,
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -17,7 +17,7 @@ exports.updateArticle = function(id, body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getAllArticles = function() {
|
exports.getAllArticles = function() {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/articles?includes=parent',
|
url: '/api/articles?includes=parent',
|
||||||
})
|
})
|
||||||
|
@ -43,7 +43,7 @@ exports.getAllArticlesPagination = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getAllPageArticles = function(pageId, includes) {
|
exports.getAllPageArticles = function(pageId, includes) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/pages/' + pageId + '/articles?includes=' + includes.join(','),
|
url: '/api/pages/' + pageId + '/articles?includes=' + includes.join(','),
|
||||||
})
|
})
|
||||||
|
@ -69,14 +69,14 @@ exports.getAllPageArticlesPagination = function(pageId, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getArticle = function(id) {
|
exports.getArticle = function(id) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/articles/' + id + '?includes=media,parent,banner,files',
|
url: '/api/articles/' + id + '?includes=media,parent,banner,files',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.removeArticle = function(article, id) {
|
exports.removeArticle = function(article, id) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: '/api/articles/' + id,
|
url: '/api/articles/' + id,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const { sendRequest } = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
exports.uploadFile = function(articleId, file) {
|
exports.uploadFile = function(articleId, file) {
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
|
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/articles/' + articleId + '/file',
|
url: '/api/articles/' + articleId + '/file',
|
||||||
body: formData,
|
body: formData,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const { sendRequest } = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
exports.uploadMedia = function(file) {
|
exports.uploadMedia = function(file) {
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
|
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/media',
|
url: '/api/media',
|
||||||
body: formData,
|
body: formData,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const { sendRequest } = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
const Tree = window.__nfptree || []
|
const Tree = window.__nfptree || []
|
||||||
|
|
||||||
exports.Tree = Tree
|
exports.Tree = Tree
|
||||||
|
|
||||||
exports.createPage = function(body) {
|
exports.createPage = function(body) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/pages',
|
url: '/api/pages',
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -26,14 +26,14 @@ exports.createPage = function(body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getTree = function() {
|
exports.getTree = function() {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/pages?tree=true&includes=children&fields=id,name,path,children(id,name,path)',
|
url: '/api/pages?tree=true&includes=children&fields=id,name,path,children(id,name,path)',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.updatePage = function(id, body) {
|
exports.updatePage = function(id, body) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: '/api/pages/' + id,
|
url: '/api/pages/' + id,
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -62,21 +62,21 @@ exports.updatePage = function(id, body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getAllPages = function() {
|
exports.getAllPages = function() {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/pages',
|
url: '/api/pages',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getPage = function(id) {
|
exports.getPage = function(id) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/pages/' + id + '?includes=media,banner,children,news,news.media',
|
url: '/api/pages/' + id + '?includes=media,banner,children,news,news.media',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.removePage = function(page, id) {
|
exports.removePage = function(page, id) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: '/api/pages/' + id,
|
url: '/api/pages/' + id,
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const parse = require('parse-link-header')
|
const parse = require('parse-link-header')
|
||||||
const { sendRequest } = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
exports.fetchPage = function(url) {
|
exports.fetchPage = function(url) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: url,
|
url: url,
|
||||||
}, true)
|
}, true)
|
||||||
.then(result => {
|
.then(function(result) {
|
||||||
return {
|
return {
|
||||||
data: result.data,
|
data: result.data,
|
||||||
links: parse(result.headers.link || ''),
|
links: parse(result.headers.link || ''),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { sendRequest } = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
exports.createStaff = function(body) {
|
exports.createStaff = function(body) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/staff',
|
url: '/api/staff',
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -9,7 +9,7 @@ exports.createStaff = function(body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.updateStaff = function(id, body) {
|
exports.updateStaff = function(id, body) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: '/api/staff/' + id,
|
url: '/api/staff/' + id,
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -17,21 +17,21 @@ exports.updateStaff = function(id, body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getAllStaff = function() {
|
exports.getAllStaff = function() {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/staff',
|
url: '/api/staff',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getStaff = function(id) {
|
exports.getStaff = function(id) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/staff/' + id,
|
url: '/api/staff/' + id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.removeStaff = function(id) {
|
exports.removeStaff = function(id) {
|
||||||
return sendRequest({
|
return common.sendRequest({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: '/api/staff/' + id,
|
url: '/api/staff/' + id,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const m = require('mithril')
|
const m = require('mithril')
|
||||||
const { getArticle } = require('../api/article')
|
const ApiArticle = require('../api/article')
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
const Fileinfo = require('../widgets/fileinfo')
|
const Fileinfo = require('../widgets/fileinfo')
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ const Article = {
|
||||||
}
|
}
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
getArticle(this.path)
|
ApiArticle.getArticle(this.path)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.article = result
|
vnode.state.article = result
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const m = require('mithril')
|
const m = require('mithril')
|
||||||
const { Tree } = require('../api/page')
|
const Page = require('../api/page')
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
|
|
||||||
const Footer = {
|
const Footer = {
|
||||||
|
@ -12,7 +12,7 @@ const Footer = {
|
||||||
m('div.sitemap', [
|
m('div.sitemap', [
|
||||||
m('div', 'Sitemap'),
|
m('div', 'Sitemap'),
|
||||||
m(m.route.Link, { class: 'root', href: '/' }, 'Home'),
|
m(m.route.Link, { class: 'root', href: '/' }, 'Home'),
|
||||||
Tree.map(function(page) {
|
Page.Tree.map(function(page) {
|
||||||
return [
|
return [
|
||||||
m(m.route.Link, { class: 'root', href: '/page/' + page.path }, page.name),
|
m(m.route.Link, { class: 'root', href: '/page/' + page.path }, page.name),
|
||||||
(page.children.length
|
(page.children.length
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const m = require('mithril')
|
const m = require('mithril')
|
||||||
|
|
||||||
const { Tree } = require('../api/page')
|
const Page = require('../api/page')
|
||||||
const { getAllArticlesPagination } = require('../api/article')
|
const Article = require('../api/article')
|
||||||
const { fetchPage } = require('../api/pagination')
|
const Pagination = require('../api/pagination')
|
||||||
const Pages = require('../widgets/pages')
|
const Pages = require('../widgets/pages')
|
||||||
const Newsitem = require('../widgets/newsitem')
|
const Newsitem = require('../widgets/newsitem')
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ const Frontpage = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchArticles(vnode) {
|
fetchArticles: function(vnode) {
|
||||||
this.error = ''
|
this.error = ''
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.links = null
|
this.links = null
|
||||||
this.articles = []
|
this.articles = []
|
||||||
this.lastpage = m.route.param('page') || '1'
|
this.lastpage = m.route.param('page') || '1'
|
||||||
|
|
||||||
return fetchPage(getAllArticlesPagination({
|
return Pagination.fetchPage(Article.getAllArticlesPagination({
|
||||||
per_page: 10,
|
per_page: 10,
|
||||||
page: this.lastpage,
|
page: this.lastpage,
|
||||||
includes: ['parent', 'files', 'media', 'banner'],
|
includes: ['parent', 'files', 'media', 'banner'],
|
||||||
|
@ -96,7 +96,7 @@ const Frontpage = {
|
||||||
m('aside.sidebar', [
|
m('aside.sidebar', [
|
||||||
m('div.categories', [
|
m('div.categories', [
|
||||||
m('h4', 'Categories'),
|
m('h4', 'Categories'),
|
||||||
Tree.map(function(page) {
|
Page.Tree.map(function(page) {
|
||||||
return [
|
return [
|
||||||
m(m.route.Link, { class: 'root', href: '/page/' + page.path }, page.name),
|
m(m.route.Link, { class: 'root', href: '/page/' + page.path }, page.name),
|
||||||
(page.children.length
|
(page.children.length
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const m = require('mithril')
|
const m = require('mithril')
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
const { sendRequest } = require('../api/common')
|
const Api = require('../api/common')
|
||||||
|
|
||||||
const Login = {
|
const Login = {
|
||||||
loadedGoogle: false,
|
loadedGoogle: false,
|
||||||
|
@ -81,7 +81,7 @@ const Login = {
|
||||||
|
|
||||||
Login.loading = true
|
Login.loading = true
|
||||||
|
|
||||||
sendRequest({
|
Api.sendRequest({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/login/user',
|
url: '/api/login/user',
|
||||||
body: {
|
body: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const m = require('mithril')
|
const m = require('mithril')
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
const Darkmode = require('../darkmode')
|
const Darkmode = require('../darkmode')
|
||||||
const { Tree, getTree } = require('../api/page')
|
const Page = require('../api/page')
|
||||||
|
|
||||||
const Menu = {
|
const Menu = {
|
||||||
currentActive: 'home',
|
currentActive: 'home',
|
||||||
|
@ -18,14 +18,14 @@ const Menu = {
|
||||||
oninit: function(vnode) {
|
oninit: function(vnode) {
|
||||||
Menu.onbeforeupdate()
|
Menu.onbeforeupdate()
|
||||||
|
|
||||||
if (Tree.length) return
|
if (Page.Tree.length) return
|
||||||
|
|
||||||
Menu.loading = true
|
Menu.loading = true
|
||||||
|
|
||||||
getTree()
|
Page.getTree()
|
||||||
.then(function(results) {
|
.then(function(results) {
|
||||||
Tree.splice(0, Tree.length)
|
Page.Tree.splice(0, Page.Tree.length)
|
||||||
Tree.push.apply(Tree, results)
|
Page.Tree.push.apply(Page.Tree, results)
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
Menu.error = err.message
|
Menu.error = err.message
|
||||||
|
@ -72,7 +72,7 @@ const Menu = {
|
||||||
href: '/',
|
href: '/',
|
||||||
class: Menu.currentActive === 'home' ? 'active' : '',
|
class: Menu.currentActive === 'home' ? 'active' : '',
|
||||||
}, 'Home'),
|
}, 'Home'),
|
||||||
Menu.loading ? m('div.loading-spinner') : Tree.map(function(page) {
|
Menu.loading ? m('div.loading-spinner') : Page.Tree.map(function(page) {
|
||||||
if (page.children.length) {
|
if (page.children.length) {
|
||||||
return m('div.hassubmenu', [
|
return m('div.hassubmenu', [
|
||||||
m(m.route.Link, {
|
m(m.route.Link, {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const m = require('mithril')
|
const m = require('mithril')
|
||||||
const { getPage } = require('../api/page')
|
const ApiPage = require('../api/page')
|
||||||
const { getAllPageArticlesPagination } = require('../api/article')
|
const Article = require('../api/article')
|
||||||
const { fetchPage } = require('../api/pagination')
|
const pagination = require('../api/pagination')
|
||||||
const Authentication = require('../authentication')
|
const Authentication = require('../authentication')
|
||||||
const Newsentry = require('../widgets/newsentry')
|
const Newsentry = require('../widgets/newsentry')
|
||||||
const Pages = require('../widgets/pages')
|
const Pages = require('../widgets/pages')
|
||||||
|
@ -27,7 +27,7 @@ const Page = {
|
||||||
}
|
}
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
getPage(this.path)
|
ApiPage.getPage(this.path)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.page = result
|
vnode.state.page = result
|
||||||
})
|
})
|
||||||
|
@ -52,7 +52,7 @@ const Page = {
|
||||||
this.newslinks = null
|
this.newslinks = null
|
||||||
this.lastpage = m.route.param('page') || '1'
|
this.lastpage = m.route.param('page') || '1'
|
||||||
|
|
||||||
return fetchPage(getAllPageArticlesPagination(this.page.id, {
|
return pagination.fetchPage(Article.getAllPageArticlesPagination(this.page.id, {
|
||||||
per_page: 10,
|
per_page: 10,
|
||||||
page: this.lastpage,
|
page: this.lastpage,
|
||||||
includes: ['files', 'media'],
|
includes: ['files', 'media'],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const Fileinfo = {
|
const Fileinfo = {
|
||||||
getPrefix(vnode) {
|
getPrefix: function(vnode) {
|
||||||
if (!vnode.attrs.file.filename.endsWith('.torrent')) {
|
if (!vnode.attrs.file.filename.endsWith('.torrent')) {
|
||||||
return vnode.attrs.file.filename.split('.').slice(-1)
|
return vnode.attrs.file.filename.split('.').slice(-1)
|
||||||
}
|
}
|
||||||
|
@ -15,21 +15,21 @@ const Fileinfo = {
|
||||||
return 'Other'
|
return 'Other'
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle(vnode) {
|
getTitle: function(vnode) {
|
||||||
if (vnode.attrs.file.meta.torrent) {
|
if (vnode.attrs.file.meta.torrent) {
|
||||||
return vnode.attrs.file.meta.torrent.name
|
return vnode.attrs.file.meta.torrent.name
|
||||||
}
|
}
|
||||||
return vnode.attrs.file.filename
|
return vnode.attrs.file.filename
|
||||||
},
|
},
|
||||||
|
|
||||||
getDownloadName(vnode) {
|
getDownloadName: function(vnode) {
|
||||||
if (vnode.attrs.file.meta.torrent) {
|
if (vnode.attrs.file.meta.torrent) {
|
||||||
return 'Torrent'
|
return 'Torrent'
|
||||||
}
|
}
|
||||||
return 'Download'
|
return 'Download'
|
||||||
},
|
},
|
||||||
|
|
||||||
getSize(orgSize) {
|
getSize: function(orgSize) {
|
||||||
var size = orgSize
|
var size = orgSize
|
||||||
var i = -1
|
var i = -1
|
||||||
var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB']
|
var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB']
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const { uploadMedia } = require('../api/media')
|
const Media = require('../api/media')
|
||||||
|
|
||||||
const FileUpload = {
|
const FileUpload = {
|
||||||
uploadFile(vnode, event) {
|
uploadFile: function(vnode, event) {
|
||||||
if (!event.target.files[0]) return
|
if (!event.target.files[0]) return
|
||||||
vnode.state.updateError(vnode, '')
|
vnode.state.updateError(vnode, '')
|
||||||
vnode.state.loading = true
|
vnode.state.loading = true
|
||||||
|
|
||||||
uploadMedia(event.target.files[0])
|
Media.uploadMedia(event.target.files[0])
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
if (vnode.attrs.onupload) {
|
if (vnode.attrs.onupload) {
|
||||||
vnode.attrs.onupload(res)
|
vnode.attrs.onupload(res)
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
{
|
|
||||||
"NODE_ENV": "development",
|
|
||||||
"server": {
|
|
||||||
"port": 4030,
|
|
||||||
"host": "0.0.0.0"
|
|
||||||
},
|
|
||||||
"CIRCLECI_VERSION": "circleci_version_number",
|
|
||||||
"knex": {
|
|
||||||
"client": "pg",
|
|
||||||
"connection": {
|
|
||||||
"host" : "127.0.0.1",
|
|
||||||
"user" : "postgres",
|
|
||||||
"password" : "postgres",
|
|
||||||
"database" : "nfpmoe"
|
|
||||||
},
|
|
||||||
"connectionslave": null,
|
|
||||||
"migrations": {
|
|
||||||
},
|
|
||||||
"acquireConnectionTimeout": 10000
|
|
||||||
},
|
|
||||||
"bunyan": {
|
|
||||||
"name": "nfpmoe",
|
|
||||||
"streams": [{
|
|
||||||
"stream": "process.stdout",
|
|
||||||
"level": "debug"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"frontend": {
|
|
||||||
"url": "http://localhost:8080"
|
|
||||||
},
|
|
||||||
"jwt": {
|
|
||||||
"secret": "this-is-my-secret",
|
|
||||||
"options": {
|
|
||||||
"expiresIn": 604800
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"googleid": "1076074914074-3no1difo1jq3dfug3glfb25pn1t8idud.apps.googleusercontent.com",
|
|
||||||
"sessionsecret": "this-is-session-secret-lol",
|
|
||||||
"bcrypt": 5,
|
|
||||||
"fileSize": 524288000,
|
|
||||||
"upload": {
|
|
||||||
"baseurl": "http://192.168.42.14",
|
|
||||||
"port": "2111",
|
|
||||||
"host": "storage01.nfp.is",
|
|
||||||
"name": "nfpmoe-dev",
|
|
||||||
"secret": "nfpmoe-dev"
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue