1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 08:07:30 +00:00

Implement caption on right (closes #51)

This commit is contained in:
Cadence Ember 2020-05-20 03:03:21 +12:00
parent 2244c219a4
commit 13339efa9e
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412
4 changed files with 16 additions and 9 deletions

View File

@ -25,7 +25,6 @@ module.exports = [
},
{
route: "/privacy", methods: ["GET"], code: async ({req}) => {
if (constants.has_privacy_policy && pugCache.has("pug/privacy.pug")) {
const settings = getSettings(req)
return render(200, "pug/privacy.pug", {settings})
@ -107,13 +106,14 @@ module.exports = [
}
},
{
route: `/fragment/user/(${constants.external.username_regex})/(\\d+)`, methods: ["GET"], code: async ({url, fill}) => {
route: `/fragment/user/(${constants.external.username_regex})/(\\d+)`, methods: ["GET"], code: async ({req, url, fill}) => {
return fetchUser(fill[0]).then(async user => {
const pageNumber = +fill[1]
const pageIndex = pageNumber - 1
await user.timeline.fetchUpToPage(pageIndex)
if (user.timeline.pages[pageIndex]) {
return render(200, "pug/fragments/timeline_page.pug", {page: user.timeline.pages[pageIndex], pageIndex, user, url})
const settings = getSettings(req)
return render(200, "pug/fragments/timeline_page.pug", {page: user.timeline.pages[pageIndex], pageIndex, user, url, settings})
} else {
return {
statusCode: 400,
@ -136,17 +136,18 @@ module.exports = [
}
},
{
route: `/fragment/post/(${constants.external.shortcode_regex})`, methods: ["GET"], code: ({fill}) => {
route: `/fragment/post/(${constants.external.shortcode_regex})`, methods: ["GET"], code: ({req, fill}) => {
return getOrFetchShortcode(fill[0]).then(async post => {
await post.fetchChildren()
await post.fetchExtendedOwnerP() // serial await is okay since intermediate fetch result is cached
if (post.isVideo()) await post.fetchVideoURL()
const settings = getSettings(req)
return {
statusCode: 200,
contentType: "application/json",
content: {
title: getPageTitle(post),
html: pugCache.get("pug/fragments/post.pug").web({post})
html: pugCache.get("pug/fragments/post.pug").web({post, settings})
}
}
}).catch(error => {
@ -186,9 +187,7 @@ module.exports = [
await post.fetchChildren()
await post.fetchExtendedOwnerP() // serial await is okay since intermediate fetch result is cached
if (post.isVideo()) await post.fetchVideoURL()
const settings = getSettings(req)
return render(200, "pug/post.pug", {
title: getPageTitle(post),
post,

View File

@ -1,7 +1,9 @@
include ./display_structured
mixin post(post, headerWithNavigation)
.post-page-divider
.post-page-divider(class={
"caption-on-right": settings.caption_side === "right"
})
section.description-section
.user-header
header.user-header-inner

View File

@ -76,7 +76,7 @@ html
{value: "6", text: "6 columns"}
])
+select("caption_side", "Caption side", true, [
+select("caption_side", "Caption side", false, [
{value: "left", text: "Left (Bibliogram)"},
{value: "right", text: "Right (Instagram)"}
])

View File

@ -266,6 +266,12 @@ body
display: flex
flex-direction: column
&.caption-on-right
grid-template-columns: auto 360px
.description-section
order: 1
.description-section
display: grid
align-items: stretch