From 03019645fb7842bec465f36e47c043ae00c2d3fd Mon Sep 17 00:00:00 2001 From: zmeyer44 Date: Tue, 17 Oct 2023 11:08:27 -0400 Subject: [PATCH] updated landing and service worker --- app/(app)/(profile)/{ => [npub]}/layout.tsx | 0 app/(app)/(profile)/[npub]/page.tsx | 5 +- app/(app)/list/[naddr]/page.tsx | 2 +- app/(landing)/_page.tsx | 213 +++++++++++++ app/(landing)/page.tsx | 313 ++++++++------------ public/service-worker.js | 48 +++ 6 files changed, 383 insertions(+), 198 deletions(-) rename app/(app)/(profile)/{ => [npub]}/layout.tsx (100%) create mode 100644 app/(landing)/_page.tsx create mode 100644 public/service-worker.js diff --git a/app/(app)/(profile)/layout.tsx b/app/(app)/(profile)/[npub]/layout.tsx similarity index 100% rename from app/(app)/(profile)/layout.tsx rename to app/(app)/(profile)/[npub]/layout.tsx diff --git a/app/(app)/(profile)/[npub]/page.tsx b/app/(app)/(profile)/[npub]/page.tsx index cced53c..f1288fc 100644 --- a/app/(app)/(profile)/[npub]/page.tsx +++ b/app/(app)/(profile)/[npub]/page.tsx @@ -19,8 +19,11 @@ export default function ProfilePage({ }) { const [activeTab, setActiveTab] = useState("feed"); console.log("calling with ", npub); + if (npub === "service-worker.js") { + throw new Error("Invalid list"); + } const { type, data } = nip19.decode(npub); - console.log("RES", data); + if (type !== "npub") { throw new Error("Invalid list"); } diff --git a/app/(app)/list/[naddr]/page.tsx b/app/(app)/list/[naddr]/page.tsx index 95bb3a4..99b2a42 100644 --- a/app/(app)/list/[naddr]/page.tsx +++ b/app/(app)/list/[naddr]/page.tsx @@ -59,7 +59,7 @@ export default function ListPage({ ); } const noteIds = getTagsValues("e", event.tags).filter(Boolean); - + console.log("notes", event.tags); const title = getTagValues("title", event.tags) ?? getTagValues("name", event.tags) ?? diff --git a/app/(landing)/_page.tsx b/app/(landing)/_page.tsx new file mode 100644 index 0000000..8604f53 --- /dev/null +++ b/app/(landing)/_page.tsx @@ -0,0 +1,213 @@ +import { Button } from "@/components/ui/button"; +import Image from "next/image"; +import Link from "next/link"; + +export default function LandingPage() { + return ( +
+
+
+
+

+ Your Community, Where ever you are. +

+

+ Nostr allows you to truly own your community with a fully + decentralized social graph. Never get locked into a platform + again. +

+
+ + + +
+
+
+
+ + About nostr + +
+

+ Nostr is a simple, open protocol for decentralizing how + infomration is stored and retreived on the web. +

+

+ Rather that your user data being siloed by the big tech + companies whose platforms dominate our culture, nostr + distributes data across hundreds of relays that anyone can spin + up. +

+

+ This means that no single entity is ever in control of your + data. In other words: + + No more lock-in, Way more choices. + +

+
+
+
+ {/*
+
+
+ + About nostr + +
+

+ Nostr is a simple, open protocol for decentralizing how + infomration is stored and retreived on the web. +

+

+ Rather that your user data being siloed by the big tech + companies whose platforms dominate our culture, nostr + distributes data across hundreds of relays that anyone can + spin up. +

+

+ This means that no single entity is ever in control of your + data. In other words: + + No more lock-in, Way more choices. + +

+
+
+ +
+
+
+
+
+ + Why Bitcoin? + +
+

+ Nostr is a simple, open protocol for decentralizing how + infomration is stored and retreived on the web. +

+

+ Rather that your user data being siloed by the big tech + companies whose platforms dominate our culture, nostr + distributes data across hundreds of relays that anyone can + spin up. +

+

+ This means that no single entity is ever in control of your + data. In other words: + + No more lock-in, Way more choices. + +

+
+
+ +
+
+
+
+
+
+

+ Find out if you're the right fit. +

+

+ Nostr allows you to truly own your community with a fully + decentralized social graph. Never get locked into a platform + again. +

+
+ +
+
+
*/} +
+ {/*
+
+
+
+
+
+

+ It's about time +
+ Let's take a look. +

+
+ + Explore Now + + +
+
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
+
*/} +
+ ); +} diff --git a/app/(landing)/page.tsx b/app/(landing)/page.tsx index 8604f53..e5b7dfa 100644 --- a/app/(landing)/page.tsx +++ b/app/(landing)/page.tsx @@ -1,213 +1,134 @@ +import { useState } from "react"; import { Button } from "@/components/ui/button"; -import Image from "next/image"; -import Link from "next/link"; + +const navigation = [ + { name: "Product", href: "#" }, + { name: "Features", href: "#" }, + { name: "Marketplace", href: "#" }, + { name: "Company", href: "#" }, +]; export default function LandingPage() { return ( -
-
-
-
-

- Your Community, Where ever you are. -

-

- Nostr allows you to truly own your community with a fully - decentralized social graph. Never get locked into a platform - again. -

-
- - - -
-
-
-
- - About nostr - -
-

- Nostr is a simple, open protocol for decentralizing how - infomration is stored and retreived on the web. -

-

- Rather that your user data being siloed by the big tech - companies whose platforms dominate our culture, nostr - distributes data across hundreds of relays that anyone can spin - up. -

-

- This means that no single entity is ever in control of your - data. In other words: - - No more lock-in, Way more choices. - -

-
-
+
+
+ +
- {/*
-
-
-
-
- +
+
+
+ +
- -
-
-
-
- -
- -
- -
-
-
-
- -
- -
- -
-
-
-
- -
- -
- -
-
+
+
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+ +
-
*/} -
+ + ); } diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 0000000..864d7ef --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,48 @@ +console.log("Running service worker!!!"); +self.addEventListener("install", () => { + console.log("service worker installed"); +}); + +self.addEventListener("activate", () => { + console.log("service worker activated"); +}); + +self.addEventListener("push", function (event) { + const data = JSON.parse(event.data.text()); + event.waitUntil( + registration.showNotification(data.title, { + body: data.message, + icon: "/icon-192x192.png", + data: { + url: data.url ?? "/", + }, + }), + ); +}); + +self.addEventListener("notificationclick", function (event) { + event.notification.close(); + event.waitUntil( + clients + .matchAll({ type: "window", includeUncontrolled: true }) + .then(function (clientList) { + if (clientList.length > 0) { + let client = clientList[0]; + for (let i = 0; i < clientList.length; i++) { + if (clientList[i].focused) { + client = clientList[i]; + } + } + if (event.notification.data?.url) { + return client.navigate(event.notification.data.url); + } + return client.focus(); + } + if (event.notification.data?.url) { + const outcome = clients.openWindow(event.notification.data.url); + return outcome.navigate(event.notification.data.url); + } + return clients.openWindow("/"); + }), + ); +});