Add readme accessible from web app
This commit is contained in:
parent
d9623fbe04
commit
5140301cd7
10
index.js
10
index.js
|
@ -3,6 +3,8 @@
|
|||
'use strict'
|
||||
|
||||
const yargs = require('yargs')
|
||||
const fs = require('fs').promises
|
||||
const path = require('path')
|
||||
|
||||
const config = yargs
|
||||
.env('OASIS')
|
||||
|
@ -39,6 +41,12 @@ process.argv = []
|
|||
if (config.debug) {
|
||||
process.env.DEBUG = '*'
|
||||
}
|
||||
|
||||
const app = require('./src/app')
|
||||
|
||||
app(config)
|
||||
const start = async () => {
|
||||
config.readme = await fs.readFile(path.join(__dirname, 'README.md'), 'utf8')
|
||||
app(config)
|
||||
}
|
||||
|
||||
start()
|
||||
|
|
|
@ -26,6 +26,7 @@ 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')
|
||||
|
||||
module.exports = (config) => {
|
||||
const assets = new Koa()
|
||||
|
@ -97,6 +98,9 @@ module.exports = (config) => {
|
|||
.get('/status/', async (ctx) => {
|
||||
ctx.body = await status()
|
||||
})
|
||||
.get('/readme/', async (ctx) => {
|
||||
ctx.body = await markdown(config.readme)
|
||||
})
|
||||
.get('/mentions/', async (ctx) => {
|
||||
ctx.body = await mentions()
|
||||
})
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const markdownView = require('./views/markdown')
|
||||
|
||||
module.exports = async function statusPage (text) {
|
||||
return markdownView({ text })
|
||||
}
|
|
@ -36,8 +36,7 @@ module.exports = (...elements) => {
|
|||
li(a({ href: '/compose' }, 'compose')),
|
||||
li(a({ href: '/profile' }, 'profile')),
|
||||
li(a({ href: '/status' }, 'status')),
|
||||
li(a({ href: 'https://github.com/fraction/oasis' }, 'source')),
|
||||
li(a({ href: 'https://github.com/fraction/oasis/issues/new/choose' }, 'help'))
|
||||
li(a({ href: '/readme' }, 'readme'))
|
||||
)
|
||||
),
|
||||
main({ id: 'content' }, ...elements)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
'use strict'
|
||||
|
||||
const { section } = require('hyperaxe')
|
||||
const ssbMarkdown = require('ssb-markdown')
|
||||
const template = require('./components/template')
|
||||
|
||||
module.exports = ({ text }) => {
|
||||
const rawHtml = ssbMarkdown.block(text)
|
||||
|
||||
return template(
|
||||
section({ class: 'message' }, { innerHTML: rawHtml })
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue