Skip to content

Commit

Permalink
Update to new UIX version
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasstrehle committed Oct 25, 2023
1 parent d93f7f6 commit 343e35c
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 737 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/uix-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
- name: Setup Deno
uses: "denoland/setup-deno@v1"
- name: Deploy UIX App
run: "deno run --importmap https://dev.cdn.unyt.org/importmap.json -Aqr https://dev.cdn.unyt.org/uix/run.ts --stage prod --detach "
run: "deno run --importmap https://dev.cdn.unyt.org/uix1/importmap.json -Aqr https://dev.cdn.unyt.org/uix1/run.ts --stage prod --detach "
needs: test
11 changes: 6 additions & 5 deletions backend/entrypoint.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
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";
import { Entrypoint } from "uix/html/entrypoints.ts";
import { FileProvider } from "uix/html/entrypoint-providers.tsx";
import { UIX } from "uix";

@endpoint export class Screenshot {
@timeout(40_000)
Expand All @@ -12,7 +13,7 @@ import { timeout } from "unyt_core/datex_all.ts";
fullSize?: boolean
}): Promise<HTMLImageElement> {
const fileName = `${url.toString().replaceAll(/[^a-zA-Z0-9\?\-\.]+/g, '_')}.png`;
const filePath = UIX_CACHE_PATH.getChildPath(fileName);
const filePath = UIX.cacheDir.getChildPath(fileName);
if (filePath.fs_exists)
return this.getImage(filePath);

Expand All @@ -35,5 +36,5 @@ import { timeout } from "unyt_core/datex_all.ts";
// The backend routes definition
export default {
'/': null,
'/image/*': new UIX.FileProvider(UIX_CACHE_PATH)
} satisfies UIX.Entrypoint;
'/image/*': new FileProvider(UIX.cacheDir)
} satisfies Entrypoint;
9 changes: 5 additions & 4 deletions common/components/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { UIX } from "uix";
import { Screenshot } from 'backend/entrypoint.tsx';
import { Component } from 'uix/components/Component.ts';
import { template } from "uix/html/template.ts";

@UIX.template(function(this: MainPage) {
@template(function(this: MainPage) {
return <div>
<h1>UIX Screenshot <b>App</b></h1>
<span>Get a screenshot of any given URL.</span>

<input id="url" value="https://example.com" type={"url"} placeholder={"Enter URL here..."}/>
<div id="submit" onclick={UIX.inDisplayContext(()=>this.capture())} class="submit active">Capture</div>
<div id="submit" onclick:frontend={()=>this.capture()} class="submit active">Capture</div>

<p>Screenshot</p>
<div id="images"/>
</div>
})
export class MainPage extends UIX.BaseComponent {
export class MainPage extends Component {
@id declare url: HTMLInputElement;
@id declare images: HTMLDivElement;
@id declare submit: HTMLDivElement;
Expand Down
36 changes: 3 additions & 33 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
{
"imports": {
"unyt/": "https://cdn.unyt.org/uix-components/",
"unyt_core": "https://dev.cdn.unyt.org/unyt_core/datex.ts",
"uix": "https://dev.cdn.unyt.org/uix/uix.ts",
"unyt_core/": "https://dev.cdn.unyt.org/unyt_core/",
"uix/": "https://dev.cdn.unyt.org/uix/",
"uix_std/": "https://dev.cdn.unyt.org/uix/uix_std/",
"unyt_tests/": "https://dev.cdn.unyt.org/unyt_tests/",
"unyt_web/": "https://dev.cdn.unyt.org/unyt_web/",
"unyt_node/": "https://dev.cdn.unyt.org/unyt_node/",
"unyt_cli/": "https://dev.cdn.unyt.org/unyt_cli/",
"supranet/": "https://portal.unyt.org/ts_module_resolver/",
"uix/jsx-runtime": "https://dev.cdn.unyt.org/uix/jsx-runtime/jsx.ts",
"backend/": "./backend/",
"common/": "./common/",
"frontend/": "./frontend/"
},
"_publicImportMap": "./importmap.json",
"importMap": "./.datex-cache/importmap.lock.json",
"compilerOptions": {
"module": "esnext",
"target": "es2022",
"noImplicitOverride": true,
"removeComments": true,
"preserveConstEnums": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"jsx": "react-jsx",
"jsxImportSource": "uix",
"lib": [
"deno.window",
"dom",
"esnext"
"deno.window"
]
},
"tasks": {
"run": "uix",
"run-dev": "uix -wr",
"run-uixdev": "deno run -Aqr http://localhost:4200/run.ts -wr --import-map importmap.uixdev.json"
}
}
Loading

0 comments on commit 343e35c

Please sign in to comment.