Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

reactions/v0 package

Overview

Package reactions is a reaction block any realm can embed, keyed on the page it appears on rather than on the realm that stores it.

It is the shape the web settled on for this in 2010: one hosted widget, the same snippet pasted everywhere, deciding what to show from the page identifier it is handed. Here the snippet is two lines of gno:

Example
1import "gno.land/r/moul/reactions/v0"
2
3func Render(path string) string {
4	return body + reactions.RenderBlock()
5}

RenderBlock takes no argument because it does not need one: a plain read exported by a realm and called by another opens no realm frame, so unsafe.CurrentRealm() inside it reports the CALLER. The host realm's own path is the page key, and nothing has to be configured, registered or passed. RenderBlockFor is the explicit form, for a realm that renders more than one page or already holds its path as a constant.

The host realm stores nothing. Every tally lives here, so a realm can add reactions without a redeploy the next time it wants to change them, and a reader's reaction survives the host realm being replaced.

What it is not

Not a comment system. There is no text field anywhere, which is what makes it possible to run with no moderation at all: six emoji, one reaction per address per page, changeable and removable. The page shows the tally and who reacted last. That is the whole feature.

Function

RenderBlockFor

func RenderBlockFor(page string) string

RenderBlockFor is RenderBlock for a named page. Use it from a crossing function, where there is no caller to read off the stack, or when one realm renders several pages.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/reactions/v0.RenderBlockFor()"

Result