Skip to content

Commit

Permalink
Fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasstrehle committed Sep 19, 2023
1 parent 3e42b97 commit ada023e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 60 deletions.
2 changes: 1 addition & 1 deletion app.dx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Website Screenshot Example",
name: "Threads Example",
icon_path: "https://cdn.unyt.org/unyt-resources/logos/unyt/square-dark-background.png";

plugin git_deploy (
Expand Down
4 changes: 2 additions & 2 deletions backend/.dx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use stage from #public.uix;

endpoint: stage {
prod: @+example_screenshot
prod: @+example_threads
},

location: stage {
prod: @+unyt_eu1
},

domain: stage {
prod: 'screenshot.unyt.app'
prod: 'threads.example.unyt.org'
}
24 changes: 0 additions & 24 deletions backend/Capture.ts

This file was deleted.

33 changes: 0 additions & 33 deletions backend/entrypoint.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
import { UIX } from "uix/uix.ts";
import { UIX_CACHE_PATH } from "uix/uix_all.ts";
import Capture from './Capture.ts';
import { Path } from "uix/utils/path.ts";
import { timeout } from "unyt_core/datex_all.ts";

@endpoint export class Screenshot {
@timeout(40_000)
@property static async take(url: string | URL, config?: {
width: number,
height: number,
fullSize?: boolean
}): Promise<HTMLImageElement> {
const fileName = `${url.toString().replaceAll(/[^a-zA-Z0-9\?\-\.]+/g, '_')}.png`;
const filePath = UIX_CACHE_PATH.getChildPath(fileName);
if (filePath.fs_exists)
return this.getImage(filePath);

const fileData = await Capture.take(
url,
config?.fullSize, {
width: config?.width ?? 1920,
height: config?.height ?? 1080
}
);
await Deno.writeFile(filePath, fileData);
return this.getImage(filePath);
}

static getImage(filePath: Path<`${string}:`, boolean>) {
return <img src={'/image/'.concat(filePath.name)}/> as HTMLImageElement;
}
}

// The backend routes definition
export default {
'/': null,
'/image/*': new UIX.FileProvider(UIX_CACHE_PATH)
} satisfies UIX.Entrypoint;

0 comments on commit ada023e

Please sign in to comment.