mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
search nostr plebs
This commit is contained in:
@@ -2,68 +2,191 @@
|
||||
{{-- HEADER --}}
|
||||
<livewire:frontend.header :country="null"/>
|
||||
|
||||
<div class="bg-21gray py-24 sm:py-32">
|
||||
<div class="mx-auto grid max-w-7xl gap-y-20 gap-x-8 px-6 lg:px-8 xl:grid-cols-3">
|
||||
<div class="bg-21gray py-24 sm:py-32"
|
||||
wire:ignore
|
||||
x-data="{
|
||||
plebsNpubs: @entangle('plebsNpubs'),
|
||||
plebs: [],
|
||||
ndk: null,
|
||||
search: '',
|
||||
ndkUser: null,
|
||||
nip07signer: null,
|
||||
currentUser: null,
|
||||
npubToFollow: null,
|
||||
currentFollows: null,
|
||||
get searchResults () {
|
||||
if (this.search === '') {
|
||||
return this.plebs;
|
||||
}
|
||||
|
||||
return this.plebs.filter(
|
||||
i => i.profile && i.profile.name.toLocaleLowerCase().includes(this.search.toLocaleLowerCase())
|
||||
);
|
||||
},
|
||||
async init() {
|
||||
this.ndk = new window.NDK({
|
||||
explicitRelayUrls: [
|
||||
'wss://eden.nostr.land',
|
||||
'wss://relay.snort.social',
|
||||
'wss://nostr.wine',
|
||||
'wss://nostr-pub.wellorder.net',
|
||||
'wss://nos.lol',
|
||||
'wss://offchain.pub',
|
||||
'wss://nostr.fmt.wiz.biz',
|
||||
'wss://nostr.einundzwanzig.space',
|
||||
'wss://relay.nostr.band',
|
||||
'wss://relay.damus.io',
|
||||
'wss://eden.nostr.land',
|
||||
'wss://nostr.codingarena.de',
|
||||
'wss://relay.primal.net',
|
||||
],
|
||||
});
|
||||
this.ndk.connect();
|
||||
this.plebsNpubs.forEach(async npub => {
|
||||
const ndkUser = this.ndk.getUser({
|
||||
npub,
|
||||
});
|
||||
await ndkUser.fetchProfile();
|
||||
if (ndkUser.profile.image) {
|
||||
ndkUser.profile.npub = npub;
|
||||
this.plebs.push(ndkUser);
|
||||
}
|
||||
});
|
||||
},
|
||||
login () {
|
||||
this.nip07signer = new window.NDKNip07Signer();
|
||||
this.ndk = new window.NDK({
|
||||
explicitRelayUrls: [
|
||||
'wss://eden.nostr.land',
|
||||
'wss://relay.snort.social',
|
||||
'wss://nostr.wine',
|
||||
'wss://nostr-pub.wellorder.net',
|
||||
'wss://nos.lol',
|
||||
'wss://offchain.pub',
|
||||
'wss://nostr.fmt.wiz.biz',
|
||||
'wss://nostr.einundzwanzig.space',
|
||||
'wss://relay.nostr.band',
|
||||
'wss://relay.damus.io',
|
||||
'wss://eden.nostr.land',
|
||||
'wss://nostr.codingarena.de',
|
||||
'wss://relay.primal.net',
|
||||
],
|
||||
signer: this.nip07signer
|
||||
});
|
||||
this.ndk.connect();
|
||||
this.nip07signer.user().then(async (user) => {
|
||||
if (!!user.npub) {
|
||||
this.currentUser = this.ndk.getUser({
|
||||
npub: user.npub,
|
||||
});
|
||||
await this.currentUser.fetchProfile();
|
||||
//this.currentFollows = await this.currentUser.follows();
|
||||
//this.plebs.forEach(pleb => {
|
||||
// console.log(this.currentFollows);
|
||||
// console.log(this.currentFollows.has(pleb));
|
||||
//});
|
||||
}
|
||||
});
|
||||
},
|
||||
async follow(npubToFollow) {
|
||||
this.followUser = this.ndk.getUser({
|
||||
npub: npubToFollow,
|
||||
});
|
||||
console.log(this.followUser);
|
||||
const follow = await this.currentUser.follow(this.followUser);
|
||||
console.log(follow);
|
||||
if(follow) {
|
||||
window.$wireui.notify({title:'{{ __('Followed!') }}',icon:'success'});
|
||||
} else {
|
||||
window.$wireui.notify({title:'{{ __('Follow failed!') }}',icon:'error'});
|
||||
}
|
||||
},
|
||||
}"
|
||||
>
|
||||
<div class="mx-auto grid max-w-7xl gap-y-20 gap-x-8 px-6 lg:px-8 xl:grid-cols-2">
|
||||
<div class="max-w-2xl">
|
||||
<h2 class="text-3xl font-bold tracking-tight text-gray-200 sm:text-4xl">{{ __('Follow Einundzwanzig plebs') }}</h2>
|
||||
<p class="mt-6 text-lg leading-8 text-gray-300">
|
||||
{{ __('Eine Übersicht aller Einundzwanzig Plebs, die ihren npub geteilt haben.') }}
|
||||
{{ __('An overview of all Einundzwanzig plebs who have shared their npub.') }}
|
||||
</p>
|
||||
</div>
|
||||
<ul
|
||||
wire:ignore
|
||||
x-data="{
|
||||
plebsNpubs: @entangle('plebsNpubs'),
|
||||
plebs: [],
|
||||
ndk: null,
|
||||
ndkUser: null,
|
||||
nip07signer: null,
|
||||
async init() {
|
||||
this.ndk = new window.NDK({
|
||||
explicitRelayUrls: ['wss://nos.lol', 'wss://eden.nostr.land', 'wss://relay.damus.io', 'wss://nostr.einundzwanzig.space'],
|
||||
});
|
||||
this.ndk.connect();
|
||||
this.plebsNpubs.forEach(async npub => {
|
||||
const ndkUser = this.ndk.getUser({
|
||||
npub,
|
||||
});
|
||||
await ndkUser.fetchProfile();
|
||||
if (ndkUser.profile.image) {
|
||||
ndkUser.profile.npub = npub;
|
||||
this.plebs.push(ndkUser.profile);
|
||||
console.log(ndkUser.profile);
|
||||
}
|
||||
});
|
||||
},
|
||||
}"
|
||||
role="list" class="grid gap-x-8 gap-y-12 sm:grid-cols-2 sm:gap-y-16 xl:col-span-2">
|
||||
|
||||
<template x-for="pleb in plebs">
|
||||
<li class="text-white cursor-pointer"
|
||||
x-data="{
|
||||
textToCopy: pleb.npub,
|
||||
}"
|
||||
@click.prevent="window.navigator.clipboard.writeText(textToCopy);window.$wireui.notify({title:'{{ __('NPUB copied!') }}',icon:'success'});"
|
||||
>
|
||||
<div class="flex items-center gap-x-6">
|
||||
<img class="h-16 w-16 rounded-full"
|
||||
:src="pleb.image"
|
||||
:alt="pleb.name">
|
||||
<div>
|
||||
<h3
|
||||
x-text="pleb.name"
|
||||
class="text-base font-semibold leading-7 tracking-tight text-gray-200">
|
||||
</h3>
|
||||
<p
|
||||
x-text="pleb.nip05"
|
||||
class="text-sm font-semibold leading-6 text-amber-600">
|
||||
</p>
|
||||
</div>
|
||||
@auth
|
||||
<p class="mt-6 text-lg leading-8 text-gray-300">
|
||||
{{ __('Go to your profile and add your Nostr-npub. After that you can also log in with Nostr here on the portal.') }}
|
||||
<br>
|
||||
<a class="text-amber-500" href="{{ route('profile.show') }}">{{ __('Profile') }}</a>
|
||||
</p>
|
||||
@endauth
|
||||
{{--<p class="mt-8">
|
||||
<x-button x-show="!currentUser" primary label="{{ __('NIP-07 Login') }}" icon="login"
|
||||
@click="login()"/>
|
||||
</p>--}}
|
||||
<h3 x-show="currentUser && currentUser.profile" class="py-4 text-gray-100 text-2xl">
|
||||
{{ __('Logged into Nostr as:') }}
|
||||
</h3>
|
||||
<div
|
||||
x-show="currentUser && currentUser.profile"
|
||||
class="block flex-shrink-0 mt-8">
|
||||
<div class="flex items-center">
|
||||
<div>
|
||||
<img class="inline-block h-9 w-9 rounded-full"
|
||||
:src="currentUser.profile.image"
|
||||
:alt="currentUser.profile.image"
|
||||
>
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
<div class="ml-3">
|
||||
<p class="text-sm font-medium text-gray-100" x-text="currentUser.profile.name"></p>
|
||||
<p class="text-xs font-medium text-gray-200" x-text="currentUser.profile.nip05"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="py-4">
|
||||
<x-input x-ref="searchInput" x-model="search" placeholder="{{ __('Search') }}"/>
|
||||
</div>
|
||||
|
||||
<ul role="list" class="divide-y divide-gray-100">
|
||||
|
||||
<template x-for="pleb in searchResults">
|
||||
<li class="flex items-center justify-between gap-x-6 py-5">
|
||||
<div class="flex min-w-0 gap-x-4">
|
||||
<img class="h-12 w-12 flex-none rounded-full bg-gray-50"
|
||||
:src="pleb.profile.image"
|
||||
:alt="pleb.profile.name"
|
||||
>
|
||||
<div class="min-w-0 flex-auto">
|
||||
<p class="text-sm font-semibold leading-6 text-gray-100" x-text="pleb.profile.name"></p>
|
||||
<p class="mt-1 truncate text-xs leading-5 text-gray-200"
|
||||
x-text="pleb.profile.nip05"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div>
|
||||
<div
|
||||
x-data="{
|
||||
textToCopy: pleb.profile.npub,
|
||||
}"
|
||||
@click.prevent="window.navigator.clipboard.writeText(textToCopy);window.$wireui.notify({title:'{{ __('NPUB copied!') }}',icon:'success'});"
|
||||
class="cursor-pointer whitespace-no-wrap rounded-full bg-white px-2.5 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">
|
||||
Copy
|
||||
</div>
|
||||
</div>
|
||||
{{--<div>
|
||||
<div
|
||||
x-show="currentUser"
|
||||
@click.prevent="follow(pleb.profile.npub)"
|
||||
class="cursor-pointer whitespace-no-wrap rounded-full bg-white px-2.5 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">
|
||||
Follow
|
||||
</div>
|
||||
</div>--}}
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user