Pure package detail
web25
gno.land/p/moul/web25/v2
Indexed deployment identity with independently loaded latest RPC source. Functions and Render are realm-only RPC capabilities.
Indexed deployment
Identity
- Package path
- gno.land/p/moul/web25/v2
- Block
- 23361
- Deployed (UTC)
- Transaction
- HeviIcEOgFSw9mg1S0Wb84QxlEcQKhi3tT8uKQELGls=
Latest RPC state
Source
// Pacakge web25 provides an opinionated way to register an external web2
// frontend to provide a "better" web2.5 experience.
package web25
import (
"strings"
"gno.land/p/moul/realmpath/v1"
)
type Config struct {
CID string
URL string
Text string
}
func (c *Config) SetRemoteFrontendByURL(url string) {
c.CID = ""
c.URL = url
}
func (c *Config) SetRemoteFrontendByCID(cid string) {
c.CID = cid
c.URL = ""
}
func (c Config) GetLink() string {
if c.CID != "" {
return "https://ipfs.io/ipfs/" + c.CID
}
return c.URL
}
const DefaultText = "Click [here]({link}) to visit the full rendering experience.\n"
// Render displays a frontend link at the top of your realm's Render function in
// a concistent way to help gno visitors to have a consistent experience.
//
// if query is not nil, then it will check if it's not disable by ?no-web25, so
// that you can call the render function from an external point of view.
func (c Config) Render(path string) string {
if realmpath.Parse(path).Query.Get("no-web25") == "1" {
return ""
}
text := c.Text
if text == "" {
text = DefaultText
}
text = strings.ReplaceAll(text, "{link}", c.GetLink())
return text
}
The verified vm/qfuncs operation accepts realm paths only.
Pure packages expose source files but do not have Realm Render.