Skip to content

Commit

Permalink
added temp boilerplate codes and shims.
Browse files Browse the repository at this point in the history
  • Loading branch information
eser committed Sep 26, 2022
1 parent 5000746 commit c0bee88
Show file tree
Hide file tree
Showing 36 changed files with 381 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ etc/coverage/*.json
etc/coverage/cov_profile.lcov

# hidden
tmp/
tmp/_hidden/
39 changes: 39 additions & 0 deletions src/shims/error-event/error-event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Taken from: https://github.com/oakserver/oak/blob/main/node_shims.ts
// Copyright 2018-2022 the oak authors. All rights reserved. MIT license.

export class ErrorEvent extends Event {
#message: string;
#filename: string;
#lineno: number;
#colno: number;
// deno-lint-ignore no-explicit-any
#error: any;

get message(): string {
return this.#message;
}
get filename(): string {
return this.#filename;
}
get lineno(): number {
return this.#lineno;
}
get colno(): number {
return this.#colno;
}
// deno-lint-ignore no-explicit-any
get error(): any {
return this.#error;
}

constructor(type: string, eventInitDict: ErrorEventInit = {}) {
super(type, eventInitDict);
const { message = "error", filename = "", lineno = 0, colno = 0, error } =
eventInitDict;
this.#message = message;
this.#filename = filename;
this.#lineno = lineno;
this.#colno = colno;
this.#error = error;
}
}
21 changes: 21 additions & 0 deletions src/shims/error-event/oak-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-2022 the oak authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions tmp/boilerplate/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*.md]
trim_trailing_whitespace = false

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
11 changes: 11 additions & 0 deletions tmp/boilerplate/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text eol=lf

*.png binary
*.jpg binary
*.ico binary
*.jpg binary
*.eot binary
*.ttf binary
*.woff binary
*.woff2 binary
22 changes: 22 additions & 0 deletions tmp/boilerplate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# OS-specific files
.DS_Store
Thumbs.db

# Editor metadata
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea/

# local API keys and secrets
.env.local
.env.*.local

# sensitive files
*.pem
*.swp

# typescript
*.tsbuildinfo
5 changes: 5 additions & 0 deletions tmp/boilerplate/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"denoland.vscode-deno"
]
}
6 changes: 6 additions & 0 deletions tmp/boilerplate/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
"editor.defaultFormatter": "denoland.vscode-deno"
}
50 changes: 50 additions & 0 deletions tmp/boilerplate/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"compilerOptions": {
"strict": true
},
"lint": {
"files": {
"include": [
"src/",
"mod.ts",
"*.md",
"*.json"
],
"exclude": []
},
"rules": {
"tags": [
"recommended"
],
"include": [],
"exclude": []
}
},
"fmt": {
"files": {
"include": [
"src/",
"mod.ts",
"*.md",
"*.json"
],
"exclude": []
}
},
"test": {
"files": {
"include": [
"src/"
],
"exclude": []
}
},
"tasks": {
"test": "deno test ./src/ --coverage=./etc/cov_profile",
"test:coverage": "deno coverage ./etc/cov_profile",
"test:generate-lcov": "deno coverage ./etc/cov_profile --lcov > ./etc/cov_profile/cov_profile.lcov",
"bench": "deno bench ./src/ --unstable",
"start": "deno run -A --watch=src/,public/ dev.ts"
},
"importMap": "./import_map.json"
}
Empty file added tmp/boilerplate/dev.ts
Empty file.
Empty file.
20 changes: 20 additions & 0 deletions tmp/boilerplate/hex.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const hexConfig = {
urls: {
structure: "/[lang]/[...path]",
rewrites: [
// {
// source: "/",
// destination: "/en/"
// }
],
},

i18n: {
languages: [
"en",
"tr"
]
},
};

export { hexConfig as default, hexConfig };
7 changes: 7 additions & 0 deletions tmp/boilerplate/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"imports": {
"_@hex/": "https://deno.land/x/hex/",
"@hex/": "../../src/",
"@app/": "./src/"
}
}
Binary file added tmp/boilerplate/public/favicon.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions tmp/boilerplate/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow: /
Empty file.
Empty file.
Empty file.
30 changes: 30 additions & 0 deletions tmp/boilerplate/src/app/[...static]/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const staticPage = {
nameSingular: "StaticPage",
namePlural: "StaticPages",
filePathPattern: "./content/**/*.md",
fields: {
title: {
type: "string",
description: "The title of the static page",
required: true,
},
date: {
type: "date",
description: "The date of the static page",
required: true,
},
url: {
type: "string",
description: "The url of the static page",
resolve: (item) => {
const [, title, lang] = /static\/([^\.]*)\.(.*)/.exec(
item.filePath,
);

return `/${lang}/${title}`;
},
},
},
};

export { staticPage, staticPage as default };
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions tmp/boilerplate/src/app/_unhandled/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { type Context, results } from "@hex/web/page";
import { type Language } from "@hex/i18n";

interface PageProps {
lang: Language;
}

const Page = function HomeIndex(ctx: Context<PageProps>) {
return results.reactView(
<div>
<h1>Homepage</h1>
</div>,
{
title: "Homepage",
description: "This is the homepage",
layout: "@app/shared/layout/layout.tsx",
},
);
};

export { Page, Page as default };
3 changes: 3 additions & 0 deletions tmp/boilerplate/src/app/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: slategray;
}
33 changes: 33 additions & 0 deletions tmp/boilerplate/src/app/home/forms/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "https://jspm.dev/[email protected]";

import {
dumper,
dumperReact,
executeFromCli,
type HexFunctionInput,
results,
} from "@hex/functions/mod.ts";
import { type Language } from "@hex/i18n/mod.ts";

interface PageProps {
lang: Language;
}

const Page = function HomeIndex(input: HexFunctionInput<PageProps>) {
return results.reactView(
<div>
<h1>Homepage</h1>
</div>,
{
title: "Homepage",
description: "This is the homepage",
layout: "@app/shared/layout/layout.tsx",
},
);
};

const result = executeFromCli(Page);
// dumper(result);
dumperReact(result);

export { Page, Page as default };
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions tmp/boilerplate/src/app/home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "https://jspm.dev/[email protected]";

import {
dumper,
dumperReact,
executeFromCli,
type HexFunctionInput,
results,
} from "@hex/functions/mod.ts";
import { type Language } from "@hex/i18n/mod.ts";

interface PageProps {
lang: Language;
}

const Page = function HomeIndex(input: HexFunctionInput<PageProps>) {
return results.reactView(
<div>
<h1>Homepage</h1>
</div>,
{
title: "Homepage",
description: "This is the homepage",
layout: "@app/shared/layout/layout.tsx",
},
);
};

const result = executeFromCli(Page);
// dumper(result);
dumperReact(result);

export { Page, Page as default };
35 changes: 35 additions & 0 deletions tmp/boilerplate/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { BodyContents, HeadContents } from "@hex/web/page";
import { type Language } from "@hex/i18n";

interface LayoutProps {
lang: Language;
children: JSX.Element;
}

const Layout = function Layout(props: LayoutProps) {
return (
<html lang={props.lang.code}>
<head>
<meta charSet="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<link rel="icon" href="/favicon.ico" />

<HeadContents />
</head>
<body>
<div id="app">
<Routes content={props.children}>
<PathBasedRoutes />
</Routes>
</div>

<BodyContents />
</body>
</html>
);
};

export { Layout, Layout as default };
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit c0bee88

Please sign in to comment.