Skip to content

Commit

Permalink
なんかめっちゃ変えた
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaina committed Dec 30, 2023
1 parent 67909d3 commit 7902ded
Show file tree
Hide file tree
Showing 22 changed files with 1,609 additions and 173 deletions.
122 changes: 122 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: [
'@typescript-eslint',
'import'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript'
],
rules: {
'indent': ['warn', 'tab', {
'SwitchCase': 1,
'MemberExpression': 1,
'flatTernaryExpressions': true,
'ArrayExpression': 'first',
'ObjectExpression': 'first',
}],
'eol-last': ['error', 'always'],
'semi': ['error', 'always'],
'semi-spacing': ['error', { 'before': false, 'after': true }],
'quotes': ['warn', 'single'],
'comma-dangle': ['warn', 'always-multiline'],
'comma-spacing': ['error', { 'before': false, 'after': true }],
'array-bracket-spacing': ['error', 'never'],
'keyword-spacing': ['error', {
'before': true,
'after': true,
}],
'key-spacing': ['error', {
'beforeColon': false,
'afterColon': true,
}],
'arrow-spacing': ['error', {
'before': true,
'after': true,
}],
'brace-style': ['error', '1tbs', {
'allowSingleLine': true,
}],
'padded-blocks': ['error', 'never'],
/* TODO: path aliasを使わないとwarnする
'no-restricted-imports': ['warn', {
'patterns': [
]
}],
*/
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'no-multi-spaces': ['error'],
'no-var': ['error'],
'prefer-arrow-callback': ['error'],
'no-throw-literal': ['error'],
'no-param-reassign': ['warn'],
'no-constant-condition': ['warn'],
'no-empty-pattern': ['warn'],
'no-async-promise-executor': ['off'],
'no-useless-escape': ['off'],
'no-multiple-empty-lines': ['error', { 'max': 1 }],
'no-control-regex': ['warn'],
'no-empty': ['warn'],
'no-inner-declarations': ['off'],
'no-sparse-arrays': ['off'],
'nonblock-statement-body-position': ['error', 'beside'],
'object-curly-spacing': ['error', 'always'],
'space-infix-ops': ['error'],
'space-before-blocks': ['error', 'always'],
'padding-line-between-statements': [
'error',
{ 'blankLine': 'always', 'prev': 'function', 'next': '*' },
{ 'blankLine': 'always', 'prev': '*', 'next': 'function' },
],
"lines-between-class-members": "off",
/* typescript-eslint では enforce に対応してないっぽい
'@typescript-eslint/lines-between-class-members': ['error', {
enforce: [{
blankLine: 'always',
prev: 'method',
next: '*',
}]
}],
*/
'@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/no-unnecessary-condition': ['warn'],
'@typescript-eslint/no-var-requires': ['warn'],
'@typescript-eslint/no-inferrable-types': ['warn'],
'@typescript-eslint/no-empty-function': ['off'],
'@typescript-eslint/no-non-null-assertion': ['warn'],
'@typescript-eslint/explicit-function-return-type': ['off'],
'@typescript-eslint/no-misused-promises': ['error', {
'checksVoidReturn': false,
}],
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/prefer-nullish-coalescing': [
'warn',
],
'@typescript-eslint/naming-convention': [
'error',
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "typeParameter",
"format": []
}
],
'import/no-unresolved': ['off'],
'import/no-default-export': ['warn'],
'import/order': ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
}]
},
};
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.10.0]

steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install
run: |
corepack enable
pnpm i --frozen-lockfile
- name: eslint
run: |
pnpm eslint
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
run: |
corepack enable
pnpm i --frozen-lockfile
- name: Build
run: |
pnpm build
- name: Test
run: |
Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
npm-debug.log
gulpfile.js
tsconfig.json
tslint.json
.eslintrc.cjs
.editorconfig
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
4.1.0 / 2023-12-30
------------------
* branch.ioを用いたディープリンク(spotify.link)などでパースに失敗する問題を修正
* 'mixi:content-rating'をsensitive判定で見ることで、dlsiteなどでセンシティブ情報を得れるように
5.0.0 / 2023-12-30
------------------
* support `<link rel="alternate" type="application/activitypub+json" href="{href}">` https://github.com/misskey-dev/summaly/pull/10, https://github.com/misskey-dev/summaly/pull/11
* 結果の`activityPub`プロパティでherfの内容を取得できます
* branch.ioを用いたディープリンク(spotify.link)などでパースに失敗する問題を修正 https://github.com/misskey-dev/summaly/pull/13
* Twitter Cardが読めていない問題を修正 https://github.com/misskey-dev/summaly/pull/15
* 'mixi:content-rating'をsensitive判定で見ることで、dlsiteなどでセンシティブ情報を得れるように https://github.com/misskey-dev/summaly/pull/16
* sitenameをURLから生成する場合、ポートを含むように (URL.hostname → URL.host)
* `Summary`型に`url`プロパティを追加した`SummalyResult`型をexportするように
* `IPlugin`インターフェースを`SummalyPlugin`に改称

