From 13339efa9e2864cb1d67fd28ac556bc34befdc9d Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 20 May 2020 03:03:21 +1200 Subject: [PATCH] Implement caption on right (closes #51) --- src/site/api/routes.js | 13 ++++++------- src/site/pug/includes/post.pug | 4 +++- src/site/pug/settings.pug | 2 +- src/site/sass/includes/_main.sass | 6 ++++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/site/api/routes.js b/src/site/api/routes.js index 3288520..fce1dee 100644 --- a/src/site/api/routes.js +++ b/src/site/api/routes.js @@ -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, diff --git a/src/site/pug/includes/post.pug b/src/site/pug/includes/post.pug index 3a9c920..a8005b1 100644 --- a/src/site/pug/includes/post.pug +++ b/src/site/pug/includes/post.pug @@ -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 diff --git a/src/site/pug/settings.pug b/src/site/pug/settings.pug index 5ad0425..63a6b63 100644 --- a/src/site/pug/settings.pug +++ b/src/site/pug/settings.pug @@ -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)"} ]) diff --git a/src/site/sass/includes/_main.sass b/src/site/sass/includes/_main.sass index a9f4a12..02e52c7 100644 --- a/src/site/sass/includes/_main.sass +++ b/src/site/sass/includes/_main.sass @@ -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