Skip to content

Commit b5aa73a

Browse files
authored
Add typescript support (#219)
* Add typescript support * Make jekyll work on docker-compose on windows
1 parent 48a265b commit b5aa73a

11 files changed

Lines changed: 1977 additions & 33 deletions

.github/workflows/pages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ jobs:
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@v3
33+
- name: Setup node
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 20
37+
- name: Install Node deps
38+
run: npm ci
39+
- name: Compile typescript
40+
run: npm run build
3341
- name: Setup Ruby
3442
uses: ruby/setup-ruby@v1
3543
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ _site/
44
.jekyll-cache/
55
.jekyll-metadata
66
Gemfile.lock
7-
assets/js/zzzz-search-data.json
7+
assets/js/zzzz-search-data.json
8+
node_modules/
9+
assets/js/generated

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@ if you want to contribute there is something to be done:
1313
- theoretical information on GPON
1414
- absent stick information
1515
- quick start
16-
- absent and new ont
16+
- absent and new ont
17+
18+
## How to build
19+
This website uses typescript, so remember to:
20+
21+
- Install node (20)
22+
- Run npm ci to install all relevant typescript packages
23+
- Run npm run build to transpile ts to js
24+
25+
Alternatively, you can just run:
26+
`docker-compose up -d typescript` which will build all the required typescript files for you

_config.docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
url: "http://localhost:4000"

_ont_xgs/ont-hisense-ltf7267-bha+.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ Reboot ONT to apply the change
330330
</div>
331331
</form>
332332

333-
<script type="text/javascript" src="/assets/js/LTF7267-BHA-ploam.js"></script>
333+
<script type="text/javascript" src="/assets/js/generated/LTF7267-BHA-ploam.js"></script>
334334
<script type="text/javascript">
335335
var hisensePloamForm = document.getElementById('hisense-ploam');
336336
var hisenseResult = document.getElementById('ploam-encoded');

assets/js/LTF7267-BHA-ploam.js

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

assets/ts/LTF7267-BHA-ploam.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function hexEncode(str: String): String {
2+
3+
var result = "";
4+
for (let i = 0; i < str.length; i++) {
5+
const hex = str.charCodeAt(i).toString(16);
6+
result += hex.padStart(2, "0");
7+
}
8+
9+
return result;
10+
}
11+
12+
function hisensePloam(ascii_ploam: String): String {
13+
const hex_ploam = hexEncode(ascii_ploam);
14+
const hex_padded_ploam = hex_ploam.padEnd(72, "0");
15+
let array: String[] = [];
16+
for (let i = 0; i < 9; i++) {
17+
const ploam_segment = hex_padded_ploam.slice(i * 8, (i + 1) * 8);
18+
let new_ploam_segment = "";
19+
for (let j = 4; j > 0; j--) {
20+
new_ploam_segment = new_ploam_segment + ploam_segment.slice((j - 1) * 2, j * 2);
21+
}
22+
if (new_ploam_segment !== "00000000") {
23+
array.push("INT CFG_ID_PON_REGISTRATION_ID" + i + " = 0x" + new_ploam_segment + ";");
24+
}
25+
}
26+
return array.join("\n");
27+
}
28+
29+
(window as any).hisensePloam = hisensePloam;

docker-compose.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
version: "3"
1+
version: "3.3"
22

33
services:
4+
typescript:
5+
image: node:20
6+
command: sh -c "cd /mnt && npm ci && npm run build"
7+
restart: on-failure
8+
volumes:
9+
- ./tsup.config.ts:/mnt/tsup.config.ts
10+
- ./package.json:/mnt/package.json
11+
- ./package-lock.json:/mnt/package-lock.json
12+
- ./assets:/mnt/assets
413
site:
5-
command: jekyll serve --verbose --incremental --force_polling
614
image: jekyll/jekyll:latest
15+
command: jekyll serve --verbose --incremental --force_polling --config _config.yml,_config.docker.yml
16+
environment:
17+
- JEKYLL_ENV=docker
718
volumes:
819
- .:/srv/jekyll
920
ports:
1021
- 4000:4000
22+
depends_on:
23+
typescript:
24+
condition: service_completed_successfully
25+

0 commit comments

Comments
 (0)