feat: add CuriousCat (#5340)

This commit is contained in:
Lucas Eduardo 2020-08-04 12:03:00 -03:00 committed by GitHub
parent 2e087f3e5a
commit 9eaa2814fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 1 deletions

View File

@ -180,7 +180,21 @@ Under `RSSHub`'s directory, execute the following commands to pull the latest so
$ git pull
```
Then repeat the installation steps
Then repeat the installation steps.
### A tip for Nix users
To install nodejs, yarn and jieba (to build documentation) you can use the following `nix-shell` configuration script.
```nix
let
pkgs = import <nixpkgs> {};
node = pkgs.nodejs-12_x;
in pkgs.stdenv.mkDerivation {
name = "nodejs-yarn-jieba";
buildInputs = [node pkgs.yarn pkgs.pythonPackages.jieba];
}
```
## Deploy to Heroku

View File

@ -4,6 +4,12 @@ pageClass: routes
# Social Media
## CuriousCat
### User
<RouteEn author="lucasew" path="/curiouscat/user/:name" example="/curiouscat/user/username" :paramsDesc="['name, username that is in the URL']" />
## Disqus
### Comment

View File

@ -3043,6 +3043,9 @@ router.get('/scvtc/xygg', require('./routes/universities/scvtc/xygg'));
// OneJAV
router.get('/onejav/:type/:key?', require('./routes/onejav/one'));
// CuriousCat
router.get('/curiouscat/user/:id', require('./routes/curiouscat/user'));
// Telecompaper
router.get('/telecompaper/news/:caty/:year?/:country?/:type?/:keyword?', require('./routes/telecompaper/news'));

View File

@ -0,0 +1,40 @@
const got = require('@/utils/got');
const fetchAPIByUser = async (user) => {
const baseURL = 'https://curiouscat.me/api/v2/profile?username=';
const { data } = await got.get(baseURL + user);
return data;
};
module.exports = async (ctx) => {
const { id } = ctx.params;
const user = id;
const data = await fetchAPIByUser(user);
const items = data.posts.map((post) => {
const author = post.senderData.id ? post.senderData.username : 'Anonymous';
const title = `@${author}: ${post.comment}`;
const link = `https://curiouscat.qa/${user}/post/${post.id}`;
const media = post.media ? `<img src="${post.media.img}"></img>` : '';
const description = `${post.comment}<br><br>
${post.reply}
${media}
<br>
Likes: ${post.likes}`;
const pubDate = new Date(post.timestamp * 1000);
return {
author,
link,
title,
description,
pubDate,
};
});
ctx.state.data = {
title: `Curiouscat - ${user}`,
link: `https://curiouscat.qa/${user}`,
description: `Questions answered by ${user} using Curiouscat`,
language: data.lang,
item: items,
};
};