Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solved show code #29

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cors-proxy-server/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// Source from: https://www.npmjs.com/package/cors-anywhere
const fs = require("node:fs");
const cors_proxy = require('cors-anywhere');

// const options = {
// key: fs.readFileSync("/etc/ssl/neofonie/privkey.pem"),
// cert: fs.readFileSync("/etc/ssl/neofonie/fullchain.pem"),
// };

// Listen on a specific host via the HOST environment variable
var host = process.env.HOST || '0.0.0.0';
const host = process.env.HOST || '0.0.0.0';

// Listen on a specific port via the PORT environment variable
var port = process.env.PORT || 8080;

var cors_proxy = require('cors-anywhere');
const port = process.env.PORT || 8443;

cors_proxy.createServer({
cors_proxy.createServer({
//...options,
originWhitelist: [], // Allow all origins
requireHeader: ['origin', 'x-requested-with' ],
removeHeaders: ['cookie', 'cookie2']
Expand Down
10 changes: 7 additions & 3 deletions cors-proxy-server/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"name": "cors-proxy-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
"start:local": "node index.js",
"start": "pm2 start index.js",
"list": "pm2 list",
"monitor": "pm2 monitor",
"stop": "pm2 stop 0"
},
"author": "",
"license": "ISC",
"devDependencies": {
"cors-anywhere": "^0.4.4"
"cors-anywhere": "^0.4.4",
"pm2": "^5.3.1"
}
}
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"yargs": "^17.7.2"
"yargs": "^17.7.2",
"dedent": "^1.5.3"
},
"dependencies": {
"material": "^0.9.10",
Expand Down
26 changes: 16 additions & 10 deletions src/lib/components/checkbox.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- checkbox.svelte -->
<script lang="ts">
import SvelteMarkdown from 'svelte-markdown';
import { linkA11yRule } from '$lib/helpers/a11y-manager.js';
import { onMount, createEventDispatcher } from 'svelte';
import {linkA11yRule} from '$lib/helpers/a11y-manager.js';
import {onMount, createEventDispatcher} from 'svelte';

export let label: string = '';
export let value: boolean = false;
Expand All @@ -29,15 +29,21 @@
}
</style>

<label class="flex gap-2 items-center">
<input bind:this={elmCheckbox} {id} type="checkbox" class="h-4 w-4 shrink-0" bind:checked={value} on:click={handleChange}/>
<div class="flex gap-2 items-start">
<input bind:this={elmCheckbox} {id}
type="checkbox"
class="h-4 w-4 mt-1 shrink-0"
bind:checked={value}
on:click={handleChange}/>
<div>
{#if label}
<SvelteMarkdown source={label}/>
{:else}
<slot/>
{/if}
<label for={id}>
{#if label}
<SvelteMarkdown source={label}/>
{:else}
<slot/>
{/if}
</label>

<slot name="show-code"/>
</div>
</label>
</div>
17 changes: 14 additions & 3 deletions src/lib/components/show-code.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@
$: showPlayground = showCode;
</script>

<button class="link" on:click={toggleCode}>Show Code</button>
<button class="link" on:click={toggleCode}>{!showPlayground ? 'Show' : 'Hide'} Code</button>
{#if showPlayground}
<playground-ide editable-file-system line-numbers resizable><slot /></playground-ide>
{/if}
<playground-ide line-numbers resizable class="playground-theme-zenburn">
<svelte:element this="script" type="sample/html" filename="index.html">
<slot/>
</svelte:element>
</playground-ide>
{/if}

<style>
:global(#playground) {
--playground-code-font-size: 18px;
--playground-highlight-color: #f00000;
}
</style>
32 changes: 18 additions & 14 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import dedent from 'dedent';
import Github from '$lib/components/github.svelte';
import Link from '$lib/components/link.svelte';
import Headline from '$lib/components/headline.svelte';
Expand All @@ -11,8 +12,7 @@
</script>

<svelte:head>
<!-- TODO: https://www.npmjs.com/package/playground-elements?activeTab=readme#other -->
<script type="module" src="/node_modules/playground-elements/playground-ide.js"></script>
<script type="module" src="https://google.github.io/playground-elements/playground-configurator.js"></script>
</svelte:head>

<Github/>
Expand Down Expand Up @@ -56,20 +56,24 @@
<Headline tag="h2">Markup</Headline>

<StoredCheckbox key="html-lang" label="`<html>-Tag` hat korrektes lang-Attribut">
<ShowCode slot="show-code">
<script type="sample/html" filename="index.html">
<!doctype html>
<html lang="de-DE"><!-- language-COUNTRY -->
<head></head>
<body>
...
</body>
</html>
</script>
</ShowCode>
<ShowCode slot="show-code">{@html dedent`
<!doctype html>
<!-- lang="language-COUNTRY" -->
<html lang="de-DE">
<head></head>
<body>
...
</body>
</html>
`}</ShowCode>
</StoredCheckbox>

<StoredCheckbox key="tabindex" label="Es gibt bei tabindex nur 0 oder -1" />
<StoredCheckbox key="tabindex" label="Es gibt bei tabindex nur 0 oder -1">
<ShowCode slot="show-code">{@html dedent`
<a href="url" tabindex="-1">Ich bin ein Link</a><br />
<input type="text" tabindex="0" />
`}</ShowCode>
</StoredCheckbox>
<StoredCheckbox key="a-tag" label="`<a>-Tag` wird für alle Links verwendet -> Seitenwechseln" />
<StoredCheckbox key="button-tag"
label="`<button>-Tag` wird für alle Buttons, Klick- und Action-Flächen genutzt (kein div mit onclick etc.)" />
Expand Down