mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-02 02:41:34 +00:00
RSS
This commit is contained in:
parent
b5f163891c
commit
30b45c2573
17 changed files with 157 additions and 26 deletions
|
|
@ -1,3 +1,4 @@
|
|||
const constants = require("../../lib/constants")
|
||||
const {fetchUser} = require("../../lib/collectors")
|
||||
|
||||
function reply(statusCode, content) {
|
||||
|
|
@ -9,7 +10,7 @@ function reply(statusCode, content) {
|
|||
}
|
||||
|
||||
module.exports = [
|
||||
{route: "/api/user/(\\w+)", methods: ["GET"], code: async ({fill}) => {
|
||||
{route: `/api/user/(${constants.external.username_regex})`, methods: ["GET"], code: async ({fill}) => {
|
||||
const user = await fetchUser(fill[0])
|
||||
const data = user.export()
|
||||
return reply(200, data)
|
||||
|
|
|
|||
15
src/site/api/feed.js
Normal file
15
src/site/api/feed.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const constants = require("../../lib/constants")
|
||||
const {fetchUser} = require("../../lib/collectors")
|
||||
const {render} = require("pinski/plugins")
|
||||
|
||||
module.exports = [
|
||||
{route: `/u/(${constants.external.username_regex})/rss.xml`, methods: ["GET"], code: async ({url, fill}) => {
|
||||
const user = await fetchUser(fill[0])
|
||||
const content = user.timeline.getFeed().xml()
|
||||
return {
|
||||
statusCode: 200,
|
||||
contentType: "application/rss+xml", // see https://stackoverflow.com/questions/595616/what-is-the-correct-mime-type-to-use-for-an-rss-feed
|
||||
content
|
||||
}
|
||||
}}
|
||||
]
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
const constants = require("../../lib/constants")
|
||||
const {fetchUser} = require("../../lib/collectors")
|
||||
const {render} = require("pinski/plugins")
|
||||
|
||||
module.exports = [
|
||||
{route: "/u/([\\w.]+)", methods: ["GET"], code: async ({url, fill}) => {
|
||||
{route: `/u/(${constants.external.username_regex})`, methods: ["GET"], code: async ({url, fill}) => {
|
||||
const params = url.searchParams
|
||||
const user = await fetchUser(fill[0])
|
||||
const page = +params.get("page")
|
||||
|
|
@ -11,7 +12,7 @@ module.exports = [
|
|||
}
|
||||
return render(200, "pug/user.pug", {url, user})
|
||||
}},
|
||||
{route: "/fragment/user/([\\w.]+)/(\\d+)", methods: ["GET"], code: async ({url, fill}) => {
|
||||
{route: `/fragment/user/(${constants.external.username_regex})/(\\d+)`, methods: ["GET"], code: async ({url, fill}) => {
|
||||
const user = await fetchUser(fill[0])
|
||||
const pageNumber = +fill[1]
|
||||
const pageIndex = pageNumber - 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue