Add raw JSON view

This commit is contained in:
Christian Bundy 2019-06-25 10:18:45 -07:00
parent 8dcdc58043
commit 84d5d1810c
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
4 changed files with 16 additions and 2 deletions

View File

@ -12,6 +12,7 @@ const author = require('./routes/author')
const hashtag = require('./routes/hashtag')
const home = require('./routes/home')
const profile = require('./routes/profile')
const raw = require('./routes/raw')
const thread = require('./routes/thread')
const assets = new Koa()
@ -37,6 +38,7 @@ router
.get('/hashtag/:id', hashtag)
.get('/profile/', profile)
.get('/thread/:id', thread)
.get('/raw/:id', raw)
app.use(router.routes())

View File

@ -25,7 +25,7 @@ h1, h2, h3, h4, h5, h6 {
margin: 0.5em 0;
}
.message pre {
pre {
overflow-x: auto;
}
@ -118,7 +118,6 @@ nav a {
border-radius: 2px;
}
ul {
padding-left: 1rem;
}

12
routes/raw.js Normal file
View File

@ -0,0 +1,12 @@
const cooler = require('../lib/cooler')
module.exports = async function thread (ctx) {
const ssb = await cooler.connect()
const rawMsg = await cooler.get(ssb.get, {
id: ctx.params.id,
meta: true,
private: true
})
ctx.body = rawMsg
}

View File

@ -38,5 +38,6 @@
<% } %>
<% } %>
<a href="/raw/<%= encodeURIComponent(msg.value.content.root) %>">raw</a>
</footer>
</section>