no_name on Nostr: could this work? request some kind of instruction json from server it has ...
could this work?
request some kind of instruction json from server
it has instructions how to fetch preview for certain url
quick draft:
url for which we want to resolve #preview img:
https://domain.ext/app.html#12345let preview_instruction = await fetch("
https://domain.ext/preview.json";)
let socket = new WebSocket(preview_instruction.url)
// we take parameter(s) from url hash and add these to preview instruction query
let preview_query = preview_instruction.query[preview_instruction.key] = 12345
socket.onopen = function(){
// send preview instruction query with dynamically populated parameters
this.send(preview_query)
}
socket.onmessage = function(e){
// we receive preview image data
let preview_img = JSON.parse(e.data)[preview_instruction.response_key])
}
here is a challenge for fellow #devs
solve link #previews in era of dynamic #webapps
do not rely on server
app is hosted in #ipfs. server is dump
Published at
2023-12-30 12:32:03Event JSON
{
"id": "856a1ad7a32b0c7827ce5c8b8dfef6693482744ec00cd65287615f7ed4df52e9",
"pubkey": "ae8942b6dd585d633e7881791ab2fbde9edcb76dff5f0388872394a08132adf8",
"created_at": 1703939523,
"kind": 1,
"tags": [
[
"q",
"781d8aa2f57b8d07cf71dd5a48ee75e8ffcd9dd7f0a3c64f44922144489819b1",
"wss://relay.nostr.band/"
],
[
"t",
"preview"
],
[
"t",
"12345"
]
],
"content": "could this work?\n\nrequest some kind of instruction json from server\nit has instructions how to fetch preview for certain url\n\nquick draft:\n\nurl for which we want to resolve #preview img: https://domain.ext/app.html#12345\n\nlet preview_instruction = await fetch(\"https://domain.ext/preview.json\")\nlet socket = new WebSocket(preview_instruction.url)\n\n// we take parameter(s) from url hash and add these to preview instruction query\nlet preview_query = preview_instruction.query[preview_instruction.key] = 12345\n\nsocket.onopen = function(){\n // send preview instruction query with dynamically populated parameters\n this.send(preview_query)\n}\nsocket.onmessage = function(e){\n // we receive preview image data\n let preview_img = JSON.parse(e.data)[preview_instruction.response_key])\n}\nnostr:note10qwc4gh40wxs0nm3m4dy3mn4arlum8wh7z3uvn6yjgs5gjycrxcshlasye",
"sig": "f47be68489623050c1ce68eeef2803e503e0adbfc5d4708b42978de223e3ec7911be61064694bdd1b357799d5870c6f541d15a2ead98010cba24dfb0cf12308a"
}