-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
202 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ users.json | |
khatru-pyramid | ||
.env | ||
db | ||
*_templ.go |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nbd-wtf/go-nostr/sdk" | ||
) | ||
|
||
templ inviteTreePage(loggedUser string) { | ||
@layout(loggedUser) { | ||
<div> | ||
if loggedUser != "" && (loggedUser == s.RelayPubkey || !hasInvitedAtLeast(loggedUser, s.MaxInvitesPerPerson)) { | ||
<form | ||
hx-post="/add-to-whitelist" | ||
hx-trigger="submit" | ||
hx-target="#tree" | ||
_="on htmx:afterRequest(elt, successful) if successful and elt is I call I.reset()" | ||
class="flex justify-center" | ||
> | ||
<input | ||
type="text" | ||
name="pubkey" | ||
placeholder="npub1..." | ||
class="w-96 rounded-md border-0 p-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600" | ||
/> | ||
<button | ||
type="submit" | ||
class="rounded-md text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 ml-2 p-2 bg-white hover:bg-gray-50" | ||
> | ||
invite | ||
</button> | ||
</form> | ||
} | ||
<div id="tree" class="mt-3 flex justify-center"> | ||
@inviteTreeComponent("", loggedUser) | ||
</div> | ||
</div> | ||
} | ||
} | ||
|
||
templ inviteTreeComponent(inviter string, loggedUser string) { | ||
<ul> | ||
for pubkey, invitedBy := range whitelist { | ||
if invitedBy == inviter { | ||
<li class="ml-6"> | ||
@userNameComponent(sys.FetchProfileMetadata(ctx, pubkey)) | ||
if isAncestorOf(loggedUser, pubkey) && loggedUser != "" { | ||
<button | ||
class="rounded-md text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 px-2 ml-2 bg-red-100 hover:bg-red-300" | ||
hx-post="/remove-from-whitelist" | ||
hx-trigger="click" | ||
hx-target="#tree" | ||
hx-vals={ fmt.Sprintf(`{"pubkey": "%s"}`, pubkey) } | ||
> | ||
remove | ||
</button> | ||
} | ||
@inviteTreeComponent(pubkey, loggedUser) | ||
</li> | ||
} | ||
} | ||
</ul> | ||
} | ||
|
||
templ userNameComponent(profile sdk.ProfileMetadata) { | ||
<a href={ templ.URL("https://nosta.me/" + profile.Npub()) } target="_blank" class="font-mono py-1"> | ||
<span title={ profile.Npub() }>{ profile.ShortName() }</span> | ||
</a> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package main | ||
|
||
templ layout(loggedUser string) { | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"/> | ||
<title>{ s.RelayName }</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
</head> | ||
<body class="max-w-screen-lg px-3 mx-auto"> | ||
<div class="mx-auto my-6 text-center"> | ||
<h1 class="font-bold text-2xl">{ s.RelayName }</h1> | ||
if s.RelayDescription != "" { | ||
<p class="text-lg">{ s.RelayDescription }</p> | ||
} | ||
</div> | ||
<nav class="flex flex-1 items-center justify-center"> | ||
<a href="/" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium" hx-boost="true" hx-target="main" hx-select="main">invite tree</a> | ||
<a href="/browse" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium">browse</a> | ||
<a href="/reports" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium" hx-boost="true" hx-target="main" hx-select="main">reports</a> | ||
if loggedUser == s.RelayPubkey { | ||
<a href="/cleanup" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium">clear stuff</a> | ||
} | ||
<a | ||
href="#" | ||
class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium" | ||
_=" | ||
on click if my innerText is equal to 'login' | ||
get window.nostr.signEvent({created_at: Math.round(Date.now()/1000), kind: 27235, tags: [['domain', '{ s.Domain }']], content: ''}) | ||
then get JSON.stringify(it) | ||
then set cookies['nip98'] to it | ||
otherwise | ||
call cookies.clear('nip98') | ||
end | ||
then call location.reload() | ||
on load | ||
get cookies['nip98'] | ||
then if it is undefined | ||
set my innerText to 'login' | ||
otherwise | ||
set my innerText to 'logout' | ||
" | ||
></a> | ||
</nav> | ||
<main class="m-4"> | ||
{ children... } | ||
</main> | ||
<p class="text-end my-4 text-sm"> | ||
powered by | ||
<a href="https://github.com/github-tijlxyz/khatru-pyramid" class="hover:underline cursor-pointer text-blue-500">khatru-pyramid</a> | ||
</p> | ||
</body> | ||
</html> | ||
} |
Oops, something went wrong.