Compare commits
No commits in common. "99637521d4e40f158fbbc4698b724d7d2aab5f92" and "3be13e191e08a12c5fca05254e6e3869692d6325" have entirely different histories.
99637521d4
...
3be13e191e
|
@ -60,7 +60,7 @@ async function cacheActor(actorObject: ActorObject) {
|
|||
function getIconUrl(icon: string | object): string {
|
||||
return icon instanceof String ? icon : (icon as any).url;
|
||||
}
|
||||
const iconURL = !actorObject.icon ? null : actorObject.icon instanceof Array ? getIconUrl(actorObject.icon[0]) : getIconUrl(actorObject.icon);
|
||||
const iconURL: string = actorObject.icon instanceof Array ? getIconUrl(actorObject.icon[0]) : getIconUrl(actorObject.icon);
|
||||
const actor = new Actor();
|
||||
actor.id = actorObject.id;
|
||||
actor.actorObject = actorObject;
|
||||
|
|
|
@ -4,7 +4,6 @@ import comments from "./comments";
|
|||
import federate from "./federate";
|
||||
import followers from "./followers";
|
||||
import inbox from "./inbox";
|
||||
import nodeinfo from "./nodeinfo";
|
||||
import webfinger from "./webfinger";
|
||||
|
||||
export = {
|
||||
|
@ -14,6 +13,5 @@ export = {
|
|||
federate,
|
||||
followers,
|
||||
inbox,
|
||||
nodeinfo,
|
||||
webfinger
|
||||
};
|
|
@ -1,59 +0,0 @@
|
|||
import {Request, Response, Router} from "express";
|
||||
import { promises as fs } from "fs";
|
||||
import {getConnection} from "typeorm";
|
||||
import Article from "../entity/Article";
|
||||
import Note from "../entity/Note";
|
||||
|
||||
const domain = process.env.DOMAIN;
|
||||
|
||||
export default async function nodeinfo(router: Router) {
|
||||
router.get("/.well-known/nodeinfo", (req, res) => {
|
||||
res.json({
|
||||
links: [
|
||||
{
|
||||
href: `https://${domain}/nodeinfo/2.0.json`,
|
||||
rel: "https://nodeinfo.diaspora.software/ns/schema/2.0"
|
||||
},
|
||||
{
|
||||
href: `https://${domain}/nodeinfo/2.1.json`,
|
||||
rel: "https://nodeinfo.diaspora.software/ns/schema/2.1"
|
||||
}
|
||||
]
|
||||
});
|
||||
res.end();
|
||||
});
|
||||
|
||||
router.get("/nodeinfo/2.0.json", await handleNodeInfo("2.0"));
|
||||
router.get("/nodeinfo/2.1.json", await handleNodeInfo("2.1"));
|
||||
}
|
||||
|
||||
async function handleNodeInfo(version: string) {
|
||||
const softwareVersion = JSON.parse((await fs.readFile("package.json")).toString()).version;
|
||||
const postCount = await getConnection().getRepository(Article).count();
|
||||
return async (req: Request, res: Response) => {
|
||||
res.json({
|
||||
version: version,
|
||||
software: {
|
||||
name: "shadowfacts_blog",
|
||||
version: softwareVersion,
|
||||
repository: version === "2.1" ? "https://git.shadowfacts.net/shadowfacts/shadowfacts.net" : undefined
|
||||
},
|
||||
protocols: ["activitypub"],
|
||||
services: {
|
||||
inbound: [],
|
||||
outbound: ["atom1.0"]
|
||||
},
|
||||
openRegistrations: false,
|
||||
usage: {
|
||||
users: {
|
||||
total: 1,
|
||||
activeHalfyear: 1,
|
||||
activeMonth: 1
|
||||
},
|
||||
localPosts: postCount,
|
||||
localComments: await getConnection().getRepository(Note).count()
|
||||
}
|
||||
});
|
||||
res.end();
|
||||
};
|
||||
}
|
|
@ -34,7 +34,5 @@ export default async function css() {
|
|||
await generate("dark");
|
||||
await generate("auto");
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
require("fs").watch("site/css/", css);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
import * as metadata from "../metadata";
|
||||
import layout from "../layout";
|
||||
import * as util from "../util";
|
||||
|
||||
export default async function errors() {
|
||||
await generate("404.html");
|
||||
await generate("500.html");
|
||||
}
|
||||
|
||||
async function generate(filename: string) {
|
||||
const page = await metadata.get(`site/${filename}.ejs`);
|
||||
|
||||
page.text = util.render(page.text, {
|
||||
metadata: page.metadata
|
||||
}, `site/${filename}.ejs`);
|
||||
|
||||
page.text = await layout(page.text, page.metadata, page.metadata.layout!);
|
||||
|
||||
await util.write(filename, page.text);
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
import categories from "./categories";
|
||||
import copy from "./copy";
|
||||
import css from "./css";
|
||||
import errors from "./errors";
|
||||
import homepage from "./homepage";
|
||||
import missing from "./missing";
|
||||
import posts from "./posts";
|
||||
import redirects from "./redirects";
|
||||
import rss from "./rss";
|
||||
|
@ -12,8 +12,8 @@ export = {
|
|||
categories,
|
||||
copy,
|
||||
css,
|
||||
errors,
|
||||
homepage,
|
||||
missing,
|
||||
posts,
|
||||
redirects,
|
||||
rss,
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import * as metadata from "../metadata";
|
||||
import layout from "../layout";
|
||||
import * as util from "../util";
|
||||
|
||||
export default async function missing() {
|
||||
const page = await metadata.get("site/404.html.ejs");
|
||||
|
||||
page.text = util.render(page.text, {
|
||||
metadata: page.metadata
|
||||
}, "site/404.html.ejs");
|
||||
|
||||
page.text = await layout(page.text, page.metadata, page.metadata.layout!);
|
||||
|
||||
util.write("404.html", page.text);
|
||||
}
|
14
lib/index.ts
14
lib/index.ts
|
@ -14,7 +14,7 @@ import * as path from "path";
|
|||
async function generate(): Promise<Page[]> {
|
||||
generators.copy();
|
||||
generators.css();
|
||||
generators.errors();
|
||||
generators.missing();
|
||||
|
||||
const tutorials = await generators.tutorials();
|
||||
|
||||
|
@ -68,23 +68,11 @@ async function generate(): Promise<Page[]> {
|
|||
activitypub.comments(apRouter);
|
||||
activitypub.followers(apRouter);
|
||||
activitypub.inbox(apRouter);
|
||||
await activitypub.nodeinfo(apRouter);
|
||||
activitypub.webfinger(apRouter);
|
||||
activitypub.articles.route(apRouter);
|
||||
app.use(apRouter);
|
||||
app.use(express.static("out"));
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
res.status(500).sendFile("500.html", {
|
||||
root: "out"
|
||||
});
|
||||
});
|
||||
app.use((req, res, next) => {
|
||||
res.status(404).sendFile("404.html", {
|
||||
root: "out"
|
||||
});
|
||||
});
|
||||
|
||||
const port = process.env.PORT || 8083;
|
||||
app.listen(port, () => {
|
||||
console.log(`Listening on port ${port}`);
|
||||
|
|
|
@ -3,7 +3,7 @@ metadata.title = "Not Found"
|
|||
metadata.layout = "default.html.ejs"
|
||||
```
|
||||
|
||||
<div class="main error-page">
|
||||
<div class="main search">
|
||||
<h1 class="page-heading">Unable to find what you were looking for.</h1>
|
||||
<h3>Try searching:</h3>
|
||||
<form action="https://www.google.com/search" method="GET">
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
```
|
||||
metadata.title = "Not Found"
|
||||
metadata.layout = "default.html.ejs"
|
||||
```
|
||||
|
||||
<div class="main error-page">
|
||||
<h1 class="page-heading">Something went wrong.</h1>
|
||||
<p>
|
||||
Please try again later. If the error persists, please <a href="mailto:me@shadowfacts.net">contact me</a>.
|
||||
</p>
|
||||
</div>
|
|
@ -195,8 +195,8 @@ article {
|
|||
}
|
||||
}
|
||||
|
||||
.error-page {
|
||||
margin: 0 auto;
|
||||
.search {
|
||||
margin: 100px auto;
|
||||
text-align: center;
|
||||
|
||||
h3 {
|
||||
|
@ -205,6 +205,7 @@ article {
|
|||
line-height: 1.3;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
padding: 0 2rem;
|
||||
}
|
||||
|
||||
input#q {
|
||||
|
|
Loading…
Reference in New Issue