Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
floscher committed May 22, 2023
1 parent 2473ae6 commit e802a2c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docker/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '3'

services:
postgres:
image: ghcr.io/fumix/fublog-postgres:main-de_DE
image: ghcr.io/floscher/fublog-postgres:font-opengraph-de_DE
env_file: .env
environment:
# Example
Expand All @@ -14,17 +14,18 @@ services:
volumes:
- fublog_postgres_data:/var/lib/postgresql/data
app:
image: ghcr.io/fumix/fublog-app:main
image: ghcr.io/floscher/fublog-app:font-opengraph
env_file: .env
environment:
DATABASE_HOST: "postgres"
DATABASE_PORT: "5432"
networks:
- default
- outside
ports: ["3000:5000"]
networks:
# The docker network that connects the app with the outside world (put e.g. an nginx container in this network)
outside:
external: true
#external: true
volumes:
fublog_postgres_data:
10 changes: 8 additions & 2 deletions server/src/routes/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,16 @@ router.get("/delete/:id(\\d+$)", async (req: Request, res: Response, next) => {

router.get("/:id(\\d+)/og-image", async (req: Request, res: Response, next) => {
AppDataSource.getRepository(PostEntity)
.findOne({ where: { id: +req.params.id } })
.findOne({ where: { id: +req.params.id }, relations: ["attachments"] })
.then((post) => {
if (post && post.id) {
res.status(200).write(generateShareImage(post.title, post.createdAt));
res.status(200).write(
generateShareImage(
post.title,
post.createdAt,
post.attachments.find((it) => it.file && it.file.binaryData),
),
);
res.end();
} else {
next(new ForbiddenError("Post not found"));
Expand Down
2 changes: 1 addition & 1 deletion server/src/service/opengraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function generateShareImage(title: string, date: Date, image: Image | Can
context.fillStyle = "rgb(48,48,48)";
context.fillRect(0, 0, 1280, 640);

context.font = "bold 48px sans-serif";
context.font = 'bold 48px "Roboto", sans-serif';
const titleWords = title.split(/\s+/).map((word) => ({ word, width: context.measureText(word).width }));

const lines = titleWords
Expand Down

0 comments on commit e802a2c

Please sign in to comment.