Add new compose view for writing root messages
This commit is contained in:
parent
270f62f57a
commit
28f62c8360
10
src/app.js
10
src/app.js
|
@ -23,6 +23,8 @@ const mentions = require('./pages/mentions')
|
|||
const reply = require('./pages/reply')
|
||||
const publishReply = require('./pages/publish-reply')
|
||||
const image = require('./pages/image')
|
||||
const compose = require('./pages/compose')
|
||||
const publish = require('./pages/publish')
|
||||
|
||||
module.exports = (config) => {
|
||||
const assets = new Koa()
|
||||
|
@ -101,12 +103,20 @@ module.exports = (config) => {
|
|||
const { message } = ctx.params
|
||||
ctx.body = await reply(message, false)
|
||||
})
|
||||
.get('/compose/', async (ctx) => {
|
||||
ctx.body = await compose()
|
||||
})
|
||||
.post('/reply/:message', koaBody(), async (ctx) => {
|
||||
const { message } = ctx.params
|
||||
const text = String(ctx.request.body.text)
|
||||
ctx.body = await publishReply({ message, text })
|
||||
ctx.redirect('/')
|
||||
})
|
||||
.post('/publish/', koaBody(), async (ctx) => {
|
||||
const text = String(ctx.request.body.text)
|
||||
ctx.body = await publish({ text })
|
||||
ctx.redirect('/')
|
||||
})
|
||||
.post('/like/:message', koaBody(), async (ctx) => {
|
||||
const { message } = ctx.params
|
||||
// TODO: convert all so `message` is full message and `messageKey` is key
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const composeView = require('./views/compose')
|
||||
|
||||
module.exports = async function composePage () {
|
||||
return composeView()
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
'use strict'
|
||||
|
||||
const ssbMentions = require('ssb-mentions')
|
||||
const post = require('./models/post')
|
||||
|
||||
module.exports = async function publishPage ({ text }) {
|
||||
const mentions = ssbMentions(text) || undefined
|
||||
return post.publish({
|
||||
text,
|
||||
mentions
|
||||
})
|
||||
}
|
|
@ -30,6 +30,7 @@ module.exports = (...elements) => {
|
|||
nav(
|
||||
a({ href: '/' }, 'home'),
|
||||
a({ href: '/mentions' }, 'mentions'),
|
||||
a({ href: '/compose' }, 'compose'),
|
||||
a({ href: '/profile' }, 'profile'),
|
||||
a({ href: '/status' }, 'status'),
|
||||
a({ href: 'https://github.com/fraction/oasis' }, 'source'),
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
'use strict'
|
||||
|
||||
const {
|
||||
button,
|
||||
form,
|
||||
textarea
|
||||
} = require('hyperaxe')
|
||||
|
||||
const template = require('./components/template')
|
||||
|
||||
module.exports = () => {
|
||||
const publishForm = '/publish/'
|
||||
|
||||
return template(
|
||||
form({ action: publishForm, method: 'post' },
|
||||
textarea({ autofocus: true, required: true, name: 'text' }),
|
||||
button({
|
||||
type: 'submit'
|
||||
}, 'publish (public!!!)'))
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue