Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staltz/feedpunk
A scuttlebutt client in the terminal
https://github.com/staltz/feedpunk
Last synced: 3 months ago
JSON representation
A scuttlebutt client in the terminal
- Host: GitHub
- URL: https://github.com/staltz/feedpunk
- Owner: staltz
- License: gpl-3.0
- Created: 2018-02-27T14:28:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-07T17:22:33.000Z (over 5 years ago)
- Last Synced: 2024-02-20T12:47:55.228Z (5 months ago)
- Language: JavaScript
- Size: 1.04 MB
- Stars: 57
- Watchers: 7
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: readMessage.js
- License: LICENSE
Lists
- awesome-community-networks - feed punk
README
var blessed = require('blessed')
var pull = require('pull-stream')
const { renderTime } = require('./utils')module.exports = function readMessage(screen, ssb, msgKey) {
var readMessageBox = blessed.box({
top: 'center',
left: 'center',
width: '90%',
height: '70%',
label: ' {bold}{green-fg}Message{/green-fg}{/bold} ',
tags: true,
border: {
type: 'line',
},
})function setAuthorName(msgValue, about) {
if (err) return
const authorKey = msgValue.author
if (!about[authorKey]) return
const nameDefs = about[authorKey].name
if (!nameDefs) return
const ownName = nameDefs[authorKey]
if (!ownName) return
msgValue.authorName = ownName[0]
}function renderMsg(msgValue) {
readMessageBox.setContent(
`Author: ${msgValue.authorName || msgValue.author}\n` +
`When: ${renderTime(msgValue)}\n\n` +
JSON.stringify(msgValue.content, null, 2)
)
screen.render()
}function renderPostMsg(msgValue) {
readMessageBox.style = { border: { fg: 'yellow' } }
readMessageBox.setLabel(' {bold}{yellow-fg}Message{/yellow-fg}{/bold} ')
const msgContent = msgValue.content
readMessageBox.setContent(
`Author: ${msgValue.authorName || msgValue.author}\n` +
`When: ${renderTime(msgValue)}\n` +
`${msgContent.channel ? `Channel: #${msgContent.channel}\n` : ''}` +
`${msgContent.root ? `Root: #${msgContent.root}\n` : ''}` +
`\n${msgContent.text}`
)
screen.render()
}ssb.get(msgKey, (err, msgValue) => {
if (msgValue.content.type === 'post') renderPostMsg(msgValue)
else renderMsg(msgValue)
})screen.append(readMessageBox)
screen.readingMessage = readMessageBox
readMessageBox.focus()
screen.render()
}