mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-12-16 19:18:49 +00:00
RSS
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user