4.0.2 / 2023-04-20
------------------
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-2019 syuilo
Copyright (c) 2016-2024 syuilo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ npm run build
npm run serve
```

### Options
#### opts (SummalyOptions)

| Property | Type | Description | Default |
| :------------------ | :--------------------- | :------------------------------ | :------ |
Expand All @@ -53,7 +53,7 @@ npm run serve
#### Plugin

``` typescript
interface IPlugin {
interface SummalyPlugin {
test: (url: URL) => boolean;
summarize: (url: URL) => Promise<Summary>;
}
Expand All @@ -76,26 +76,31 @@ A Promise of an Object that contains properties below:

※ Almost all values are nullable. player should not be null.

#### Root
#### SummalyResult

| Property | Type | Description |
| :-------------- | :------- | :------------------------------------------ |
| **title** | *string* | The title of the web page |
| **icon** | *string* | The url of the icon of the web page |
| **description** | *string* | The description of the web page |
| **thumbnail** | *string* | The url of the thumbnail of the web page |
| **title** | *string* \| *null* | The title of the web page |
| **icon** | *string* \| *null* | The url of the icon of the web page |
| **description** | *string* \| *null* | The description of the web page |
| **thumbnail** | *string* \| *null* | The url of the thumbnail of the web page |
| **sitename** | *string* \| *null* | The name of the web site |
| **player** | *Player* | The player of the web page |
| **sitename** | *string* | The name of the web site |
| **sensitive** | *boolean* | Whether the url is sensitive |
| **activityPub** | *string* \| *null* | The url of the ActivityPub representation of that web page |
| **url** | *string* | The url of the web page |

#### Summary

`Omit<SummalyResult, "url">`

#### Player

| Property | Type | Description |
| :-------------- | :--------- | :---------------------------------------------- |
| **url** | *string* | The url of the player |
| **width** | *number* | The width of the player |
| **height** | *number* | The height of the player |
| **url** | *string* \| *null* | The url of the player |
| **width** | *number* \| *null* | The width of the player |
| **height** | *number* \| *null* | The height of the player |
| **allow** | *string[]* | The names of the allowed permissions for iframe |

Currently the possible items in `allow` are:
Expand All @@ -105,6 +110,7 @@ Currently the possible items in `allow` are:
* `fullscreen`
* `encrypted-media`
* `picture-in-picture`
* `web-share`

See [Permissions Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy) in MDN for details of them.

Expand All @@ -123,7 +129,7 @@ will be ... ↓
```json
{
"title": "【アイドルマスター】「Stage Bye Stage」(歌:島村卯月、渋谷凛、本田未央)",
"icon": "https://www.youtube.com/s/desktop/9318de79/img/favicon.ico",
"icon": "https://www.youtube.com/s/desktop/28b0985e/img/favicon.ico",
"description": "Website▶https://columbia.jp/idolmaster/Playlist▶https://www.youtube.com/playlist?list=PL83A2998CF3BBC86D2018年7月18日発売予定THE IDOLM@STER CINDERELLA GIRLS CG STAR...",
"thumbnail": "https://i.ytimg.com/vi/NMIEAhH_fTU/maxresdefault.jpg",
"player": {
Expand All @@ -135,11 +141,13 @@ will be ... ↓
"clipboard-write",
"encrypted-media",
"picture-in-picture",
"web-share"
"web-share",
"fullscreen",
]
},
"sitename": "YouTube",
"sensitive": false,
"activityPub": null,
"url": "https://www.youtube.com/watch?v=NMIEAhH_fTU"
}
```
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"scripts": {
"build": "tsc",
"eslint": "eslint --quiet \"src/**/*.ts\"",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --silent=false --verbose false",
"serve": "fastify start ./built/index.js"
},
Expand All @@ -27,7 +28,11 @@
"@types/debug": "4.1.7",
"@types/escape-regexp": "^0.0.1",
"@types/node": "20.10.6",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"debug": "^4.3.4",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"fastify": "^4.25.2",
"fastify-cli": "^5.9.0",
"jest": "^29.7.0",
Expand Down
Loading

0 comments on commit 7902ded

Please sign in to comment.