Skip to content

Commit 90b30a9

Browse files
committed
feat: refactored codebase
1 parent 95c5b37 commit 90b30a9

25 files changed

+11670
-6754
lines changed

.env.example

Lines changed: 0 additions & 10 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 184 deletions
This file was deleted.

.npmrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ Network dashboard for Polykey.
66

77
This uses Docusaurus as a CMS.
88

9-
GitHub builds this site via the CI/CD into static pages, rendering the markdown files.
9+
GitHub builds this site via the CI/CD into static pages, rendering the markdown
10+
files.
1011

11-
The CI/CD then pushes it to [testnet.polykey.com](https://testnet.polykey.com) and [mainnet.polykey.com](https://mainnet.polykey.com) which is hosted by Cloudflare's worker system.
12+
The CI/CD then pushes it to [testnet.polykey.com](https://testnet.polykey.com)
13+
and [mainnet.polykey.com](https://mainnet.polykey.com) which is hosted by
14+
Cloudflare's worker system.
1215

1316
## Development
1417

@@ -27,13 +30,22 @@ npm run lint
2730
npm run lintfix
2831
```
2932

30-
You need to do setup the `.env` from `.env.example` if you want to successfully deploy to Cloudflare.
33+
You need to do setup the `.env` from `.env.example` if you want to successfully
34+
deploy to Cloudflare.
3135

32-
We use Git LFS to store all media in `images/**`. It's important to ensure that `git-lfs` is installed on your system before you contribute anything (on NixOS, it is installed as a separate package to `git`). By default anything put under `images/**` when using `git add` (after LFS is setup) will be uploaded to LFS, and thus the repository will only have links. Because LFS is enabled, it is used on GitHub.
36+
We use Git LFS to store all media in `images/**`. It's important to ensure that
37+
`git-lfs` is installed on your system before you contribute anything (on NixOS,
38+
it is installed as a separate package to `git`). By default anything put under
39+
`images/**` when using `git add` (after LFS is setup) will be uploaded to LFS,
40+
and thus the repository will only have links. Because LFS is enabled, it is used
41+
on GitHub.
3342

34-
If this is the first time you cloned the repository, you must use `git lfs install` to ensure your local repository has LFS setup. It may be automatically setup if you already had it installed prior to cloning.
43+
If this is the first time you cloned the repository, you must use
44+
`git lfs install` to ensure your local repository has LFS setup. It may be
45+
automatically setup if you already had it installed prior to cloning.
3546

36-
Pro-tip, if we need to make sure files that were accidentally not put into LFS must be put into LFS, the command to use is:
47+
Pro-tip, if we need to make sure files that were accidentally not put into LFS
48+
must be put into LFS, the command to use is:
3749

3850
```sh
3951
git lfs migrate import --include="images/**" --everything
@@ -47,64 +59,88 @@ Because we use docusaurus, we can choose to write in markdown, TSX or MDX.
4759

4860
Create a new markdown file in `/pages`. See the other files for formatting.
4961

50-
Note that some pages were not able to be put into `/pages` due to to more complex coding. These are in the `/src`.
62+
Note that some pages were not able to be put into `/pages` due to to more
63+
complex coding. These are in the `/src`.
5164

5265
### HTML Syntax
5366

5467
Sometimes markdown syntax just doesn't cut it, and HTML syntax needs to be used.
5568

5669
While `docusaurus` is flexible, GitHub is not.
5770

58-
GitHub will process the markdown and then sanitizes the HTML: https://github.com/github/markup#github-markup.
71+
GitHub will process the markdown and then sanitizes the HTML:
72+
https://github.com/github/markup#github-markup.
5973

60-
There is a limited set of HTML tags are here: https://github.com/gjtorikian/html-pipeline/blob/03ae30d713199c2562951d627b98b75dc16939e4/lib/html/pipeline/sanitization_filter.rb#L40-L49
74+
There is a limited set of HTML tags are here:
75+
https://github.com/gjtorikian/html-pipeline/blob/03ae30d713199c2562951d627b98b75dc16939e4/lib/html/pipeline/sanitization_filter.rb#L40-L49
6176

62-
Furthermore not all attributes are kept. The `style` attribute for example is filtered out.
77+
Furthermore not all attributes are kept. The `style` attribute for example is
78+
filtered out.
6379

64-
The most common styling attributes to be used will most likely be `align`, `width`, and `height`. See: https://davidwells.io/snippets/how-to-align-images-in-markdown
80+
The most common styling attributes to be used will most likely be `align`,
81+
`width`, and `height`. See:
82+
https://davidwells.io/snippets/how-to-align-images-in-markdown
6583

6684
### Linking Assets (files, images)
6785

6886
Markdown supports 2 ways of referencing images:
6987

7088
```md
71-
![](/images/foobar.png)
72-
<img src="/images/foobar.png" />
89+
![](/images/foobar.png) <img src="/images/foobar.png" />
7390
```
7491

7592
The former is markdown syntax, the latter is HTML tag.
7693

77-
In order to maintain portability, we always use absolute paths. This works on both GitHub markdown rendering and also for `docusaurus`.
94+
In order to maintain portability, we always use absolute paths. This works on
95+
both GitHub markdown rendering and also for `docusaurus`.
7896

79-
On GitHub, which renders the markdown directly, the relative paths are considered relative to the location of the markdown file referencing the path. The absolute paths are considered relative to the root of the project repository. Therefore because `images` directory is located at the project root, it ends up being routable.
97+
On GitHub, which renders the markdown directly, the relative paths are
98+
considered relative to the location of the markdown file referencing the path.
99+
The absolute paths are considered relative to the root of the project
100+
repository. Therefore because `images` directory is located at the project root,
101+
it ends up being routable.
80102

81-
With `docusaurus`, the absolute paths are looked up relative to `static` directory. Inside the `static` directory we have created symlinks pointing back to `../images`. This allows `docusaurus` to also resolve these paths which will be copied into the `/build/` directory.
103+
With `docusaurus`, the absolute paths are looked up relative to `static`
104+
directory. Inside the `static` directory we have created symlinks pointing back
105+
to `../images`. This allows `docusaurus` to also resolve these paths which will
106+
be copied into the `/build/` directory.
82107

83-
Note that `docusaurus` doesn't do any special rendering for HTML tags, it uses the `src` as is. While markdown references will be further processed with webpack. It is therefore preferable to use markdown syntax instead. The `docusaurus` does support a variant of the HTML tag:
108+
Note that `docusaurus` doesn't do any special rendering for HTML tags, it uses
109+
the `src` as is. While markdown references will be further processed with
110+
webpack. It is therefore preferable to use markdown syntax instead. The
111+
`docusaurus` does support a variant of the HTML tag:
84112

85113
```md
86114
<img src={require('/images/foobar.png').default} />
87115
```
88116

89117
However this does not work in GitHub. So this is not recommended to use.
90118

91-
Therefore if you want to add inline styles to an image and still use markdown syntax so you get the benefit of `docusaurus` asset processing, the styles must be applied outside the image reference in a surrounding tag:
119+
Therefore if you want to add inline styles to an image and still use markdown
120+
syntax so you get the benefit of `docusaurus` asset processing, the styles must
121+
be applied outside the image reference in a surrounding tag:
92122

93123
```md
94124
<div align="center">
95125

96-
![](/images/foobar.png)
126+
![](/images/foobar.png)
97127

98128
</div>
99129
```
100130

101-
Take note of the whitespace newlines between, if no newlines are used, GitHub will interpret this as all HTML. Also note that `<p></p>` will not work.
131+
Take note of the whitespace newlines between, if no newlines are used, GitHub
132+
will interpret this as all HTML. Also note that `<p></p>` will not work.
102133

103-
Note that this won't work for resizing the images unfortunately. You have to apply the `width` attribute directly to the `<img />` tag. See: https://github.com/facebook/docusaurus/discussions/6465 for more information.
134+
Note that this won't work for resizing the images unfortunately. You have to
135+
apply the `width` attribute directly to the `<img />` tag. See:
136+
https://github.com/facebook/docusaurus/discussions/6465 for more information.
104137

105138
### Linking
106139

107-
In the navigation in Docusaurus, there are several properties that controls how the routing works. Because `polykey.com` is composed of separate cloudflare workers stitched together into a single domain, we have to hack around client side routing even for what looks like relative links.
140+
In the navigation in Docusaurus, there are several properties that controls how
141+
the routing works. Because `polykey.com` is composed of separate cloudflare
142+
workers stitched together into a single domain, we have to hack around client
143+
side routing even for what looks like relative links.
108144

109145
```js
110146
{
@@ -117,7 +153,8 @@ The `to` ensures it shows up as a relative link.
117153

118154
The `pathname://` bypasses the client side routing forcing server side routing.
119155

120-
The `target: '_self'` ensures that the same frame is used instead of creating a new frame.
156+
The `target: '_self'` ensures that the same frame is used instead of creating a
157+
new frame.
121158

122159
## Deployment
123160

@@ -129,16 +166,23 @@ Finally run `npm run deploy`.
129166

130167
This will deploy the development workers first.
131168

132-
If you want to deploy production workers, you have to `npm run deploy -- --env production`.
169+
If you want to deploy production workers, you have to
170+
`npm run deploy -- --env production`.
133171

134172
### DNS
135173

136-
DNS is managed by cloudflare. The `wrangler.toml` specifies the usage of a custom domain for the worker that runs this static site.
174+
DNS is managed by cloudflare. The `wrangler.toml` specifies the usage of a
175+
custom domain for the worker that runs this static site.
137176

138177
The entire built `public` directory gets uploaded to cloudflare's KV system.
139178

140-
The custom domain is then added as a special record on the `testnet.polykey.com` and `mainnet.polykey.com` zone which routes directly to the worker service.
179+
The custom domain is then added as a special record on the `testnet.polykey.com`
180+
and `mainnet.polykey.com` zone which routes directly to the worker service.
141181

142182
Finally HTTPS is always on, so there's a redirection from `http` to `https` too.
143183

144-
Traditionally without the custom domain, you would have to use worker routes. However this only works if you also create a A record for the root with the proxy-mode turned on. The actual address doesn't matter, you can point it to a private or reserved IP, maybe even `127.0.0.1` because once the proxy is activated, the worker routes take effect.
184+
Traditionally without the custom domain, you would have to use worker routes.
185+
However this only works if you also create a A record for the root with the
186+
proxy-mode turned on. The actual address doesn't matter, you can point it to a
187+
private or reserved IP, maybe even `127.0.0.1` because once the proxy is
188+
activated, the worker routes take effect.

0 commit comments

Comments
 (0)