Skip to content

Instantly share code, notes, and snippets.

View pfrazee's full-sized avatar

Paul Frazee pfrazee

View GitHub Profile
@pfrazee
pfrazee / DatArchive.dream.js
Last active August 27, 2019 19:58 — forked from RangerMauve/DatArchive.dream.js
Dream DatArchive API for extensions / peers
const archive = await DatArchive.load('someurl')
var fooExt = archive.extension('foo')
// listen to 'foo' messages from all peers
fooExt.addEventListener('message', ({detail}) => {
const {message, peer} = detail
// send to one peer:
await peer.extension('bar').send('Hello World')

For the theme, I'm leaning toward using a template file.

  • The "theme dat" has been mounted to the site's /theme directory.
  • User visits /index.html on the site
    • The /theme/template.html file is loaded.
    • The /index.html file is loaded.
  • Output is constructed:
    • The template <!-- TEMPLATE-CONTENT --> string gets replaced with the content of /index.html
    • The resulting string is served.

DNS handling in beaker

Dat site "Primary URL" (pURL)

Within Beaker, all Dat sites have a "Primary URL" (pURL). This is dat://{key} by default. Dat sites can assign multiple DNS short names, but the pURL will only be changed to a DNS shortname if the site's dat.json assigns a "domain" value. This value will be confirmed against the DNS record.

Therefore the "Primary URL" can be visualized as:

var hostname = key

Dat Simple Directories (DSD)

The premise of Dat Simple Directories (DSD) is that organizations such as companies, schools, agencies, and communities can act as the backbone of global identity.

Organizations will typically have the following desirable properties:

  • The resources to deploy websites with DNS and SSL
  • A need to maintain and publish their membership
  • An interest in maintaining their reputation

Beaker/Dat code modules proposal

Like node and other platforms, Beaker will need a way to share modules of code and other assets. The Web's ES Modules give us a lot of the tooling for importing and exporting javascript, but we still need solutions for publishing, versioning, and "installing" dependencies.

This is a proposal to use Dat archives and ES Modules in Beaker to solve code-sharing.

Overview

"Module" dat archives have a folder structure that includes the current development code in /dev and any frozen versions in /v. A trivial example of that folder structure:

Four new proposed schemas for Unwalled.Garden

This week I created PRs for four new unwalled.garden schemas. The are:

Of these, I'm 99% sure that Discussions and Votes should land. I think Actions and Relationships could be fun additions, but I'm open to disagreements about them.

Blue setup / build process

Create a new directory, let's say ~/blue.

mkdir blue
cd blue

Clone the following repos:

@pfrazee
pfrazee / build-site.js
Created May 24, 2019 19:02
Nodejs static site generator (for unwalled.garden)
const path = require('path')
const fs = require('fs').promises
const MarkdownIt = require('./vendor/markdown-it.min')
const hljs = require('highlight.js')
const md = MarkdownIt({
html: true, // Enable HTML tags in source
xhtmlOut: false, // Use '/' to close single tags (<br />)
breaks: true, // Convert '\n' in paragraphs into <br>
langPrefix: 'language-', // CSS language prefix for fenced blocks
User drive's folder structure:
/data/ - json records
/website/ - html/css/js for visiting them as a site
/drives/ - published drives
/dat.json - metadata
/thumb.jpg - avatar
/favicon.ico - icon
/cover.jpg - cover photo in social cards/profile page

🔐 DatPubkeyFile

An API for libsodium pubkey crypto operations in the Beaker/Dat ecosystem. Includes mechanisms to:

  • Sign
  • Verify signatures
  • Encrypt blobs
  • Decrypt blobs
  • Validate pubkey ownership