mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-31 18:37:34 +09:00
Follow lint
This commit is contained in:
parent
9374664cbc
commit
2b01979fb2
@ -1,10 +1,11 @@
|
|||||||
import * as URL from 'url';
|
import * as URL from 'url';
|
||||||
|
|
||||||
import * as client from 'cheerio-httpcli';
|
import * as client from 'cheerio-httpcli';
|
||||||
|
import summary from '../summary';
|
||||||
|
|
||||||
client.set('referer', false);
|
client.set('referer', false);
|
||||||
client.set('timeout', 10000);
|
client.set('timeout', 10000);
|
||||||
|
|
||||||
export function test(url: URL.Url) {
|
export function test(url: URL.Url): boolean {
|
||||||
return url.hostname === 'www.amazon.com' ||
|
return url.hostname === 'www.amazon.com' ||
|
||||||
url.hostname === 'www.amazon.co.jp' ||
|
url.hostname === 'www.amazon.co.jp' ||
|
||||||
url.hostname === 'www.amazon.ca' ||
|
url.hostname === 'www.amazon.ca' ||
|
||||||
@ -18,10 +19,10 @@ export function test(url: URL.Url) {
|
|||||||
url.hostname === 'www.amazon.nl' ||
|
url.hostname === 'www.amazon.nl' ||
|
||||||
url.hostname === 'www.amazon.cn' ||
|
url.hostname === 'www.amazon.cn' ||
|
||||||
url.hostname === 'www.amazon.in' ||
|
url.hostname === 'www.amazon.in' ||
|
||||||
url.hostname === 'www.amazon.au'
|
url.hostname === 'www.amazon.au';
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function summarize(url: URL.Url) {
|
export async function summarize(url: URL.Url): Promise<summary> {
|
||||||
const res = await client.fetch(url.href);
|
const res = await client.fetch(url.href);
|
||||||
const $ = res.$;
|
const $ = res.$;
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import * as URL from 'url';
|
import * as URL from 'url';
|
||||||
import * as request from 'request';
|
import * as request from 'request';
|
||||||
import * as debug from 'debug';
|
import * as debug from 'debug';
|
||||||
|
import summary from '../summary';
|
||||||
import clip from './../utils/clip';
|
import clip from './../utils/clip';
|
||||||
|
|
||||||
const log = debug('summaly:plugins:wikipedia');
|
const log = debug('summaly:plugins:wikipedia');
|
||||||
|
|
||||||
export function test(url: URL.Url) {
|
export function test(url: URL.Url): boolean {
|
||||||
return /\.wikipedia\.org$/.test(url.hostname);
|
return /\.wikipedia\.org$/.test(url.hostname);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function summarize(url: URL.Url) {
|
export function summarize(url: URL.Url): Promise<summary> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
const lang = url.host.split('.')[0];
|
const lang = url.host.split('.')[0];
|
||||||
const title = url.pathname.split('/')[2];
|
const title = url.pathname.split('/')[2];
|
||||||
|
@ -23,6 +23,6 @@ type Summary = {
|
|||||||
* The title of that web page
|
* The title of that web page
|
||||||
*/
|
*/
|
||||||
title: string;
|
title: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Summary;
|
export default Summary;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import nullOrEmpty from './null-or-empty';
|
import nullOrEmpty from './null-or-empty';
|
||||||
|
|
||||||
export default function(s: string, max: number) {
|
export default function(s: string, max: number): string {
|
||||||
if (nullOrEmpty(s)) {
|
if (nullOrEmpty(s)) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export default function(val: string) {
|
export default function(val: string): boolean {
|
||||||
if (val === undefined) {
|
if (val === undefined) {
|
||||||
return true;
|
return true;
|
||||||
} else if (val === null) {
|
} else if (val === null) {
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
"radix": true,
|
"radix": true,
|
||||||
"semicolon": true,
|
"semicolon": true,
|
||||||
"switch-default": false,
|
"switch-default": false,
|
||||||
"triple-equals": true,
|
"triple-equals": false,
|
||||||
"typedef": [true,
|
"typedef": [true,
|
||||||
"call-signature",
|
"call-signature",
|
||||||
"property-declaration"
|
"property-declaration"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user