Skip to content

Commit

Permalink
Merge pull request #1 from AnYiEE/master
Browse files Browse the repository at this point in the history
Update from upstream
  • Loading branch information
ZoruaFox authored Feb 17, 2024
2 parents c98d12e + 439d04a commit ec04676
Show file tree
Hide file tree
Showing 41 changed files with 4,202 additions and 1,784 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
root = true

[*]
charset = utf-8
indent_style = tab
Expand Down
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,37 @@
{
"files": ["*.js"],
"extends": ["plugin:@typescript-eslint/disable-type-checked"]
},
{
"files": ["*.jsx", "*.tsx"],
"extends": ["plugin:react/recommended", "plugin:react/jsx-runtime"],
"rules": {
"arrow-body-style": ["error", "as-needed"],
"class-methods-use-this": [
"error",
{
"exceptMethods": [
"forceUpdate",
"getDefaultProps",
"getInitialState",
"isMounted",
"render",
"replaceState",
"setState"
]
}
],
"func-style": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"varsIgnorePattern": "^_|^React$"
}
],
"react/no-unknown-property": "off"
}
}
],
"rules": {
Expand Down Expand Up @@ -177,6 +208,8 @@
"jsdoc/check-tag-names": "off",
"jsdoc/no-undefined-types": "off",

"mediawiki/class-doc": "warn",

"no-jquery/no-animate": [
"warn",
{
Expand Down Expand Up @@ -241,5 +274,10 @@
"avoidEscape": true
}
]
},
"settings": {
"react": {
"version": "detect"
}
}
}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dist/*
!dist/store.txt
node_modules
scripts/credentials.json
.*cache
7 changes: 4 additions & 3 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"*.{css,less}": ["prettier --write", "stylelint --fix"],
"*.{cjs,js,ts}": ["prettier --write", "eslint --fix"],
"*": "prettier --ignore-unknown --write"
"*.{css,less}": ["prettier --write", "stylelint --allow-empty-input --fix"],
"*.{cjs,mjs,js,jsx,ts,tsx}": ["prettier --write", "eslint --fix"],
"*.json": "tsx --no-deprecation scripts/run.ts --format-json - ",
"!*.{css,less,cjs,mjs,js,jsx,ts,tsx,json}": "prettier --ignore-unknown --write"
}
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5",
"useTabs": true
"useTabs": true,
"overrides": [
{
"files": ".eslintrc",
"options": {
"parser": "json"
}
}
]
}
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
78 changes: 78 additions & 0 deletions .vscode/json-schemas/credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "登录凭据 / Login credentials",
"type": "object",
"additionalProperties": {
"title": "站点名称 / Site name",
"type": "object",
"oneOf": [
{
"type": "object",
"properties": {
"apiUrl": {
"type": "string",
"minLength": 1
},
"OAuthCredentials": {
"type": "object",
"properties": {
"accessToken": {
"type": "string",
"minLength": 1
},
"accessSecret": {
"type": "string",
"minLength": 1
},
"consumerToken": {
"type": "string",
"minLength": 1
},
"consumerSecret": {
"type": "string",
"minLength": 1
}
},
"required": ["accessToken", "accessSecret", "consumerToken", "consumerSecret"]
}
},
"additionalProperties": false,
"required": ["apiUrl", "OAuthCredentials"]
},
{
"type": "object",
"properties": {
"apiUrl": {
"type": "string",
"minLength": 1
},
"OAuth2AccessToken": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false,
"required": ["apiUrl", "OAuth2AccessToken"]
},
{
"type": "object",
"properties": {
"apiUrl": {
"type": "string",
"minLength": 1
},
"username": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false,
"required": ["apiUrl", "username", "password"]
}
]
}
}
46 changes: 34 additions & 12 deletions .vscode/json-schemas/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
"title": "是否启用当前小工具 / Enable current gadget or not",
"default": true
},
"excludeSites": {
"type": "array",
"title": "在给定站点上禁用当前小工具 / Disable the current gadget on given sites",
"default": [],
"items": {
"type": "string",
"minLength": 1
},
"minItems": 1
},
"description": {
"type": "string",
"title": "“MediaWiki:Gadget-小工具名”页面中的文本,默认为当前小工具名 / The content in the page 'MediaWiki:Gadget-${gadgetName}' (default: the current gadget name)"
Expand All @@ -23,15 +33,19 @@
"type": "array",
"default": [],
"items": {
"type": "string"
}
"type": "string",
"minLength": 1
},
"minItems": 1
},
"contentModels": {
"type": "array",
"default": [],
"items": {
"type": "string"
}
"type": "string",
"minLength": 1
},
"minItems": 1
},
"default": {
"type": "boolean",
Expand All @@ -41,8 +55,10 @@
"type": "array",
"default": [],
"items": {
"type": "string"
}
"type": "string",
"minLength": 1
},
"minItems": 1
},
"hidden": {
"type": "boolean",
Expand All @@ -53,28 +69,34 @@
"default": [],
"items": {
"type": "number"
}
},
"minItems": 1
},
"peers": {
"type": "array",
"default": [],
"items": {
"type": "string"
}
"type": "string",
"minLength": 1
},
"minItems": 1
},
"rights": {
"type": "array",
"default": [],
"items": {
"type": "string"
}
"type": "string",
"minLength": 1
},
"minItems": 1
},
"skins": {
"type": "array",
"default": [],
"items": {
"type": "string"
}
},
"minItems": 1
},
"supportsUrlLoad": {
"type": "boolean",
Expand Down
33 changes: 33 additions & 0 deletions .vscode/json-schemas/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": {
"title": "站点名称 / Site name",
"type": "object",
"patternProperties": {
"^(?![Gg]adget-).+\\.(css|js)$": {
"type": "object",
"title": "直接部署的页面(仅支持 CSS 或 JavaScript)/ Global Pages (only allow CSS or JavaScript)",
"properties": {
"enable": {
"type": "boolean",
"title": "是否部署当前页面 / Deploy current page or not",
"default": true
},
"sourceCode": {
"type": "string",
"title": "页面内容(脚本仅支持 ES5 语法)/ Page content (only supports ES5 syntax)",
"minLength": 1
},
"licenseText": {
"type": "string",
"title": "页面内容的许可声明 / License declaration of the page content",
"minLength": 1
}
},
"required": ["enable", "sourceCode"]
}
},
"additionalProperties": false
}
}
28 changes: 26 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
},
"editor.renderWhitespace": "all",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.stickyScroll.enabled": true,
"git.autoStash": true,
"git.allowForcePush": true,
"terminal.integrated.scrollback": 10000,
"eslint.enable": true,
"eslint.format.enable": true,
"prettier.enable": true,
Expand All @@ -30,9 +32,21 @@
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[tsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down Expand Up @@ -65,13 +79,23 @@
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
"package.json": ".*cache, .*ignore, .*rc, .editorConfig, .git*, pnpm-lock.yaml, tsconfig.json, LICENCE",
"package.json": ".*cache, .*ignore, .*rc, .editorConfig, .git*, pnpm-lock.yaml, tsconfig.json, LICENSE",
"readme*": "*.md"
},
"json.schemas": [
{
"fileMatch": ["scripts/credentials.json"],
"url": "./.vscode/json-schemas/credentials.json"
},
{
"fileMatch": ["src/*/definition.json"],
"url": "./.vscode/json-schemas/definition.json"
},
{
"fileMatch": ["src/global.json"],
"url": "./.vscode/json-schemas/global.json"
}
]
],
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": "./node_modules/typescript/lib"
}
File renamed without changes.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@

