Skip to content

Commit 2ffc0d6

Browse files
committed
Deploy to Github Pages
1 parent 5ea4300 commit 2ffc0d6

File tree

9 files changed

+193
-155
lines changed

9 files changed

+193
-155
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
deploy:
15+
environment:
16+
name: github-pages
17+
url: ${{steps.deployment.outputs.page_url}}
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 24
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: |
31+
npm install
32+
33+
- name: Process UCD XML to JSON
34+
run: |
35+
./bin/ucd_download.sh
36+
./bin/ucd_to_json.ts
37+
38+
- name: Build
39+
run: |
40+
npm run build
41+
42+
- name: Upload Artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: ./dist
46+
47+
- name: Deploy GitHub Pages
48+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dist
2+
.DS_Store
23
.env
34
*.env
45
*.log

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ See it in action: [unicodesear.ch](https://unicodesear.ch)
1010
[![Bootstrap](https://www.vectorlogo.zone/logos/getbootstrap/getbootstrap-ar21.svg)](https://getbootstrap.com/ "HTML/CSS Framework")
1111
[![Git](https://www.vectorlogo.zone/logos/git-scm/git-scm-ar21.svg)](https://git-scm.com/ "Version control")
1212
[![Github](https://www.vectorlogo.zone/logos/github/github-ar21.svg)](https://gitlab.com/ "Code hosting")
13+
[![Google Noto Emoji](https://www.vectorlogo.zone/logos/google/google-ar21.svg)](https://github.com/googlefonts/noto-emoji/blob/43f47be9404018cd9d8f73a227363a8f20acdab5/svg/emoji_u1f984.svg "Icon")
1314
[![Node.js](https://www.vectorlogo.zone/logos/nodejs/nodejs-ar21.svg)](https://nodejs.org/ "Application Server")
1415
[![npm](https://www.vectorlogo.zone/logos/npmjs/npmjs-ar21.svg)](https://www.npmjs.com/ "JS Package Management")
1516
[![Unicode](https://www.vectorlogo.zone/logos/unicode/unicode-ar21.svg)](https://www.unicode.org/Public/17.0.0/ucdxml/ "Unicode Character Database")
@@ -18,3 +19,21 @@ See it in action: [unicodesear.ch](https://unicodesear.ch)
1819
[![VectorLogoZone](https://www.vectorlogo.zone/logos/vectorlogozone/vectorlogozone-ar21.svg)](https://www.vectorlogo.zone/ "Logos")
1920
[![Vite](https://www.vectorlogo.zone/logos/vitejsdev/vitejsdev-ar21.svg)](https://vitejs.dev/ "Bundler")
2021

22+
## To Do
23+
24+
- [ ] U+ prefix on codepoints
25+
- [ ] name sort not working
26+
- [ ] numeric search for codepoints
27+
- [ ] codepoint sort should be numeric
28+
- [ ] preview column (SVGs)
29+
- [ ] preview column (font)
30+
- [ ] copy to clipboard button
31+
- [ ] test dark mode
32+
- [ ] share links in footer
33+
- [ ] test responsive layout
34+
- [ ] expand category abbreviations
35+
- [ ] category search: 2 char=>use abbreviation, 3+ char=>search full name
36+
- [ ] name search
37+
- [ ] tips for name search
38+
- [ ] tags: bidi, emoji, letter, number, punctuation, symbol, whitespace
39+
- [ ] tag filters

bin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

bin/ucd_download.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Download and unzip the Unicode Character Database XML file
4+
# from Unicode.org.
5+
#
6+
7+
set -o nounset
8+
set -o errexit
9+
set -o pipefail
10+
11+
SCRIPT_HOME="$( cd "$( dirname "$0" )" && pwd )"
12+
BASE_DIR=$(realpath "${SCRIPT_HOME}/..")
13+
14+
echo "INFO: starting download at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
15+
16+
TMP_DIR="${BASE_DIR}/tmp"
17+
if [ ! -d "${TMP_DIR}" ]; then
18+
echo "INFO: creating temp dir ${TMP_DIR}"
19+
mkdir -p "${TMP_DIR}"
20+
else
21+
echo "INFO: using existing temp dir ${TMP_DIR}"
22+
fi
23+
24+
curl \
25+
--location \
26+
--output "${TMP_DIR}/ucd.all.flat.zip" \
27+
--show-error \
28+
--silent \
29+
https://www.unicode.org/Public/latest/ucdxml/ucd.all.flat.zip
30+
31+
cd "${TMP_DIR}"
32+
unzip ucd.all.flat.zip
33+
34+
echo "INFO: completed download at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"

bin/ucd_to_json.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env node
2+
3+
import fs from 'fs/promises';
4+
import path from 'path';
5+
import { XMLParser } from 'fast-xml-parser';
6+
import { fileURLToPath } from "url";
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
11+
type SearchEntry = {
12+
code: string;
13+
name: string;
14+
age: string;
15+
block: string;
16+
category: string;
17+
}
18+
19+
type SearchData = {
20+
success: boolean;
21+
data: SearchEntry[];
22+
}
23+
24+
async function main() {
25+
console.log(`INFO: starting at ${new Date().toISOString()}`);
26+
27+
const xmlPath = path.join( __dirname, '..', 'tmp', 'ucd.all.flat.xml' );
28+
const jsonPath = path.join( __dirname, '..', 'public', 'ucd.json' );
29+
30+
try {
31+
await fs.access(xmlPath);
32+
} catch (err) {
33+
console.log(`INFO: XML file does not exist in ${xmlPath}`);
34+
process.exit(1);
35+
}
36+
37+
// Read and parse the XML file
38+
console.log(`INFO: reading XML file from ${xmlPath}`);
39+
const xmlData = await fs.readFile(xmlPath, 'utf-8');
40+
console.log(`INFO: parsing XML data`);
41+
const parser = new XMLParser({
42+
ignoreAttributes: false,
43+
attributeNamePrefix: '',
44+
});
45+
const jsonObj = parser.parse(xmlData);
46+
47+
const entries: SearchEntry[] = [];
48+
49+
for (const charData of jsonObj.ucd.repertoire.char) {
50+
entries.push({
51+
code: charData.cp,
52+
name: charData.na || charData.na1,
53+
age: charData.age,
54+
block: charData.blk,
55+
category: charData.gc,
56+
});
57+
}
58+
59+
const output: SearchData = {
60+
success: true,
61+
data: entries,
62+
};
63+
64+
// Write the JSON data to a file
65+
console.log(`INFO: writing JSON data to ${jsonPath}`);
66+
await fs.writeFile(jsonPath, JSON.stringify(output, null, 2), 'utf-8');
67+
console.log(`INFO: wrote JSON data to ${jsonPath}`);
68+
}
69+
70+
71+
72+
main().then( () => {
73+
console.log(`INFO: complete at ${new Date().toISOString()}`);
74+
});

0 commit comments

Comments
 (0)