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
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
mixin image(url)
|
||||
-
|
||||
let params = new URLSearchParams()
|
||||
params.set("url", url)
|
||||
img(src="/imageproxy?"+params.toString())&attributes(attributes)
|
||||
@@ -1,15 +1,14 @@
|
||||
//- Needs page, pageIndex
|
||||
|
||||
include image.pug
|
||||
|
||||
mixin timeline_page(page, pageIndex)
|
||||
- const pageNumber = pageIndex + 1
|
||||
if pageNumber > 1
|
||||
.page-number(id=`page-${pageNumber}`)
|
||||
span.number Page #{pageNumber}
|
||||
section.timeline-page
|
||||
- const pageNumber = pageIndex + 1
|
||||
if pageNumber > 1
|
||||
header.page-number(id=`page-${pageNumber}`)
|
||||
span.number Page #{pageNumber}
|
||||
|
||||
.timeline-inner
|
||||
- const suggestedSize = 300
|
||||
each image in page
|
||||
- const thumbnail = image.getSuggestedThumbnail(suggestedSize) //- use this as the src in case there are problems with srcset
|
||||
+image(thumbnail.src)(alt=image.getAlt() width=thumbnail.config_width height=thumbnail.config_height srcset=image.getSrcset() sizes=`${suggestedSize}px`).image
|
||||
.timeline-inner
|
||||
- const suggestedSize = 300
|
||||
each image in page
|
||||
- const thumbnail = image.getSuggestedThumbnail(suggestedSize) //- use this as the src in case there are problems with srcset
|
||||
img(src=image.getProxy(thumbnail.src) alt=image.getAlt() width=thumbnail.config_width height=thumbnail.config_height srcset=image.getSrcset() sizes=`${suggestedSize}px`).image
|
||||
|
||||
@@ -16,10 +16,10 @@ html
|
||||
.main-divider
|
||||
header.profile-overview
|
||||
.profile-sticky
|
||||
+image(user.data.profile_pic_url)(width="150px" height="150px").pfp
|
||||
img(src=user.proxyProfilePicture width="150px" height="150px" alt=`${user.data.full_name}'s profile picture.`).pfp
|
||||
//-
|
||||
Instagram only uses the above URL, but an HD version is also available:
|
||||
+image(user.data.profile_pic_url_hd)
|
||||
Instagram only uses the above URL, but an HD version is also available.
|
||||
The alt text is pathetic, I know. I don't have much to work with.
|
||||
h1.full-name= user.data.full_name
|
||||
h2.username= `@${user.data.username}`
|
||||
p.bio= user.data.biography
|
||||
@@ -35,6 +35,8 @@ html
|
||||
span(data-numberformat=user.followedBy).count #{numberFormat(user.followedBy)}
|
||||
|
|
||||
| followed by
|
||||
div.links
|
||||
a(rel="alternate" type="application/rss+xml" href=`/u/${user.data.username}/rss.xml`) RSS
|
||||
|
||||
main#timeline.timeline
|
||||
each page, pageIndex in user.timeline.pages
|
||||
|
||||
@@ -71,6 +71,9 @@ body
|
||||
.count
|
||||
font-weight: bold
|
||||
|
||||
.links
|
||||
margin-top: 20px
|
||||
|
||||
.timeline
|
||||
--image-size: 260px
|
||||
$image-size: var(--image-size)
|
||||
|
||||
Reference in New Issue
Block a user