Merge branch 'add-about' into develop

This commit is contained in:
Christian Bundy 2019-10-07 20:19:45 -07:00
commit f48cc18436
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
6 changed files with 87 additions and 7 deletions

View File

@ -371,3 +371,18 @@ summary {
background: none;
font-size: 50%;
}
table {
width: 100%;
}
td,
th {
padding: 0.5rem;
outline: var(--thin-stroke) solid var(--bg-status);
}
th {
text-align: left;
background-color: var(--bg-status);
}

View File

@ -8,6 +8,7 @@ module.exports = async function authorPage (feedId) {
const description = await about.description(feedId)
const name = await about.name(feedId)
const image = await about.image(feedId)
const aboutPairs = await about.all(feedId)
const messages = await post.fromFeed(feedId)
const avatarUrl = `/image/128/${encodeURIComponent(image)}`
@ -17,6 +18,7 @@ module.exports = async function authorPage (feedId) {
messages,
name,
description,
avatarUrl
avatarUrl,
aboutPairs
})
}

View File

@ -2,6 +2,7 @@
const cooler = require('./lib/cooler')
const markdown = require('./lib/markdown')
const pull = require('pull-stream')
const nullImage = `&${'0'.repeat(43)}=.sha256`
@ -40,5 +41,37 @@ module.exports = {
}
)
return markdown(raw)
},
all: async (feedId) => {
const ssb = await cooler.connect()
const raw = await cooler.read(
ssb.about.read, {
dest: feedId
}
)
return new Promise((resolve, reject) =>
pull(
raw,
pull.filter((message) => message.value.author === feedId),
pull.reduce((acc, cur) => {
const metaKeys = ['type', 'about']
Object.entries(cur.value.content).filter(([key]) =>
metaKeys.includes(key) === false
).forEach(([key, value]) => {
acc[key] = value
})
return acc
}, {}, (err, val) => {
if (err) {
reject(err)
} else {
resolve(val)
}
})
)
)
}
}

View File

@ -10,7 +10,10 @@ const server = flotilla({ ws: { http: false } })
const rawConnect = () => new Promise((resolve, reject) => {
ssbClient({
manifest: {
about: { socialValue: 'async' },
about: {
socialValue: 'async',
read: 'source'
},
backlinks: { read: 'source' },
blobs: {
get: 'source',

View File

@ -12,6 +12,7 @@ module.exports = async function profilePage () {
const description = await about.description(feedId)
const name = await about.name(feedId)
const image = await about.image(feedId)
const aboutPairs = await about.all(feedId)
const messages = await post.fromFeed(feedId)
@ -22,6 +23,7 @@ module.exports = async function profilePage () {
messages,
name,
description,
avatarUrl
avatarUrl,
aboutPairs
})
}

View File

@ -3,22 +3,45 @@
const highlightJs = require('highlight.js')
const {
article,
h1,
header,
img,
h1,
pre,
section,
pre
table,
tbody,
td,
th,
tr
} = require('hyperaxe')
const post = require('./components/post')
const template = require('./components/template')
module.exports = ({
avatarUrl, name, description, messages, feedId
aboutPairs,
avatarUrl,
description,
feedId,
messages,
name
}) => {
const mention = `[@${name}](${feedId})`
const markdownMention = highlightJs.highlight('markdown', mention).value
const alreadyHandled = [
'description',
'image',
'name'
]
const metaRows = Object.entries(aboutPairs)
.filter(([key]) => alreadyHandled.includes(key) === false)
.map(([key, value]) => tr(td(key), td(value)))
const metaTable = metaRows.length > 0
? table(tbody(tr(th('key'), th('value')), metaRows))
: null
const prefix = section({ class: 'message' },
header({ class: 'profile' },
img({ class: 'avatar', src: avatarUrl }),
@ -29,7 +52,9 @@ module.exports = ({
}),
description !== '<p>null</p>\n'
? article({ innerHTML: description })
: null)
: null,
metaTable
)
return template(
prefix,