Rename some things

This commit is contained in:
Râu Cao 2024-10-24 14:28:49 +02:00
parent fdd16d8236
commit fc711c2194
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 8 additions and 10 deletions

View File

@ -5,7 +5,7 @@ import Article from "../models/article.ts";
import Profile from "../models/profile.ts"; import Profile from "../models/profile.ts";
import { articleHtml } from "../html.ts"; import { articleHtml } from "../html.ts";
import notFoundHandler from "../handlers/not-found.ts"; import notFoundHandler from "../handlers/not-found.ts";
import generateOgProfileImage from "../tasks/generate_og_profile_image.ts"; import { generateOgProfileImage } from "../magick.ts";
const userEventHandler = async function (ctx: Context) { const userEventHandler = async function (ctx: Context) {
const username = ctx.state.username.replace(/^(@|~)/, ""); const username = ctx.state.username.replace(/^(@|~)/, "");

View File

@ -5,7 +5,7 @@ import Article from "../models/article.ts";
import Profile from "../models/profile.ts"; import Profile from "../models/profile.ts";
import { profilePageHtml } from "../html.ts"; import { profilePageHtml } from "../html.ts";
import notFoundHandler from "../handlers/not-found.ts"; import notFoundHandler from "../handlers/not-found.ts";
import generateOgProfileImage from "../tasks/generate_og_profile_image.ts"; import { generateOgProfileImage } from "../magick.ts";
const userProfileHandler = async function (ctx: Context) { const userProfileHandler = async function (ctx: Context) {
const username = ctx.state.path.replace(/^(@|~)/, ""); const username = ctx.state.path.replace(/^(@|~)/, "");

View File

@ -1,10 +1,10 @@
import Profile from "../models/profile.ts"; import Profile from "./models/profile.ts";
import { checkIfFileExists, runCommand } from "../utils.ts"; import { checkIfFileExists, runCommand } from "./utils.ts";
import { log } from "../log.ts"; import { log } from "./log.ts";
const tmpImgDir = "/tmp/substr/img"; const tmpImgDir = "/tmp/substr/img";
const createRoundedImage = function (profile: Profile) { function createRoundedImage(profile: Profile) {
const command = [ const command = [
'magick', 'magick',
profile.picture, profile.picture,
@ -23,7 +23,7 @@ const createRoundedImage = function (profile: Profile) {
return runCommand(command); return runCommand(command);
} }
const createOgImage = async function (profile: Profile, ogImagePath: string, backgroundColor: string) { async function createOgImage(profile: Profile, ogImagePath: string, backgroundColor: string) {
const status = await createRoundedImage(profile); const status = await createRoundedImage(profile);
if (status.success) { if (status.success) {
@ -43,7 +43,7 @@ const createOgImage = async function (profile: Profile, ogImagePath: string, bac
} }
}; };
const generateOgProfileImage = async function(profile: Profile) { export async function generateOgProfileImage(profile: Profile) {
if (!profile.picture) return false; if (!profile.picture) return false;
const ogImagePath = `${tmpImgDir}/og-p-${profile.event.id}.png`; const ogImagePath = `${tmpImgDir}/og-p-${profile.event.id}.png`;
@ -59,5 +59,3 @@ const generateOgProfileImage = async function(profile: Profile) {
} }
} }
} }
export default generateOgProfileImage;