Compare commits
No commits in common. "320ba3fc67519c5ac4ac6e9da2b6af0d6d463cb6" and "7ca373b020062a6bc569476b44003c60f62b6148" have entirely different histories.
320ba3fc67
...
7ca373b020
|
@ -1,92 +0,0 @@
|
||||||
import path from "path";
|
|
||||||
import { Page, PostMetadata } from "../metadata";
|
|
||||||
import * as util from "../util";
|
|
||||||
|
|
||||||
const baseURL = process.env.BASE_URL || "shadowfacts.net";
|
|
||||||
|
|
||||||
export default async function activitypub(posts: Page[]) {
|
|
||||||
for (const post of posts) {
|
|
||||||
const object = postObject(post);
|
|
||||||
const dir = path.dirname(post.metadata.permalink);
|
|
||||||
const base = path.basename(post.metadata.permalink);
|
|
||||||
const dest = path.format({
|
|
||||||
dir,
|
|
||||||
name: base,
|
|
||||||
ext: ".json"
|
|
||||||
});
|
|
||||||
util.write(dest, JSON.stringify(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
util.write("ap/actor", JSON.stringify(actorObject()))
|
|
||||||
|
|
||||||
util.write(".well-known/webfinger", JSON.stringify(webfingerObject()));
|
|
||||||
}
|
|
||||||
|
|
||||||
function postObject(post: Page): object {
|
|
||||||
const postMeta = <PostMetadata>post.metadata;
|
|
||||||
return {
|
|
||||||
"@context": [
|
|
||||||
"https://www.w3.org/ns/activitystreams"
|
|
||||||
],
|
|
||||||
"type": "Article",
|
|
||||||
"id": `https://${baseURL}${postMeta.permalink}.json`,
|
|
||||||
"published": (<Date>postMeta.date).toISOString(),
|
|
||||||
"inReplyTo": null,
|
|
||||||
"url": `https://${baseURL}${postMeta.permalink}`,
|
|
||||||
"attributedTo": `https://${baseURL}/ap/actor`,
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
|
||||||
"cc": [],
|
|
||||||
"name": postMeta.title,
|
|
||||||
"content": post.text
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function actorObject() {
|
|
||||||
return {
|
|
||||||
"@context": [
|
|
||||||
"https://www.w3.org/ns/activitystreams",
|
|
||||||
"https://w3id.org/security/v1"
|
|
||||||
],
|
|
||||||
"type": "Person",
|
|
||||||
"id": `https://${baseURL}/ap/actor`,
|
|
||||||
"preferredUsername": "shadowfacts",
|
|
||||||
"name": "shadowfacts' blog",
|
|
||||||
"icon": {
|
|
||||||
"type": "Image",
|
|
||||||
"mediaType": "image/png",
|
|
||||||
"url": `https://${baseURL}/shadowfacts.png`
|
|
||||||
},
|
|
||||||
"inbox": `https://${baseURL}/ap/inbox`,
|
|
||||||
"publicKey": {
|
|
||||||
"id": `https://${baseURL}/ap/actor#main-key`,
|
|
||||||
"owner": `https://${baseURL}/ap/actor`,
|
|
||||||
"publicKeyPem":
|
|
||||||
`
|
|
||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxsePhOEq6EqqgGe+5vKa
|
|
||||||
ti8cnvLoP3eJDTHENxX4M9epMIeo48cI214wkAERoNufZLtYeGOHO6YJcVydVSYN
|
|
||||||
Ud4lQxgaPwAlh0DB0BUrXR1yfcSAhHS86XBSUq86O3fY5V+vEdZiN5PfUCG5rg5t
|
|
||||||
5V/TrcbVQngXqDmwVZ/OcJ+5vUo+B62Mul7EmiNkZHKzp1VZGVtZ6nZ/4TxsdeSN
|
|
||||||
XT8Vb0f/GJQOQLzW6dV0CBupts6x7o+9oRiYiAH+cXLFyQdTQ+1TrqMSMscdfX9I
|
|
||||||
Kos5Ih7oKdj6wQt0pDEOGx090c9JzQC25RzxRk7jc1Jt1UzDi/a1U/BbucxIvPr3
|
|
||||||
PQIDAQAB
|
|
||||||
-----END PUBLIC KEY-----
|
|
||||||
`
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function webfingerObject() {
|
|
||||||
return {
|
|
||||||
"subject": `acct:shadowfacts@${baseURL}`,
|
|
||||||
"links": [
|
|
||||||
{
|
|
||||||
"rel": "self",
|
|
||||||
"type": "application/activity+json",
|
|
||||||
"href": `https://${baseURL}/ap/actor`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
import activitypub from "./activitypub";
|
|
||||||
import categories from "./categories";
|
import categories from "./categories";
|
||||||
import copy from "./copy";
|
import copy from "./copy";
|
||||||
import css from "./css";
|
import css from "./css";
|
||||||
|
@ -10,7 +9,6 @@ import rss from "./rss";
|
||||||
import tutorials from "./tutorials";
|
import tutorials from "./tutorials";
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
activitypub,
|
|
||||||
categories,
|
categories,
|
||||||
copy,
|
copy,
|
||||||
css,
|
css,
|
||||||
|
|
|
@ -11,9 +11,7 @@ async function generate() {
|
||||||
generators.homepage(posts);
|
generators.homepage(posts);
|
||||||
generators.redirects(posts);
|
generators.redirects(posts);
|
||||||
const categories = await generators.categories(posts);
|
const categories = await generators.categories(posts);
|
||||||
await generators.rss(posts, categories, tutorials);
|
generators.rss(posts, categories, tutorials);
|
||||||
|
|
||||||
generators.activitypub(posts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generate();
|
generate();
|
|
@ -18,7 +18,6 @@ export interface PostMetadata extends Metadata {
|
||||||
category: string;
|
category: string;
|
||||||
date: string | Date;
|
date: string | Date;
|
||||||
excerpt?: string;
|
excerpt?: string;
|
||||||
uuid: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get(path: string): Promise<Page> {
|
export async function get(path: string): Promise<Page> {
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate": "tsc -p . && node built/index.js",
|
"generate": "tsc -p . && node built/index.js",
|
||||||
"serve": "npm run generate && http-server out",
|
"serve": "npm run generate && http-server out"
|
||||||
"generate-post": "node bin/generate-post.js"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sindresorhus/slugify": "^0.6.0",
|
"@sindresorhus/slugify": "^0.6.0",
|
||||||
|
@ -15,8 +14,7 @@
|
||||||
"highlight.js": "^9.13.1",
|
"highlight.js": "^9.13.1",
|
||||||
"markdown-it": "^8.4.2",
|
"markdown-it": "^8.4.2",
|
||||||
"node-sass": "^4.11.0",
|
"node-sass": "^4.11.0",
|
||||||
"typescript": "^3.2.2",
|
"typescript": "^3.2.2"
|
||||||
"uuid": "^3.3.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/ejs": "^2.6.1",
|
"@types/ejs": "^2.6.1",
|
||||||
|
|
|
@ -337,12 +337,9 @@ figure {
|
||||||
li {
|
li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: inline;
|
display: inline;
|
||||||
|
margin-right: 1em;
|
||||||
font-variant: small-caps;
|
font-variant: small-caps;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
&:not(:last-child) {
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue