Skip to content

Commit 4ea6e36

Browse files
authored
docs: add a navbar to the webpage (#46)
#5
2 parents a17f5ce + aced189 commit 4ea6e36

7 files changed

Lines changed: 78 additions & 34 deletions

File tree

.github/site/coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
![logo](./ext/blue.svg)
2+
![logo](ext/blue.svg)
33

44
# Ghostbird
55

.github/site/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
<meta name="description" content="Ghostbird is a Thunderbird add-on that connects your text editor with Thunderbird's email compose window, allowing you to edit the message in the text editor.">
88
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
99
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4.13.1/lib/themes/vue.min.css">
10-
<link rel="icon" href="ext/blue.svg" />
10+
<link rel="icon" href="ext/blue.svg">
1111
<script type="module" src="index.mjs"></script>
1212
</head>
1313
<body>
14+
<nav>
15+
<a href="https://github.com/exteditor/ghostbird/">&#x1faba; GitHub</a>
16+
<a href="#/doc/faq">&#x2753; FAQ</a>
17+
<a href="https://translate.kagi.com/exteditor.github.io/ghostbird/">&#x1f30d; Translation</a>
18+
</nav>
1419
<div id="app"></div>
1520
</body>
1621
</html>

.github/site/index.mjs

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
11
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11.12.0/+esm";
22
import "https://cdn.jsdelivr.net/npm/docsify@4.13.1/+esm";
33

4+
// @ts-check
5+
46
mermaid.initialize({ startOnLoad: false });
57

6-
// see https://docsify.js.org/#/configuration
8+
/**
9+
* Build a URL to a GitHub resource
10+
* @param {string} type The type of resource ('blob' or 'tree')
11+
* @param {string} path Absolute path (/ points to the repository root) to the resource
12+
* @returns {string} The URL to the resource
13+
*/
14+
const urlFor = (type, path) => `https://github.com/exteditor/ghostbird/${type}/main/${encodeURIComponent(path.slice(1))}`;
15+
16+
/**
17+
* Build a Markdown text that redirects to a URL
18+
* @param {string} url The URL to redirect to
19+
* @returns {string} a Markdown text
20+
*/
21+
const redirectTo = (url) => `Redirecting to ${url}...\n\n<script>\nlocation.href = "${url}"${'</'}script>`;
722

8-
const footer = `____
23+
/**
24+
* Add a footer to the Markdown text
25+
* @param {string} text The Markdown text
26+
* @returns {string} Markdown text with footer added
27+
*/
28+
const addFooter = (text, vm) => `${text}
929
10-
Powered by [Docsify](https://docsify.js.org/)
30+
____
1131
12-
[▲ Back to Top](#)
32+
[▲ Back to Top](#top)
33+
<div align="right">
34+
Last Update: <a href="${urlFor('blob', vm.route.file)}">{docsify-updated}</a><br>
35+
Powered by <a href="https://docsify.js.org/">Docsify</a>
36+
</div>
1337
`;
1438

39+
// see https://docsify.js.org/#/configuration
40+
1541
window.$docsify = {
1642
name: 'Ghostbird \u{1faba}\u{1f4eb}\u{1f47b}',
1743
repo: 'exteditor/ghostbird',
1844
logo: 'ext/blue.svg',
45+
formatUpdated: '{YYYY}-{MM}-{DD}',
1946
relativePath: true,
2047
executeScript: true,
2148
homepage: "homepage.md",
@@ -25,12 +52,16 @@ window.$docsify = {
2552
themeColor: '#0b9dd6',
2653
routes: {
2754
['/README'](route) {
28-
let url = `https://github.com/exteditor/ghostbird/blob/main/${encodeURIComponent(route.slice(1))}.md`
29-
return `Redirecting to ${url}...\n\n<script>\nlocation.href = "${url}"${'</'}script>`
55+
let url = urlFor('blob', `${route}.md`)
56+
return redirectTo(url)
57+
},
58+
['/[-._/a-zA-Z]*[.][a-zA-Z]+$'](route) {
59+
let url = urlFor('blob', route)
60+
return redirectTo(url)
3061
},
31-
['/[-._/a-zA-Z]*[.][a-zA-Z]+'](route) {
32-
let url = `https://github.com/exteditor/ghostbird/blob/main/${encodeURIComponent(route.slice(1))}`
33-
return `Redirecting to ${url}...\n\n<script>\nlocation.href = "${url}"${'</'}script>`
62+
['/[-._/a-zA-Z]+/$'](route) {
63+
let url = urlFor('tree', route)
64+
return redirectTo(url)
3465
},
3566
},
3667
search: [
@@ -53,8 +84,8 @@ window.$docsify = {
5384
}
5485
},
5586
plugins: [
56-
(hook, _vm) => {
57-
hook.beforeEach(html => html + footer);
87+
(hook, vm) => {
88+
hook.beforeEach((text) => addFooter(text, vm));
5889
hook.doneEach(() => mermaid.run());
5990
},
6091
],

doc/building.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ js & copied_ext_files & messages & manifest --> web_ext[["web-ext"]] --> xpi["Ma
5353
- Compiling bundled JavaScript files into `dist/ext/`.
5454
- Running `yarn build-xpi` creates a zip archive named `dist/ghostbird-{version}.xpi`.
5555
- [The `web-ext` tool](https://github.com/mozilla/web-ext#web-ext) does the actual work.
56-
- The usual `yarn build` runs both of the above after running the linter and tests.
56+
- The usual `yarn build`, which is used by the CI, runs both of the above after running the linter and tests.
5757
- `yarn watch` is an alias for `yarn build-js --watch`, which runs the build continuously.
5858

5959
## Build modes
@@ -111,5 +111,5 @@ The build script assumes four use cases, each using a different source of versio
111111

112112
- Building with `ext/manifest.json` should produce identical results to one from CI in terms of file names and their contents.
113113
- However, they will have different timestamps and file order, meaning Ghostbird builds are not strictly reproducible.
114-
- It would be possible to wipe `mtime`s to produce strictly identical zips, but this was considered pointless as AMO repackages the zip when signing the add-on anyway.
114+
- It would be possible to wipe `mtime`s to produce strictly identical zips, but this was considered pointless as ~~AMO repackages the zip when signing the add-on anyway.~~ **Edit:** It turns out Firefox add-ons are repackaged while Thunderbird add-ons are not, so there may be a point to this after all. PRs welcome.
115115
- See [the issue page for the `web-ext` tool](https://github.com/mozilla/web-ext/issues/2381#issuecomment-1075667618) for details.

doc/design.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ This is how user actions are handled:
174174
* [Barrelsby](https://github.com/bencoveney/barrelsby) generates `index.ts`.
175175
* See [building.md](./building.md) for details on build script internals.
176176

177+
* We rely on GitHub Actions for CI and releases.
178+
177179
## Structure of the code<a id="structure"></a>
178180

179181
The code loosely follows the [Ports and Adapters architecture](https://8thlight.com/insights/a-color-coded-guide-to-ports-and-adapters) and adheres to the [Dependency Inversion Principle](https://en.wikipedia.org/wiki/Dependency_inversion_principle).
@@ -188,21 +190,21 @@ The code loosely follows the [Ports and Adapters architecture](https://8thlight.
188190

189191
The source code is located in the `src/` directory. The main files are:
190192

191-
- `src/root/background.ts`: A background script that manages the WebSocket connection to the GhostText server and relays messages between the compose script and the server. Bundled as `background.js`.
192-
- `src/root/compose.ts`: A compose script that adds a button to the mail compose window. Bundled as `compose.js`.
193-
- `src/root/options.ts`: An options page for configuring settings such as the server URL and text editor to use. Bundled as `options.js` and used by `ext/options.html`.
193+
- [`src/root/background.ts`][backgroundts]: A background script that manages the WebSocket connection to the GhostText server and relays messages between the compose script and the server. Bundled as `background.js`.
194+
- [`src/root/compose.ts`][composets]: A compose script that adds a button to the mail compose window. Bundled as `compose.js`.
195+
- [`src/root/options.ts`][optionsts]: An options page for configuring settings such as the server URL and text editor to use. Bundled as `options.js` and used by `ext/options.html`.
194196

195197
Other directories are:
196198

197-
- `src/app-background/`: Infrastructure of `background.ts` that handles Thunderbird events.
198-
- `src/app-compose/`: Infrastructure of `compose.ts` that handles Thunderbird events.
199-
- `src/app-options/`: Infrastructure of `options.ts` that handles Thunderbird events.
200-
- `src/ghosttext-session/`: Main module of the add-on implementing the protocol.
201-
- `src/ghosttext-runner/`: Facilitator that works together with `ghosttext-session` which feeds events into it and execute decisions made.
202-
- `src/ghosttext-adaptor/`: Helpers of `ghosttext-runner`.
203-
- `src/test/`: Test code.
204-
- `src/thunderbird/`: Wrapper of the Thunderbird MailExtension API.
205-
- `src/util/`: Utility modules used by multiple modules.
199+
- [`src/app-background/`](../src/app-background/): Infrastructure of [`background.ts`][backgroundts] that handles Thunderbird events.
200+
- [`src/app-compose/`](../src/app-compose/): Infrastructure of [`compose.ts`][composets] that handles Thunderbird events.
201+
- [`src/app-options/`](../src/app-options/): Infrastructure of [`options.ts`][optionsts] that handles Thunderbird events.
202+
- [`src/ghosttext-session/`](../src/ghosttext-session/): Main module of the add-on implementing the protocol.
203+
- [`src/ghosttext-runner/`](../src/ghosttext-runner/): Facilitator that works together with `ghosttext-session` by feeding events into it and execute decisions made.
204+
- [`src/ghosttext-adaptor/`](../src/ghosttext-adaptor/): Helpers of `ghosttext-runner`.
205+
- [`src/test/`](../src/test/): Test code.
206+
- [`src/thunderbird/`](../src/thunderbird/): Wrapper of the Thunderbird MailExtension API.
207+
- [`src/util/`](../src/util/): Utility modules used by multiple modules.
206208

207209
### Module Dependencies
208210

@@ -274,7 +276,7 @@ options_api & background_api & compose_api -.->|indirectly calls| thunderbird
274276

275277
* `api.ts` defines subsets of the Thunderbird API used by the module in the folder.
276278
* These interfaces are implemented by `thunderbird/` modules.
277-
* This is to isolate the impact of future Thunderbird API changes to `src/thunderbird/` modules only.
279+
* This is to isolate the impact of future Thunderbird API changes to `thunderbird/` modules only.
278280

279281
```mermaid
280282
flowchart TB
@@ -299,7 +301,7 @@ ghostbird_runner -->|uses| ghostbird_session
299301

300302
TL;DR: `root` module contains entry point and the [Composition Root][ploeh].
301303

302-
* `root/startup/startup_{background,compose,options}.ts` is used at the toplevel modules, namely `background.ts`, `compose.ts`, and `options.ts`. It initializes classes.
304+
* [`root/startup/startup_*.ts`][startupdir] are used at the toplevel modules, namely [`background.ts`][backgroundts], [`compose.ts`][composets], and [`options.ts`][optionsts]. It initializes classes.
303305
* All the non-root classes in the codebase are either:
304306
* A) instantiated by `startup*()`, or
305307
* B) instantiated directly with `new` operator by instances of (A).
@@ -317,7 +319,7 @@ TL;DR: `root` module contains entry point and the [Composition Root][ploeh].
317319
* A class may define `static aliases: string[] | string` to have the other name.
318320
* Name clashes will result in error at startup, except ones passed to classes with `wantArray = true`.
319321
* Use of automatic instantiation must be restricted to `root/` to make the code easier to follow.
320-
* `test/startup.test.ts` contains tests to verify that all classes registered can be instantiated successfully.
322+
* [`test/startup.test.ts`](../src/test/startup.test.ts) contains tests to verify that all classes registered can be instantiated successfully.
321323
* See [FAQ](./faq-architectural.md) for some design decisions and justification.
322324

323325
```mermaid
@@ -358,3 +360,7 @@ instantiate_class --> need_instance
358360
[ploeh]: https://blog.ploeh.dk/2019/06/17/composition-root-location/
359361
[wiki]: https://github.com/exteditor/ghostbird/wiki
360362
[so]: https://stackoverflow.com/q/73206468/188256
363+
[startupdir]: ../src/root/startup/
364+
[backgroundts]: ../src/root/background.ts
365+
[composets]: ../src/root/compose.ts
366+
[optionsts]: ../src/root/options.ts

doc/faq.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@
8787

8888
### Why not use External Editor Revived as a base?
8989

90-
(For those who don't know: [External Editor Revived by @Frederick888](https://github.com/Frederick888/external-editor-revived) is an add-on for Thunderbird that lets you edit email text in an external text editor, which works in recent Thunderbird versions and is actively maintained)
90+
(For those who don't know: [External Editor Revived by @Frederick888](https://github.com/Frederick888/external-editor-revived) is an add-on for Thunderbird that lets you edit email text in an external text editor, which works in recent Thunderbird versions and is well-maintained)
9191

9292
* I started working on Ghostbird while mostly offline. Had I known about ERR's existence, Ghostbird wouldn't exist now!
9393
* ERR works using [Native Messaging](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging), which is the only way to launch external process in recent Thunderbird API. It requires a companion app to be installed and registered as a Native Messaging Host. See [ERR's Wiki pages](https://github.com/Frederick888/external-editor-revived/wiki) for details.
9494
* Reasons to continue developing Ghostbird? I think GhostText's live updating functionality is pretty (for now; there is no fundamental reason ERR can't do the same).
95-
* That said, I think you should try ERR before using Ghostbird, which is still in alpha, as ERR is more mature and already on [AMO][revived].
95+
* That said, I think you should try ERR before using Ghostbird, which is still in beta, as ERR is more mature and already listed on [AMO][revived] as a stable extension.
9696

9797
[![External Editor Revived](https://raw.githubusercontent.com/thunderbird/webext-support/refs/heads/master/images/get-the-addon.svg)][revived]
9898

@@ -106,7 +106,7 @@
106106

107107
### Why Yarn?
108108

109-
* I love cats, and Yarn has [a cat logo](https://github.com/yarnpkg/assets).
109+
* I love cats, and Yarn has [a cat logo](https://github.com/yarnpkg/assets#yarn-assets).
110110

111111
### How do you build this add-on?
112112

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"engines": {
1313
"thunderbird": ">= 128"
1414
},
15-
"homepage": "https://github.com/exteditor/ghostbird/",
15+
"homepage": "https://exteditor.github.io/ghostbird/",
16+
"bugs": "https://github.com/exteditor/ghostbird/issues/",
17+
"funding": "https://give.thunderbird.net/",
1618
"repository": {
1719
"type": "git",
1820
"url": "github:exteditor/ghostbird"

0 commit comments

Comments
 (0)