ssbc/scuttle-blog

Name: scuttle-blog

Owner: Secure Scuttlebutt Consortium

Description: null

Created: 2018-02-07 06:46:58.0

Updated: 2018-03-13 10:00:38.0

Pushed: 2018-02-16 22:57:21.0

Homepage: null

Size: 59

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Scuttle-blog

A helper module which covers all your ssb blog related needs from blog data.

The parts of this modules are :

Usage
t isBlog = require('scuttle-blog/isBlog')
og(msg)
> true
s
t { h } = require(mutant)
t ScuttleBook = require('scuttle-blog')

t sBook = ScuttleBook(server)  // server is sometimes called sbot

t myBook = sBook.obs.get('%GKGFNHKeUVAVPNUapE41skF3ND3Etm76XO7Y7sVeTLI=.sha256')

ment.body.appendChild(
'Blog', [
h('h1', blog.title),
h('pre', blog.body)


he blog here would be raw markdown, but fixing that is left to the reader!
Constructor API
Blog(server)

server is a connection to your scuttlebutt server provided by ssb-client (sometimes called sbot in other docs).

server can also be an observeable which will resolve into the above at some point. If you pass in an observeable, synchronous methods will return observeables.

Instance API
blog.sync.isBlog(msg) => Boolean

msg - is a message from a server stream (or the message content).

blog.obs.get(blogMsg) => Observeable

blogMsg (Object) - a blog message (or the content of a blogMsg)

The observeable returned is Mutant Struct which holds data structured like:


tle,
annel,
mmary,
umbnail,
dy,       [MutantValue]
rors      [MutantArray]

In this case all values will be observeables, and the blog content (body) will take some time to load if you haven't already got the whole blog. (This method called blog.async.fetch under the hood.)

blog.aync.get(blogMsg, cb)

blogMsg (Object) - a blog message (or the content of a blogMsg)

cb - a callback with signature (err, blogObj) where blogObj is a plain js object with the same form described in blog.obs.get

The observeable returned is Mutant Struct which holds data structured like:


tle,
annel,
mmary,
umbnail,
dy,       [MutantValue]
rors      [MutantArray]

In this case all values will be observeables, and the blog content (body) will take some time to load if you haven't already got the whole blog. (This method called blog.async.fetch under the hood.)

blog.async.fetch(msg, cb)

Blogs store the body of their text as an attachement. In Scuttlebutt, attachments have to be manually requested, hence this method.

key (Object) - a blog msg

cb (function) - a callback with the standard signature (err, success) where success is a Boolean

Schemas

Blog message content:


pe:       'blog',
tle:       String,
og:        Blob,
mmary:     String,  (optional)
umbnail:   Blob,    (optional)
annel:     String,  (optional)

Development

Run the tests with npm test

Things could implement in future:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.