mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-04-09 20:29:15 +02:00
rework discovery page
This commit is contained in:
parent
5ea368b0a8
commit
c7d48b2997
@ -4,7 +4,7 @@
|
||||
:items="data"
|
||||
:sort-by="sortBy"
|
||||
:sort-type="sortType">
|
||||
<template #item-content="{content, author, authorurl, avatar, indicator, links}">
|
||||
<template #item-content="{content, author, authorurl, avatar, indicator, links, lud16, id, authorid}">
|
||||
|
||||
<div class="playeauthor-wrapper">
|
||||
|
||||
@ -18,15 +18,22 @@
|
||||
{{indicator.time.split("T")[0].split("-")[2].trim()}}.{{indicator.time.split("T")[0].split("-")[1].trim()}}.{{indicator.time.split("T")[0].split("-")[0].trim().slice(2)}}
|
||||
</div>
|
||||
</div>
|
||||
<!--.substr(0, 320) + "\u2026"}} -->
|
||||
|
||||
<p>{{content.substr(0, 320) + "\u2026"}}</p>
|
||||
<h3 v-html="StringUtil.parseImages(content)"></h3>
|
||||
<!--<p>{{content.substr(0, 320) + "\u2026"}}</p> -->
|
||||
<div style="padding: 2px; text-align: left;" >
|
||||
<a class="menusmall" :href="links.uri" target="_blank">Client</a>
|
||||
<a class="menusmall" :href="links.njump" target="_blank">NJump</a>
|
||||
<!--<a class="menusmall" :href="links.highlighter" target="_blank">Highlighter</a> -->
|
||||
<a class="menusmall":href="links.nostrudel" target="_blank">Nostrudel</a>
|
||||
</div>
|
||||
|
||||
|
||||
<!--<div style="margin-left: auto; margin-right: 10px;" class=" justify-end mt-auto" @click="zap(lud16, id.toHex(), authorid)">
|
||||
<svg style="margin-top:3px" xmlns="http://www.w3.org/2000/svg" width="14" height="16" fill="currentColor" class="bi bi-lightning" viewBox="0 0 16 20">
|
||||
<path d="M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641zM6.374 1 4.168 8.5H7.5a.5.5 0 0 1 .478.647L6.78 13.04 11.478 7H8a.5.5 0 0 1-.474-.658L9.306 1z"/></svg></div>-->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<!--<template #expand="item">
|
||||
<div style="padding: 15px; text-align: left;" >
|
||||
@ -51,6 +58,9 @@ import type {Header, Item, SortType} from "vue3-easy-data-table";
|
||||
import store from '../store';
|
||||
import {types} from "sass";
|
||||
import Null = types.Null;
|
||||
import StringUtil from "@/components/helper/string";
|
||||
import {copyinvoice, createBolt11Lud16, parseandreplacenpubs, zaprequest} from "@/components/helper/Helper.vue";
|
||||
import {requestProvider} from "webln";
|
||||
defineProps<{
|
||||
data?: []
|
||||
|
||||
@ -65,6 +75,32 @@ const headers: Header[] = [
|
||||
];
|
||||
|
||||
|
||||
async function zap(lud16, id, authorid){
|
||||
//let invoice = await zaprequest(lud16, 21 , "with love from noogle.lol", id, authorid, store.state.relays) //Not working yet
|
||||
if(lud16 != Null && lud16 != ""){
|
||||
|
||||
|
||||
let invoice = await createBolt11Lud16(lud16, 21)
|
||||
let webln;
|
||||
try {
|
||||
webln = await requestProvider();
|
||||
} catch (err) {
|
||||
await copyinvoice(invoice)
|
||||
}
|
||||
if (webln) {
|
||||
try{
|
||||
let response = await webln.sendPayment(invoice)
|
||||
|
||||
}
|
||||
catch(err){
|
||||
console.log(err)
|
||||
await copyinvoice(invoice)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@ -22,7 +22,7 @@ import {data} from "autoprefixer";
|
||||
import {requestProvider} from "webln";
|
||||
import Newnote from "@/components/Newnote.vue";
|
||||
import SummarizationGeneration from "@/components/SummarizationGeneration.vue"
|
||||
import {post_note, schedule, copyurl, copyinvoice, sleep, getEvents, get_user_infos, nextInput, createBolt11Lud16, getEventsOriginalOrder} from "../components/helper/Helper.vue"
|
||||
import {post_note, schedule, copyurl, copyinvoice, sleep, getEvents, get_user_infos, nextInput, createBolt11Lud16, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue"
|
||||
import amberSignerService from "./android-signer/AndroidSigner";
|
||||
import StringUtil from "@/components/helper/string.ts";
|
||||
|
||||
@ -217,17 +217,20 @@ async function listen() {
|
||||
let nip19bech32 = nip19.toBech32()
|
||||
let picture = p === undefined ? "../assets/nostr-purple.svg" : p["profile"]["picture"]
|
||||
let name = p === undefined ? bech32id : p["profile"]["name"]
|
||||
let authorid = evt.author.toHex()
|
||||
let highlighterurl = "https://highlighter.com/e/" + nip19bech32
|
||||
let njumpurl = "https://njump.me/" + nip19bech32
|
||||
let nostrudelurl = "https://nostrudel.ninja/#/n/" + bech32id
|
||||
let uri = "nostr:" + bech32id // nip19.toNostrUri()
|
||||
let lud16 = "" //"p["profile"]["lud16"]"
|
||||
|
||||
|
||||
if (items.find(e => e.id.toHex() === evt.id.toHex()) === undefined) {
|
||||
items.push({
|
||||
id: evt.id,
|
||||
content: evt.content,
|
||||
content: await parseandreplacenpubsName(evt.content),
|
||||
author: name,
|
||||
authorid: authorid,
|
||||
authorurl: "https://njump.me/" + evt.author.toBech32(),
|
||||
links: {
|
||||
"uri": uri,
|
||||
@ -237,7 +240,9 @@ async function listen() {
|
||||
},
|
||||
avatar: picture,
|
||||
index: index,
|
||||
indicator: {"time": evt.createdAt.toHumanDatetime(), "index": index}
|
||||
indicator: {"time": evt.createdAt.toHumanDatetime(), "index": index},
|
||||
lud16: lud16,
|
||||
|
||||
})
|
||||
index = index+1
|
||||
}
|
||||
@ -616,7 +621,7 @@ const submitHandler = async () => {
|
||||
|
||||
|
||||
|
||||
<div data-tip="Make Summarization" v-if="dvm.result.length > 0 && store.state.pubkey.toHex() !== Keys.parse('ece3c0aa759c3e895ecb3c13ab3813c0f98430c6d4bd22160b9c2219efc9cf0e').publicKey.toHex()" >
|
||||
<div data-tip="Make Summarization" v-if="dvm.status === 'finished' && store.state.pubkey.toHex() !== Keys.parse('ece3c0aa759c3e895ecb3c13ab3813c0f98430c6d4bd22160b9c2219efc9cf0e').publicKey.toHex()" >
|
||||
<button @click="openModal(dvm.result)" class="w-8 h-8 rounded-full bg-nostr border-white border-1 text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black tooltip" data-top='Share' aria-label="make note" role="button">
|
||||
<svg class="w-4 h-4 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path d="M9 19V.352A3.451 3.451 0 0 0 7.5 0a3.5 3.5 0 0 0-3.261 2.238A3.5 3.5 0 0 0 2.04 6.015a3.518 3.518 0 0 0-.766 1.128c-.042.1-.064.209-.1.313a3.34 3.34 0 0 0-.106.344 3.463 3.463 0 0 0 .02 1.468A4.016 4.016 0 0 0 .3 10.5l-.015.036a3.861 3.861 0 0 0-.216.779A3.968 3.968 0 0 0 0 12a4.032 4.032 0 0 0 .107.889 4 4 0 0 0 .2.659c.006.014.015.027.021.041a3.85 3.85 0 0 0 .417.727c.105.146.219.284.342.415.072.076.148.146.225.216.1.091.205.179.315.26.11.081.2.14.308.2.02.013.039.028.059.04v.053a3.506 3.506 0 0 0 3.03 3.469 3.426 3.426 0 0 0 4.154.577A.972.972 0 0 1 9 19Zm10.934-7.68a3.956 3.956 0 0 0-.215-.779l-.017-.038a4.016 4.016 0 0 0-.79-1.235 3.417 3.417 0 0 0 .017-1.468 3.387 3.387 0 0 0-.1-.333c-.034-.108-.057-.22-.1-.324a3.517 3.517 0 0 0-.766-1.128 3.5 3.5 0 0 0-2.202-3.777A3.5 3.5 0 0 0 12.5 0a3.451 3.451 0 0 0-1.5.352V19a.972.972 0 0 1-.184.546 3.426 3.426 0 0 0 4.154-.577A3.506 3.506 0 0 0 18 15.5v-.049c.02-.012.039-.027.059-.04.106-.064.208-.13.308-.2s.214-.169.315-.26c.077-.07.153-.14.225-.216a4.007 4.007 0 0 0 .459-.588c.115-.176.215-.361.3-.554.006-.014.015-.027.021-.041.087-.213.156-.434.205-.659.013-.057.024-.115.035-.173.046-.237.07-.478.073-.72a3.948 3.948 0 0 0-.066-.68Z"/>
|
||||
|
@ -6,6 +6,7 @@ import {Duration, Event, EventBuilder, EventId, Filter, Keys, PublicKey, Tag, Ti
|
||||
import miniToastr from "mini-toastr/mini-toastr";
|
||||
import VueNotifications from "vue-notifications";
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: "posting"
|
||||
})
|
||||
@ -164,13 +165,17 @@ export async function parseandreplacenpubs(note){
|
||||
for (let word in myArray){
|
||||
if(myArray[word].startsWith("nostr:npub")){
|
||||
//console.log(myArray[word])
|
||||
let pk = PublicKey.parse(myArray[word].replace("nostr:", ""))
|
||||
//console.log(pk.toBech32())
|
||||
let profiles = await get_user_infos([pk])
|
||||
//console.log(profiles[0].profile.nip05)
|
||||
myArray[word] = profiles[0].profile.nip05 // replace with nip05 for now
|
||||
|
||||
// <href>='https://njump.com/'>test[0].profile.nip05</href>test[0].profile.nip05
|
||||
//console.log(pk.toBech32())
|
||||
try{
|
||||
let pk = PublicKey.parse(myArray[word].replace("nostr:", ""))
|
||||
let profiles = await get_user_infos([pk])
|
||||
//console.log(profiles[0].profile.nip05)
|
||||
myArray[word] = profiles[0].profile.nip05 // replace with nip05 for now
|
||||
}
|
||||
catch{
|
||||
|
||||
}
|
||||
}
|
||||
finalnote = finalnote + myArray[word] + " "
|
||||
|
||||
@ -179,6 +184,99 @@ export async function parseandreplacenpubs(note){
|
||||
return finalnote.trimEnd()
|
||||
}
|
||||
|
||||
var getHtmlBlock = function(dataType) {
|
||||
return `<div class="icon negative big toleft" id="cancel-btn"><i class="fas fa-minus-circle"></i></div><div class="icon add big toleft"><i class="fas fa-check-circle"></i></div><input type="text" class="contact-input" style="margin-bottom: 5px;" maxlength="50" name="my-contact-phone" data-name="Name" placeholder="${dataType}">`;
|
||||
};
|
||||
export async function parseandreplacenpubsName(note){
|
||||
|
||||
const myArray = note.split(" ");
|
||||
let finalnote = ""
|
||||
for (let word in myArray){
|
||||
if(myArray[word].startsWith("nostr:npub")){
|
||||
//console.log(myArray[word])
|
||||
|
||||
//console.log(pk.toBech32())
|
||||
try{
|
||||
let pk = PublicKey.parse(myArray[word].replace("nostr:", ""))
|
||||
let profiles = await get_user_infos([pk])
|
||||
//console.log(profiles[0].profile.nip05)
|
||||
|
||||
myArray[word] = profiles[0].profile.name
|
||||
|
||||
|
||||
// profiles[0].profile.name // replace with nip05 for now
|
||||
}
|
||||
catch{
|
||||
|
||||
}
|
||||
}
|
||||
finalnote = finalnote + myArray[word] + " "
|
||||
|
||||
}
|
||||
|
||||
return finalnote.trimEnd()
|
||||
}
|
||||
|
||||
|
||||
export async function zaprequest(lud16, amount, content, zapped_event_id, zapped_user_id, relay_list){
|
||||
let url = ""
|
||||
if (lud16.toString().includes('@')){
|
||||
url = 'https://' + lud16.toString().split('@')[1] + '/.well-known/lnurlp/' + lud16.toString().split('@')[0]
|
||||
}
|
||||
else{
|
||||
return None
|
||||
}
|
||||
try{
|
||||
let response = await fetch(url)
|
||||
let ob = JSON.parse(response.content)
|
||||
let callback = ob["callback"]
|
||||
let encoded_lnurl = "" // lnurl.encode(url)
|
||||
let amount_tag = Tag.parse(['amount', (amount * 1000).toString()])
|
||||
let relays_tag = Tag.parse(['relays', (relay_list).toString()])
|
||||
let lnurl_tag = Tag.parse(['lnurl', encoded_lnurl])
|
||||
let tags = []
|
||||
let p_tag = Tag.parse(['p', zapped_user_id])
|
||||
if (zapped_event_id !== None){
|
||||
let e_tag = Tag.parse(['e', zapped_event_id])
|
||||
tags = [amount_tag, relays_tag, p_tag, e_tag, lnurl_tag]
|
||||
}
|
||||
|
||||
else{
|
||||
tags = [amount_tag, relays_tag, p_tag, lnurl_tag]
|
||||
}
|
||||
|
||||
|
||||
//todo
|
||||
/* if zaptype == "private":
|
||||
key_str = keys.secret_key().to_hex() + zapped_event.id().to_hex() + str(zapped_event.created_at().as_secs())
|
||||
encryption_key = sha256(key_str.encode('utf-8')).hexdigest()
|
||||
|
||||
zap_request = EventBuilder(9733, content,
|
||||
[p_tag, e_tag]).to_event(keys).as_json()
|
||||
keys = Keys.parse(encryption_key)
|
||||
encrypted_content = enrypt_private_zap_message(zap_request, keys.secret_key(), zapped_event.author())
|
||||
anon_tag = Tag.parse(['anon', encrypted_content])
|
||||
tags.append(anon_tag)
|
||||
content = "" */
|
||||
|
||||
|
||||
|
||||
let client = store.state.client
|
||||
let zap_request = client.EventBuilder(9734, content,
|
||||
tags).toSignedEvent().asJson()
|
||||
|
||||
response = await fetch(callback + "?amount=" + (Number.parse(amount) * 1000).toString() + "&nostr=" + encodeURI(zap_request) + "&lnurl=" + encoded_lnurl)
|
||||
ob = JSON.parse(response.content)
|
||||
return ob["pr"]
|
||||
}
|
||||
catch(error){
|
||||
console.log("ZAP REQUEST: " + e)
|
||||
}
|
||||
|
||||
|
||||
|
||||
return None
|
||||
}
|
||||
export async function createBolt11Lud16(lud16, amount) {
|
||||
let url;
|
||||
if (lud16.includes('@')) { // LNaddress
|
||||
|
@ -1,5 +1,6 @@
|
||||
const Regex_Url_Str = "(https:\\/\\/)"+ "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,})+[\\/]{0,1}" // domain name
|
||||
|
||||
const Regex_Url_Str = "^https?:\/\/(?:.*\/)?[^\/.]+$" // domain name
|
||||
const Regex_Url_Img = "(https?:\\/\\/.*\\.(?:png|jpg|jpeg|webp|gif))" // domain name
|
||||
const Regex_Url_Video = "(https?:\\/\\/.*\\.(?:mp4|mov|avi))" // domain name
|
||||
|
||||
;
|
||||
|
||||
@ -8,6 +9,10 @@ const Regex_Nip05_Str= "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^
|
||||
const StringUtil = {
|
||||
isValidUrl: (str: string): boolean => new RegExp(Regex_Url_Str, "i").test(str),
|
||||
parseHyperlinks: (str: string): string => str.replace(new RegExp(Regex_Url_Str, "gim"), "<a class='purple' target=\"_blank\" rel=\"noreferrer\" href=\"$&\">$&</a>").replace(new RegExp(Regex_Nip05_Str, "gim"), "<a class='purple' target=\"_blank\" rel=\"noreferrer\" href=\"https://njump.me/$&\">$&</a>"),
|
||||
parseImages: (str: string): string => str.replace(new RegExp(Regex_Url_Img, "gim"), "<img src='$&'/> ").replace(new RegExp(Regex_Url_Video, "gim"), "<video controls muted autoplay src=\"$&\"></video>").replace(new RegExp(Regex_Url_Str, "gim"), "<a class='purple' target=\"_blank\" rel=\"noreferrer\" href=\"$&\">$&</a>"),
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default StringUtil;
|
Loading…
x
Reference in New Issue
Block a user