1// Pacakge web25 provides an opinionated way to register an external web22// frontend to provide a "better" web2.5 experience.3package web2545import (6 "strings"78 "gno.land/p/moul/realmpath/v0"9)1011type Config struct {12 CID string13 URL string14 Text string15}1617func (c *Config) SetRemoteFrontendByURL(url string) {18 c.CID = ""19 c.URL = url20}2122func (c *Config) SetRemoteFrontendByCID(cid string) {23 c.CID = cid24 c.URL = ""25}2627func (c Config) GetLink() string {28 if c.CID != "" {29 return "https://ipfs.io/ipfs/" + c.CID30 }31 return c.URL32}3334const DefaultText = "Click [here]({link}) to visit the full rendering experience.\n"3536// Render displays a frontend link at the top of your realm's Render function in37// a concistent way to help gno visitors to have a consistent experience.38//39// if query is not nil, then it will check if it's not disable by ?no-web25, so40// that you can call the render function from an external point of view.41func (c Config) Render(path string) string {42 if realmpath.Parse(path).Query.Get("no-web25") == "1" {43 return ""44 }45 text := c.Text46 if text == "" {47 text = DefaultText48 }49 text = strings.ReplaceAll(text, "{link}", c.GetLink())50 return text51}52Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.