feat(route): urbandictionary (#11969)
This commit is contained in:
@@ -287,6 +287,12 @@ Board and Build can be found in [here](http://api.ineal.me/tss/status)
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Urban Dictionary
|
||||
|
||||
### Random words
|
||||
|
||||
<RouteEn author="TonyRL" example="/urbandictionary/random" path="/urbandictionary/random" radar="1" rssbud="1"/>
|
||||
|
||||
## wikiHow
|
||||
|
||||
### Home
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/random': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'urbandictionary.com': {
|
||||
_name: 'Urban Dictionary',
|
||||
'.': [
|
||||
{
|
||||
title: 'Random words',
|
||||
docs: 'https://docs.rsshub.app/en/other.html#urban-dictionary',
|
||||
source: ['/random.php', '/'],
|
||||
target: '/urbandictionary/random',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.urbandictionary.com';
|
||||
const { data } = await got('https://api.urbandictionary.com/v0/random');
|
||||
|
||||
const items = data.list.map((item) => ({
|
||||
title: item.word,
|
||||
description: art(path.join(__dirname, 'templates/definition.art'), { item }),
|
||||
link: `${baseUrl}/define.php?term=${item.word}`,
|
||||
guid: item.permalink,
|
||||
pubDate: parseDate(item.written_on),
|
||||
author: item.author,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Urban Dictionary: Random words',
|
||||
link: `${baseUrl}/random.php`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/random', require('./random'));
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
{{ if item.definition }}
|
||||
{{ item.definition }}<br>
|
||||
{{ /if }}
|
||||
|
||||
{{ if item.example }}
|
||||
<i>{{ item.example }}</i><br>
|
||||
{{ /if }}
|
||||
|
||||
{{ if item.author }}
|
||||
by <a href="https://www.urbandictionary.com/author.php?author={{ item.author }}">{{ item.author }}</a>
|
||||
{{ /if }}
|
||||
Reference in New Issue
Block a user