Skip to content

Commit a0c8d49

Browse files
committed
Contact page, copy to clipboard, run on RegexPlanet
1 parent f215a88 commit a0c8d49

File tree

10 files changed

+68
-28
lines changed

10 files changed

+68
-28
lines changed

app/components/Footer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const links = [
44
//{ link: 'https://github.com/regexplanet/regex-zone/issues', label: 'Feedback' },
55
{ link: 'https://github.com/regexplanet/regex-zone?tab=readme-ov-file#credits', label: 'Credits'},
66
{ link: 'https://github.com/regexplanet/regex-zone', label: 'Source' },
7+
{ link: '/contact.html', label: 'Contact' },
78
//{ link: 'https://github.com/regexplanet/regex-zone?tab=readme-ov-file#other-libraries-of-regex-patterns', label: 'Alternatives' },
89
];
910

app/components/Patterns.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type PatternEntry = {
1616
export type PatternEntryVariation = {
1717
title: string;
1818
pattern: string;
19+
replacement?: string;
1920
description?: string;
2021
};
2122

app/routes/auth._index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { LoaderFunctionArgs } from "@remix-run/node";
2-
import { Link as RemixLink, useLoaderData } from "@remix-run/react";
2+
import { useLoaderData } from "@remix-run/react";
33
import { authenticator } from "~/services/auth.server";
44
import { cookieStorage } from "~/services/session.server";
5+
import { User } from "~/types/User";
56

67
export async function loader({ request }: LoaderFunctionArgs) {
78
//console.log('in loader', (await cookieStorage.getSession(request.headers.get("Cookie"))).get("user"))
89
const session = await cookieStorage.getSession(request.headers.get("Cookie"));
910
const sessionUser = session.get("user");
1011
const authUser = await authenticator.isAuthenticated(request);
1112
return {
12-
//
13-
user: sessionUser,
13+
user: authUser,
1414
sessionUser,
1515
authUser,
1616
session: (await cookieStorage.getSession(request.headers.get("Cookie")))
@@ -21,12 +21,14 @@ function LoginSection() {
2121
return (
2222
<>
2323
<p>You are not logged in!</p>
24-
<RemixLink className="btn btn-primary" to="login.html">Login</RemixLink>
24+
<form action="/auth/github" method="post">
25+
<button type="submit" className="btn btn-primary">Login with Github</button>
26+
</form>
2527
</>
2628
)
2729
}
2830

29-
function LogoutSection({ user }: { user: any }) {
31+
function LogoutSection({ user }: { user: User }) {
3032
return (
3133
<>
3234
<p>You are logged in as <span className="border rounded bg-body-tertiary text-body-secondary p-2">{user.displayName} ({user.providerName}@{user.provider})</span></p>

app/routes/auth.login[.]html.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/routes/auth.logout[.]html.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export default function AuthLogout() {
4949
<h1 className="py-2">Logout</h1>
5050
<p>{message.text}</p>
5151
<p>
52-
<RemixLink className="btn btn-primary mx-2" to="/auth/">Login</RemixLink>
5352
<RemixLink className="btn btn-primary mx-2" to="/">Home</RemixLink>
5453
</p>
5554
</>

app/routes/contact[.]html.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { MetaFunction } from "@remix-run/node";
2+
import { useLocation } from "@remix-run/react";
3+
4+
export const meta: MetaFunction = () => {
5+
return [
6+
{ title: "Contact - Regex Zone" },
7+
];
8+
};
9+
10+
export default function Page() {
11+
12+
const location = useLocation();
13+
14+
let fullpath = location.pathname;
15+
if (location.search) {
16+
fullpath += '?' + location.search;
17+
}
18+
if (typeof window !== 'undefined') {
19+
fullpath = window.location.href
20+
}
21+
22+
return (
23+
<>
24+
<iframe height="737" title="Embedded Wufoo Form" style={{ "width": "100%", "border": "none" }} sandbox="allow-popups-to-escape-sandbox allow-top-navigation allow-scripts allow-popups allow-forms allow-same-origin" src={`https://fileformat.wufoo.com/embed/z5yinul1mj3me9/?field14=regexzone&field16=${encodeURIComponent(fullpath)}`}></iframe>
25+
</>
26+
);
27+
}

app/routes/patterns.$entry._index.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import { json, type MetaFunction, LoaderFunctionArgs } from "@remix-run/node";
44
//import type { LoaderFunctionArgs } from "@remix-run/node";
55
import { useLoaderData } from "@remix-run/react";
6+
import { useCopyToClipboard } from "@uidotdev/usehooks";
7+
import { PiClipboardBold, PiPlayBold } from "react-icons/pi";
68
import Markdown from 'react-markdown'
79

810
import { get, initialize, PatternEntry, PatternEntryVariation } from "~/components/Patterns";
@@ -54,10 +56,24 @@ function PatternEntryView(entry: PatternEntry) {
5456
}
5557

5658
function PatternEntryVariationView(variation: PatternEntryVariation) {
59+
const [_, copyToClipboard] = useCopyToClipboard();
5760
return (
5861
<tr>
5962
<td>{variation.title}</td>
60-
<td><code>{variation.pattern}</code></td>
63+
<td>
64+
<code>{variation.pattern}</code>
65+
</td>
66+
<td>
67+
<button
68+
className="btn btn-sm btn-outline-secondary ms-2 px-1 pt-0 pb-1"
69+
onClick={() => copyToClipboard(variation.pattern)}
70+
><PiClipboardBold title="copy to clipboard" /></button>
71+
<form action="https://www.regexplanet.com/advanced/java/index.html" className="d-inline" method="post" target="_blank">
72+
<input type="hidden" name="regex" value={variation.pattern} />
73+
<input type="hidden" name="replacement" value={variation.replacement} />
74+
<button className="btn btn-sm btn-outline-secondary ms-2 px-1 pt-0 pb-1" ><PiPlayBold title="Test" /></button>
75+
</form>
76+
</td>
6177
</tr>
6278
)
6379
}

app/routes/sitemap[.]xml.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export async function loader() {
1212
lines.push('<?xml-stylesheet type="text/xsl" href="/sitemap.xslt" ?>');
1313
lines.push('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">');
1414
lines.push(urlLine('/'));
15+
lines.push(urlLine('/contact.html'));
1516
lines.push(urlLine('/patterns/'));
1617
lines.push(urlLine('/patterns/tags.html'));
1718
lines.push(urlLine('/search.html'));

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@remix-run/express": "^2.11.2",
1515
"@remix-run/node": "^2.9.2",
1616
"@remix-run/react": "^2.9.2",
17+
"@uidotdev/usehooks": "^2.4.1",
1718
"bootstrap": "^5.3.3",
1819
"isbot": "^5.1.9",
1920
"js-yaml": "^4.1.0",

0 commit comments

Comments
 (0)