Marcelo-Theodoro / nnterra

Proof of concept to consume web apps published on Nostr.
MIT License
5 stars 0 forks source link

json formats for webapps in nnterra? #1

Open ghost opened 1 year ago

ghost commented 1 year ago

Hi Marcelo-Theodoro.

Proof of concept to consume web apps published on Nostr.

I would like to know what you think about the idea of ​​using json formats for webapps. My general idea is to use json formats. what do you think of this idea?

json formats: json2html, editorjs

Marcelo-Theodoro commented 1 year ago

Hey! Sorry for the delay.

Seem's like an interesting solution.

In the long run, it'd be easy to implement that strategy. Before that, there's some groundwork to do, like how to get the event content and what component will be responsible for rendering it. I'll be working on a new version after Apr 24. I'll take in consideration that we can have multiple ways to render a page!

ghost commented 1 year ago

There is a proposal called NIP IDEA: New note "transclusion". I believe that the nostr-transclusion proposal is interesting for this technical discussion about whether it is possible to have a nostr-html-css-js proposal or not officially.

By theoretical definition, it should be possible to include absolute or relative paths to static files like css, js, html inside a json note or event. A general idea would be to have a "stylesheets/css" string to add the visual way, a "js" string to add the js code. It should be possible or not to add the text path related to the html element type.

Example:

{
  "id": <32-bytes lowercase hex-encoded sha256 of the the serialized event data>
  "pubkey": <32-bytes lowercase hex-encoded public key of the event creator>,
  "created_at": <unix timestamp in seconds>,
  "style":  "https://nostr-dev-test.dev/sass/file.css", 
  "js":  "https://nostr-dev-test.dev/bin/file.js", 
  "kind": <integer>,
   "texts":  ["id-relay", <32-bytes hex of a pubkey>, <32-bytes lowercase hex-encoded sha256 of the the serialized event data>,<recommended relay URL>], 
  "tags": [
    ["e", <32-bytes hex of the id of another event>, <recommended relay URL>],
    ["p", <32-bytes hex of a pubkey>, <recommended relay URL>],
    ... // other kinds of tags may be included later
  ],
  "p": "ws://linux-gamer.com/2023/docker-linux/#:~:text=25,567",
  "sig": <64-bytes hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field>
}