Commit Graph

220 Commits

Author SHA1 Message Date
Leandro Facchinetti e452838d27 Don’t store alternates explicitly to save disk space
Instead, fetch alternates from within the feed on the demand.

This makes alternates marginally more expensive to retrieve, but saves on storage (which we were running out on the DigitalOcean deployment), and is a cleaner architecture overall: no need to keep the feeds and alternates in sync.

Here’s a script to migrate existing feeds:

// Call me with, for example: env "BASE_URL=https://kill-the-newsletter.com" npx ts-node migrate.ts
// I’m idempotent and reentrant, you may call me multiple times if necessary (for example, if the migration fails in the middle for whatever reason)

import { promises as fs } from "fs";
import path from "path";
import { JSDOM } from "jsdom";

const BASE_URL = process.env.BASE_URL ?? "http://localhost:8000";
const FEEDS_PATH = "static/feeds";

(async () => {
  await fs.rmdir("static/alternate", { recursive: true });
  for (const feedPath of (await fs.readdir(FEEDS_PATH)).filter((feedPath) =>
    feedPath.endsWith(".xml")
  )) {
    const text = await fs.readFile(path.join(FEEDS_PATH, feedPath), "utf-8");
    const feed = new JSDOM(text, { contentType: "text/xml" });
    const document = feed.window.document;
    const feedIdentifier = document
      .querySelector("id")!
      .textContent!.split(":")[2];
    for (const entry of document.querySelectorAll("entry")) {
      const entryIdentifier = entry
        .querySelector("id")!
        .textContent!.split(":")[2];
      entry
        .querySelector(`link[rel="alternate"]`)
        ?.setAttribute(
          "href",
          `${BASE_URL}/alternate/${feedIdentifier}/${entryIdentifier}.html`
        );
    }
    await fs.writeFile(
      path.join(FEEDS_PATH, feedPath),
      `<?xml version="1.0" encoding="utf-8"?>${feed.serialize()}`.trim()
    );
    console.log(feedIdentifier);
  }
})();
2020-11-24 17:12:14 +00:00
Leandro Facchinetti 212b06eb49 . 2020-10-31 11:43:57 +00:00
Leandro Facchinetti 0ef39970e6
Merge pull request #25 from leafac/dependabot/npm_and_yarn/dot-prop-4.2.1
Bump dot-prop from 4.2.0 to 4.2.1
2020-10-30 21:09:57 +00:00
dependabot[bot] cb33a16fb9
Bump dot-prop from 4.2.0 to 4.2.1
Bumps [dot-prop](https://github.com/sindresorhus/dot-prop) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/sindresorhus/dot-prop/releases)
- [Commits](https://github.com/sindresorhus/dot-prop/compare/v4.2.0...v4.2.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-30 20:46:04 +00:00
Leandro Facchinetti eb58438c3e
Merge pull request #24 from leafac/dependabot/npm_and_yarn/systeminformation-4.27.11
Bump systeminformation from 4.23.1 to 4.27.11
2020-10-30 20:45:22 +00:00
dependabot[bot] 846972b4b1
Bump systeminformation from 4.23.1 to 4.27.11
Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 4.23.1 to 4.27.11.
- [Release notes](https://github.com/sebhildebrandt/systeminformation/releases)
- [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sebhildebrandt/systeminformation/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-27 20:46:07 +00:00
Leandro Facchinetti b9cf415521 . 2020-09-13 02:34:26 +01:00
Leandro Facchinetti ab99bbc699 Rmeove old line 2020-09-03 07:30:19 +01:00
Leandro Facchinetti 2724333412 Add html tagged template literal 2020-08-10 00:30:12 +01:00
Leandro Facchinetti f2fee64925 Switch src and alt 2020-08-09 23:05:31 +01:00
Leandro Facchinetti c6540fc54c Add optional tags back 2020-08-09 22:53:32 +01:00
Leandro Facchinetti f9d826fe54 . 2020-08-05 12:32:16 +01:00
Leandro Facchinetti e2a5ad35db . 2020-08-04 23:00:29 +01:00
Leandro Facchinetti c51272f340 Remove www 2020-08-04 22:57:49 +01:00
Leandro Facchinetti 175fdcae6b . 2020-08-04 22:52:12 +01:00
Leandro Facchinetti ac6f194789 . 2020-08-04 22:50:07 +01:00
Leandro Facchinetti 5a7c99b532 . 2020-08-04 22:47:58 +01:00
Leandro Facchinetti b9907a8021 Merge branch 'docker' 2020-07-24 13:08:15 +01:00
Leandro Facchinetti e9ce7e77a2 Change command-line flag 2020-07-24 09:03:49 +01:00
Leandro Facchinetti 33e84b345a Changes to Dockerfile based on https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ 2020-07-24 09:03:17 +01:00
Frank Moskal 451781ab37 update README with basic docker info 2020-07-23 21:29:56 +01:00
Frank Moskal 4be19d9862 Create Dockerfile 2020-07-23 21:29:56 +01:00
Leandro Facchinetti 80ae8fab52 Fixes & refactorings 2020-07-23 16:11:41 +01:00
Johan Holmerin 0402f641ff Add alternate test 2020-07-15 21:29:08 +02:00
Johan Holmerin d56232e6b7 Remove old alternate entries 2020-07-15 21:28:42 +02:00
Johan Holmerin 62dee956d7 Add support for alternate URL 2020-07-14 19:42:41 +02:00
Leandro Facchinetti 0fd156cec5 Remove pre-deploy-local that was only necessary for rsync 2020-07-09 15:22:04 +01:00
Leandro Facchinetti 21a5d521a7 Update caddy 2020-07-09 15:14:32 +01:00
Leandro Facchinetti 9b65d95501 Move dependencies from dev to production 2020-07-09 15:08:52 +01:00
Leandro Facchinetti fa6092c89f Add link to Caddyfile in README 2020-07-09 12:36:48 +01:00
Leandro Facchinetti c5fc764d2a . 2020-07-09 12:35:02 +01:00
Leandro Facchinetti 9733d8daf3 Fix .gitignore 2020-07-09 12:31:13 +01:00
Leandro Facchinetti 9292d04a7e . 2020-06-09 09:26:41 +01:00
Leandro Facchinetti da294b92fc . 2020-05-08 05:22:48 -04:00
Leandro Facchinetti 950cb8319c . 2020-05-07 21:08:11 -04:00
Leandro Facchinetti 3dbcda5278 Change some dependencies 2020-05-05 02:12:57 -04:00
Leandro Facchinetti 60cd8a2f5e . 2020-05-03 13:08:51 -04:00
Leandro Facchinetti 823f21e9a9 . 2020-05-02 21:37:08 -04:00
Leandro Facchinetti 919a20d016 . 2020-04-30 09:57:37 -04:00
Leandro Facchinetti 38919d1386 Remove redundant inline style 2020-04-18 21:43:51 -04:00
Leandro Facchinetti 2f81ad9e47 PT Serif → PT Sans 2020-04-16 09:55:00 -04:00
Leandro Facchinetti c8964c62ad Use PT Serif 2020-04-09 01:42:46 -04:00
Leandro Facchinetti 718d380a1f Remove check 2020-04-08 19:32:25 -04:00
Leandro Facchinetti 5c8e096c5d Fix test 2020-04-08 19:17:11 -04:00
Leandro Facchinetti d688d0fc21 Update xmlbuilder2 to fix https://github.com/oozcitak/xmlbuilder2/issues/16 2020-04-08 19:00:59 -04:00
Leandro Facchinetti 3358558f75 . 2020-04-06 10:30:39 -04:00
Leandro Facchinetti bb3dceed55 Add instructions for self-hosting 2020-04-06 10:29:33 -04:00
Leandro Facchinetti 56facba7e7 Change default 2020-04-06 09:59:21 -04:00
Leandro Facchinetti 0493ac348e Rename 2020-04-06 09:57:18 -04:00
Leandro Facchinetti f2a2ad20e2 Extract issue report email 2020-04-06 09:54:42 -04:00