Change public view to contain compose form

This commit is contained in:
Christian Bundy 2019-09-25 12:48:44 -07:00
parent 6442e1b87c
commit face906558
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
5 changed files with 31 additions and 13 deletions

View File

@ -12,7 +12,7 @@ const ssbRef = require('ssb-ref')
const author = require('./pages/author')
const hashtag = require('./pages/hashtag')
const home = require('./pages/home')
const publicPage = require('./pages/public')
const profile = require('./pages/profile')
const raw = require('./pages/raw')
const thread = require('./pages/thread')
@ -24,7 +24,6 @@ const reply = require('./pages/reply')
const publishReply = require('./pages/publish-reply')
const image = require('./pages/image')
const blob = require('./pages/blob')
const compose = require('./pages/compose')
const publish = require('./pages/publish')
const markdown = require('./pages/markdown')
@ -63,7 +62,7 @@ module.exports = (config) => {
return next()
})
.get('/', async (ctx) => {
ctx.body = await home()
ctx.body = await publicPage()
})
.get('/author/:feed', async (ctx) => {
const { feed } = ctx.params
@ -112,9 +111,6 @@ 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)

View File

@ -241,11 +241,12 @@ progress {
}
textarea {
box-sizing: border-box;
display: block;
width: 100%;
height: 16rem;
font-size: 1rem;
padding: 0.5rem;
padding: 1rem;
resize: vertical;
width: 100%;
}
/* content warning! */

View File

@ -1,9 +1,9 @@
'use strict'
const listView = require('./views/list')
const listView = require('./views/public')
const post = require('./models/post')
module.exports = async function homePage () {
module.exports = async function publicPage () {
const messages = await post.latest()
return listView({ messages })

View File

@ -31,9 +31,8 @@ module.exports = (...elements) => {
body(
nav(
ul(
li(a({ href: '/' }, 'home')),
li(a({ href: '/' }, 'public')),
li(a({ href: '/mentions' }, 'mentions')),
li(a({ href: '/compose' }, 'compose')),
li(a({ href: '/profile' }, 'profile')),
li(a({ href: '/status' }, 'status')),
li(a({ href: '/readme' }, 'readme'))

22
src/pages/views/public.js Normal file
View File

@ -0,0 +1,22 @@
'use strict'
const {
button,
form,
textarea
} = require('hyperaxe')
const template = require('./components/template')
const post = require('./components/post')
module.exports = ({ messages }) => {
const publishForm = '/publish/'
return template(
form({ action: publishForm, method: 'post' },
textarea({ autofocus: true, required: true, name: 'text' }),
button({
type: 'submit'
}, 'publish')),
messages.map((msg) => post({ msg }))
)
}