Skip to content

Commit 3253bb4

Browse files
TechQuerysepts
andauthored
add Proposal data & Web-site framework (#1)
* [add] ECMAScript Proposal crawler * [add] PWA framework based on WebCell v2 * [add] Main & Proposal pages * [add] TC39 Members of China * [add] JSCIG members Co-authored-by: Septs <[email protected]>
1 parent a1b6320 commit 3253bb4

21 files changed

+1045
-1
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI & CD
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
Build-and-Deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Use Node.js
16+
uses: actions/setup-node@v2-beta
17+
with:
18+
node-version: '12'
19+
- name: Install & build
20+
run: |
21+
npm install
22+
npm run build
23+
- name: Deploy
24+
uses: peaceiris/actions-gh-pages@v3
25+
with:
26+
publish_dir: ./dist
27+
personal_token: ${{ secrets.GITHUB_TOKEN }}
28+
force_orphan: true

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
package-lock.json
3+
yarn.lock
4+
.cache/
5+
dist/
6+
.vscode/

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# JavaScript Chinese Interest Group
22

3-
JavaScript中文讨论组致力于提供一个加强中国JavaScript社区对JavaScript语言标准(ECMAScript)工作的参与的平台。本讨论组主要侧重于确定中国JavaScript开发者的需求、帮助Ecma的中国成员熟悉TC39标准流程、讨论可能提交给TC39的提案、标准的测试、实现以及和JavaScript相关的标准化机会,同时协助中国JavaScript社区对JavaScript语言的发展进行参与和贡献。
3+
[![NPM Dependency](https://david-dm.org/JSCIG/jscig.github.io.svg)][1]
4+
[![CI & CD](https://github.com/JSCIG/jscig.github.io/workflows/CI%20&%20CD/badge.svg)][2]
5+
6+
JavaScript 中文讨论组致力于提供一个加强中国 JavaScript 社区对 JavaScript 语言标准(ECMAScript)工作的参与的平台。
7+
8+
本讨论组主要侧重于确定中国 JavaScript 开发者的需求、帮助 Ecma 的中国成员熟悉 TC39 标准流程、讨论可能提交给 TC39 的提案、标准的测试、实现以及和 JavaScript 相关的标准化机会,同时协助中国 JavaScript 社区对 JavaScript 语言的发展进行参与和贡献。
49

510
- [讨论](https://github.com/JSCIG/es-discuss/issues)
11+
12+
## 官网开发
13+
14+
本网站是一个基于 [WebCell v2](https://web-cell.dev/) 的纯 Web 前端项目,参与开发的基本命令如下:
15+
16+
```shell
17+
cd ~/Desktop
18+
git clone https://github.com/JSCIG/jscig.github.io.git ./JSCIG
19+
cd ./JSCIG
20+
npm install
21+
npm start
22+
```
23+
24+
[1]: https://david-dm.org/JSCIG/jscig.github.io
25+
[2]: https://github.com/JSCIG/jscig.github.io/actions

package.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"name": "@jscig/ows",
3+
"version": "0.5.0",
4+
"private": true,
5+
"license": "UNLICENSED",
6+
"description": "Official Web site of JavaScript Chinese Interest Group",
7+
"author": "[email protected]",
8+
"homepage": "https://jscig.github.io/",
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/JSCIG/jscig.github.io.git"
12+
},
13+
"bugs": {
14+
"url": "https://github.com/JSCIG/jscig.github.io/issues"
15+
},
16+
"main": "source/index.html",
17+
"dependencies": {
18+
"boot-cell": "^1.1.1",
19+
"bootstrap-icons": "^1.0.0",
20+
"browser-unhandled-rejection": "^1.0.2",
21+
"cell-router": "^2.0.1",
22+
"classnames": "^2.2.6",
23+
"koajax": "^0.6.2",
24+
"mobx": "^5.15.7",
25+
"mobx-web-cell": "^0.3.2",
26+
"web-cell": "^2.2.0",
27+
"web-utility": "^1.8.0"
28+
},
29+
"devDependencies": {
30+
"@types/classnames": "^2.2.10",
31+
"autoprefixer": "^9.8.6",
32+
"husky": "^4.3.0",
33+
"less": "^3.12.2",
34+
"lint-staged": "^10.4.0",
35+
"parcel": "^1.12.4",
36+
"postcss-modules": "^3.2.2",
37+
"prettier": "^2.1.2",
38+
"typescript": "^4.0.3",
39+
"workbox-cli": "^4.3.1"
40+
},
41+
"prettier": {
42+
"singleQuote": true,
43+
"trailingComma": "none",
44+
"arrowParens": "avoid"
45+
},
46+
"lint-staged": {
47+
"*.{html,md,css,less,json,yml,js,ts,tsx}": [
48+
"prettier --write"
49+
]
50+
},
51+
"postcss": {
52+
"modules": true,
53+
"plugins": {
54+
"autoprefixer": {
55+
"grid": true
56+
}
57+
}
58+
},
59+
"scripts": {
60+
"test": "lint-staged",
61+
"start": "workbox generateSW && parcel source/index.html --open",
62+
"pack-dist": "parcel build source/index.html --public-url .",
63+
"pack-sw": "rm -f dist/sw.js.map && workbox generateSW",
64+
"build": "rm -rf dist/ && npm run pack-dist && npm run pack-sw"
65+
},
66+
"husky": {
67+
"hooks": {
68+
"pre-commit": "npm test",
69+
"pre-push": "npm run build"
70+
}
71+
}
72+
}

source/component/FilterLink.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createCell } from 'web-cell';
2+
3+
import { BadgeProps, Badge } from 'boot-cell/source/Reminder/Badge';
4+
5+
export interface FilterLinkProps extends BadgeProps {
6+
type?: 'anchor' | 'badge';
7+
path: string;
8+
filter: string;
9+
value: any;
10+
}
11+
12+
export function FilterLink({
13+
type = 'anchor',
14+
filter,
15+
value,
16+
defaultSlot,
17+
...rest
18+
}: FilterLinkProps) {
19+
const Link = type === 'anchor' ? 'a' : Badge;
20+
21+
return (
22+
<Link {...rest} href={`proposals?${filter}=${value}`}>
23+
{defaultSlot[0] ? defaultSlot : value}
24+
</Link>
25+
);
26+
}

source/data/crawler.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// >>> ECMAScript Proposal crawler <<<
2+
//
3+
// [Data source] https://github.com/tc39/proposals
4+
//
5+
// [Example code] copy(JSON.stringify(getProposals(3, $0), null, 4))
6+
//
7+
// (c)2020 @TechQuery @JSCIG
8+
9+
function getNames({ childNodes }) {
10+
return Array.from(
11+
childNodes,
12+
({ nodeType, nodeValue }) => nodeType === 3 && nodeValue
13+
).filter(Boolean);
14+
}
15+
16+
function getProposals(stage, { children }) {
17+
return Array.from(children, ({ children }) => {
18+
const repository = children[0].firstElementChild,
19+
timestamp = (stage === 3 ? children[4] : children[3])?.firstElementChild;
20+
21+
return {
22+
stage,
23+
name: repository.textContent,
24+
link: repository.href,
25+
authors: getNames(children[1]),
26+
champions: getNames(children[2]),
27+
test_link: stage === 3 ? children[3].firstElementChild.href : undefined,
28+
meeting_link: timestamp?.href,
29+
updated_at: timestamp?.textContent,
30+
published_at: stage === 4 ? children[4].textContent : undefined
31+
};
32+
});
33+
}

source/data/members-china.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[
2+
{
3+
"name": "360 技术集团",
4+
"logo": "https://p3.ssl.qhimg.com/t011e94f0b9ed8e66b0.png",
5+
"link": "https://www.360.cn/"
6+
},
7+
{
8+
"name": "阿里巴巴集团",
9+
"logo": "https://docs.alibabagroup.com/assets2/images/cn/global/logo_header.png",
10+
"link": "https://www.alibabagroup.com/"
11+
},
12+
{
13+
"name": "腾讯",
14+
"logo": "https://www.tencent.com/img/index/tencent_logo.png",
15+
"link": "https://www.tencent.com/"
16+
},
17+
{
18+
"name": "华为技术",
19+
"logo": "https://www-file.huawei.com/-/media/corporate/images/home/logo/huawei_logo.png",
20+
"link": "https://www.huawei.com/"
21+
},
22+
{
23+
"name": "Sujitech",
24+
"logo": "https://www.ecma-international.org/images/members/SPC/Sujitech%20logo.gif",
25+
"link": "https://sujitech.com/"
26+
}
27+
]

source/global.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.less' {
2+
const map: Record<string, string>;
3+
export default map;
4+
}

source/index.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<meta
5+
name="viewport"
6+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
7+
/>
8+
<link rel="icon" href="https://github.com/JSCIG.png" />
9+
<title>JavaScript 中文兴趣组</title>
10+
<meta name="description" content="JavaScript Chinese Interest Group" />
11+
<meta name="author" content="[email protected]" />
12+
13+
<link rel="manifest" href="index.webmanifest" />
14+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/pwacompat.min.js"></script>
15+
<link
16+
rel="stylesheet"
17+
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
18+
/>
19+
<script
20+
crossorigin
21+
src="https://polyfill.app/api/polyfill?features=es.string.match-all,es.array.flat,es.object.from-entries"
22+
></script>
23+
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/[email protected]/custom-elements-es5-adapter.js"></script>
24+
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/[email protected]/webcomponents-bundle.min.js"></script>
25+
26+
<script src="index.tsx" async></script>
27+
</head>
28+
<body></body>
29+
</html>

source/index.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { auto } from 'browser-unhandled-rejection';
2+
import { serviceWorkerUpdate } from 'web-utility';
3+
import { documentReady, render, createCell } from 'web-cell';
4+
5+
import { PageFrame } from './page';
6+
7+
auto();
8+
9+
self.addEventListener('unhandledrejection', event => {
10+
const { message } = event.reason;
11+
12+
if (!message) return;
13+
14+
event.preventDefault();
15+
16+
self.alert(message);
17+
});
18+
19+
const { serviceWorker } = window.navigator;
20+
21+
serviceWorker
22+
?.register('sw.js')
23+
.then(serviceWorkerUpdate)
24+
.then(worker => {
25+
if (window.confirm('检测到新版本,是否立即启用?'))
26+
worker.postMessage({ type: 'SKIP_WAITING' });
27+
});
28+
29+
serviceWorker?.addEventListener('controllerchange', () =>
30+
window.location.reload()
31+
);
32+
33+
documentReady.then(() => render(<PageFrame />));

0 commit comments

Comments
 (0)