### 简介 / Introduction

Awesome Gadgets 是面向 MediaWiki 网站,用以统一存储、管理并编译全站小工具(Gadget)的工具。小工具开发者只需关心小工具本身的代码实现,无需关心其他方面。工具将自动检查语法、编译并部署到网站。<br>_Awesome Gadgets_ is a tool designed specifically for MediaWiki websites, with the goal of centralizing the storage, management, and compilation of all site-wide gadgets. Developers of these gadgets can solely focus on implementing the code for their creations without the need to worry about other aspects. The tool will automatically check the syntax, compile, and deploy gadgets to the website.

- 使用 esbuild 编译,babel 转译,支持 TypeScript 和 Less<br>It harnesses esbuild for compilation, babel for transpilation, and supports TypeScript and Less
- 部署时将自动部署<br>During deployment, it automatically deploys to the following
Awesome Gadgets 是面向 MediaWiki 网站,用以统一存储、管理并编译全站小工具(Gadget)的工具。小工具开发者只需关心小工具本身的代码实现,无需关心其他方面。工具将自动检查语法、编译并部署到网站。<br>_Awesome Gadgets_ is a tool designed specifically for MediaWiki websites, with the goal of centralizing the storage, management, and compilation of all site-wide CSS/JavaScript and their peer pages. Developers of these gadgets can solely focus on implementing the code for their creations without the need to worry about other aspects. The tool will automatically check the syntax, compile, and deploy gadgets to the website.

- 使用 esbuild 编译,通过 Babel 转译现代语法以获得良好的浏览器兼容性<br>Compile using esbuild and transpile modern syntax with Babel for good browser compatibility
- 可以编写 TypeScript 和 Less,支持 CSS 和 Less 模块,可以使用 JSX 和 TSX 组件<br>Support writing files in TypeScript and Less, support CSS/Less modules and use JSX/TSX components
-[文档](docs/how-to-use-jsx-and-tsx-with-jsxdom.md)。<br>See [documentation](docs/how-to-use-jsx-and-tsx-with-jsxdom.md)
- 支持引用 ResourceLoader 模块<br>Support requiring ResourceLoader built-in modules
-[文档](docs/how-to-use-exports-and-require-in-mediawiki.md)。<br>See [documentation](docs/how-to-use-exports-and-require-in-mediawiki.md)
- 支持向多个站点部署并独立控制启用与否<br>Support deploying to multiple sites and independently control whether to enable/disable them
- 自动部署<br>Automatic deployment
- `MediaWiki:Gadgets-definition`
- `MediaWiki:Gadget-section-*`(支持自动转换中文变体)/ (with automatic conversion for Chinese variations)
- `MediaWiki:Gadget-*`(支持自动转换中文变体)/ (with automatic conversion for Chinese variations)
- `MediaWiki:Gadget-*.{js, css}`
- 部署后将自动从网站内删除曾经部署过但现在不再需要的页面<br>After deployment, it automatically deletes pages from the website that have been deployed but are no longer needed
- `MediaWiki:Gadget-section-*`(支持自动转换中文变体)/ (with automatic conversion of Chinese variations)
- `MediaWiki:Gadget-*`(支持自动转换中文变体)/ (with automatic conversion of Chinese variations)
- `MediaWiki:*.{js, css}`
- 自动从网站内删除曾经部署过但现在不再需要的页面<br>Automatically delete pages that have been deployed on the website but are no longer needed

### 用法 / Usage

Expand Down
Loading

0 comments on commit ec04676

Please sign in to comment.