github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/r/demo/boards/z_5_c_filetest.gno (about)

     1  package main
     2  
     3  // SEND: 2000000000ugnot
     4  
     5  import (
     6  	"std"
     7  	"strconv"
     8  
     9  	"gno.land/p/demo/testutils"
    10  	"gno.land/r/demo/boards"
    11  	"gno.land/r/demo/users"
    12  )
    13  
    14  const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj")
    15  
    16  func main() {
    17  	users.Register("", "gnouser", "my profile")
    18  	// create board via registered user
    19  	bid := boards.CreateBoard("test_board")
    20  
    21  	// create post via anon user
    22  	test2 := testutils.TestAddress("test2")
    23  	std.TestSetOrigCaller(test2)
    24  	std.TestSetOrigSend(std.Coins{{"ugnot", 101000000}}, nil)
    25  
    26  	pid := boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
    27  	boards.CreateReply(bid, pid, pid, "Reply of the first post")
    28  
    29  	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
    30  }
    31  
    32  // Output:
    33  // # First Post (title)
    34  //
    35  // Body of the first post. (body)
    36  // \- [g1w3jhxapjta047h6lta047h6lta047h6laqcyu4](/r/demo/users:g1w3jhxapjta047h6lta047h6lta047h6laqcyu4), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards?help&__func=CreateReply&bid=1&threadid=1&postid=1&body.type=textarea)] \[[repost](/r/demo/boards?help&__func=CreateRepost&bid=1&postid=1&title.type=textarea&body.type=textarea&dstBoardID.type=textarea)] \[[x](/r/demo/boards?help&__func=DeletePost&bid=1&threadid=1&postid=1)]
    37  //
    38  // > Reply of the first post
    39  // > \- [g1w3jhxapjta047h6lta047h6lta047h6laqcyu4](/r/demo/users:g1w3jhxapjta047h6lta047h6lta047h6laqcyu4), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards?help&__func=CreateReply&bid=1&threadid=1&postid=2&body.type=textarea)] \[[x](/r/demo/boards?help&__func=DeletePost&bid=1&threadid=1&postid=2)]