social.gno
0.69 Kb · 28 lines
1package social
2
3import (
4 "strings"
5
6 "chain/runtime"
7
8 "gno.land/p/nt/avl/v0"
9)
10
11var (
12 gUserPostsByAddress avl.Tree // user's address -> *UserPosts
13 gUserAddressByName avl.Tree // user's username -> address
14 postsCtr uint64 // increments Post.id globally
15
16 // gRealmPath is the realm's relative URL path (e.g. "/r/g1.../social"),
17 // derived from the deployed package path at init time.
18 gRealmPath string
19)
20
21func init() {
22 pkgPath := runtime.CurrentRealm().PkgPath()
23 // Strip the chain domain (everything before the first "/") to get the
24 // relative path suitable for markdown links: "/r/g1.../social".
25 if idx := strings.Index(pkgPath, "/"); idx >= 0 {
26 gRealmPath = pkgPath[idx:]
27 }
28}