noogle: render optimizations

This commit is contained in:
Believethehype 2024-03-10 08:46:01 +01:00
parent c80275b74c
commit 4120fec8e1
6 changed files with 40 additions and 15 deletions

View File

@ -26,7 +26,7 @@ import { ref } from "vue";
import ModalComponent from "../components/Newnote.vue";
import VueDatePicker from "@vuepic/vue-datepicker";
import {timestamp} from "@vueuse/core";
import {post_note, schedule, copyinvoice, copyurl, sleep, nextInput, get_user_infos, createBolt11Lud16} from "../components/helper/Helper.vue"
import {post_note, schedule, copyinvoice, copyurl, sleep, nextInput, get_user_infos, createBolt11Lud16, zaprequest} from "../components/helper/Helper.vue"
import StringUtil from "@/components/helper/string.ts";
@ -153,7 +153,8 @@ async function listen() {
about: "",
image: "",
amount: 0,
bolt11: ""
bolt11: "",
nip90params: {},
}
for (const tag in event.tags) {
@ -184,7 +185,9 @@ async function listen() {
let lud16 = current.profile.lud16
if (lud16 !== null && lud16 !== ""){
console.log("LUD16: " + lud16)
jsonentry.bolt11 = await createBolt11Lud16(lud16, jsonentry.amount) //todo replace with zaprequest
//jsonentry.bolt11 = await createBolt11Lud16(lud16, jsonentry.amount) //todo replace with zaprequest
jsonentry.bolt11 = await zaprequest(lud16, jsonentry.amount , "zapped from noogle.lol", event.id.toHex(), event.author.toHex(), store.state.relays) //Not working yet
console.log(jsonentry.bolt11)
if(jsonentry.bolt11 === ""){
status = "error"
@ -210,8 +213,8 @@ async function listen() {
jsonentry.name = el.name
jsonentry.about = el.about
jsonentry.image = el.image
jsonentry.nip90Params = el.nip90Params
console.log(jsonentry)
}
}
@ -396,7 +399,12 @@ const submitHandler = async () => {
<h2 className="card-title">{{ dvm.name }}</h2>
</div>
<h3 class="fa-cut" v-html="StringUtil.parseHyperlinks(dvm.about)"></h3>
<h3 class="fa-cut" v-html="StringUtil.parseHyperlinks(dvm.about)"></h3>
<!-- <p>{{dvm.nip90Params}}</p> -->
<!-- <div v-for="param in dvm.nip90Params">
<p>{{param}}</p>
</div> -->

View File

@ -586,6 +586,7 @@ export default {
jsonentry.about = await parseandreplacenpubs(jsonentry.about)
jsonentry.event = entry.asJson()
jsonentry.kind = entry.tags[tag].asVec()[1]
//jsonentry.nip90Params = JSON.parse(jsonentry.nip90Params)
nip89dvms.push(jsonentry);
}
catch (error){

View File

@ -21,6 +21,7 @@
<!--.substr(0, 320) + "\u2026"}} -->
<h3 v-html="StringUtil.parseImages(content)"></h3>
<!-- <h3>{{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>
@ -28,7 +29,7 @@
<!--<a class="menusmall" :href="links.highlighter" target="_blank">Highlighter</a> -->
<a class="menusmall":href="links.nostrudel" target="_blank">Nostrudel</a>
<div class="flex" v-if="!zapped" @click="zap(lud16, id, authorid, author)">
<div class="flex" v-if="!zapped" @click="zap(lud16, id, authorid)">
<div style="margin-left: auto; margin-right: 5px; float: left;">
<svg style="margin-top:4px" 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>
@ -36,7 +37,7 @@
<p style="float: left;">{{zapAmount/1000}}</p>
</div>
</div>
<div class="flex" v-if="zapped" @click="zap(lud16, id, authorid, author)" >
<div class="flex" v-if="zapped" @click="zap(lud16, id, authorid)" >
<div style="margin-left: auto; margin-right: 5px;">
<svg style="margin-top:4px" xmlns="http://www.w3.org/2000/svg" width="14" height="16" class="bi bi-lightning fill-amber-400" 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>
@ -82,7 +83,7 @@ const headers: Header[] = [
];
async function zap(lud16, eventid, authorid, author){
async function zap(lud16, eventid, authorid){
if(lud16 != Null && lud16 != ""){
let invoice = await zaprequest(lud16, 21 , "with love from noogle.lol", eventid, authorid, store.state.relays) //Not working yet
@ -172,7 +173,7 @@ async function zap(lud16, eventid, authorid, author){
}
.customize-table {
width: auto;
--easy-table-border: 2px solid #000000;
--easy-table-border: 2px solid bg-base;
--easy-table-row-border: 1px solid #000000;
--easy-table-header-font-size: 14px;

View File

@ -246,10 +246,23 @@ export async function parseandreplacenpubs(note){
export async function parseandreplacenpubsName(note){
const myArray = note.split(" ");
const myArray = note.split(/\n | \r | /);
let finalnote = ""
for (let word in myArray){
if(myArray[word].startsWith("nostr:npub")){
if (myArray[word].startsWith("https")){
myArray[word] = myArray[word] + "\n"
}
if(myArray[word].startsWith("nostr:note")){
myArray[word] = "<a class='purple' target=\"_blank\" href='https://njump.me/" + myArray[word].replace("nostr:", "")+ "'>" +myArray[word].replace("nostr:", "") + "</a> "
}
else if(myArray[word].startsWith("nostr:nevent")){
myArray[word] = "<a class='purple' target=\"_blank\" href='https://njump.me/" + myArray[word].replace("nostr:", "")+ "'>" +myArray[word].replace("nostr:", "") + "</a> "
}
else if(myArray[word].startsWith("nostr:npub")){
//console.log(myArray[word])
//console.log(pk.toBech32())
@ -258,7 +271,8 @@ export async function parseandreplacenpubsName(note){
let profiles = await get_user_infos([pk])
//console.log(profiles[0].profile.nip05)
myArray[word] = profiles[0].profile.name
// myArray[word] = "<a class='purple' target=\"_blank\" href=\"https://njump.com/" + myArray[word].replace("nostr:", "") +" \">" + profiles[0].profile.name + "</a> "
myArray[word] = "<a class='purple' target=\"_blank\" href='https://njump.me/" + myArray[word].replace("nostr:", "")+ "'>" + profiles[0].profile.name + "</a> "
// profiles[0].profile.name // replace with nip05 for now

View File

@ -9,9 +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_Urlw_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>"),
parseHyperlinks: (str: string): string => str.replace(new RegExp(Regex_Urlw_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> "),
//parseImages: (str: string): string => str.replace("\n", " ").replace(new RegExp(Regex_Url_Img, "gim"), "<img src='$&'/> ")
};

View File

@ -11,7 +11,7 @@ import {isVisible} from "bootstrap/js/src/util/index.js";
</div>
<div className="flex-1">
<router-link class="menu" to="/">Noogle</router-link>
<router-link class="menu" to="/">Search</router-link>
<router-link class="menu" to="/discover">Discover</router-link>
<router-link class="menu" to="/image">ImageGen</router-link>
<!--<router-link class="menu" to="/about">About</router-link> -->