Skip to content

Commit 2d9f9f5

Browse files
committed
chore: update fosdem slides
Signed-off-by: moul <[email protected]>
1 parent afb2e61 commit 2d9f9f5

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package microposts
2+
3+
import (
4+
"std" // gno specific
5+
"time"
6+
)
7+
8+
var posts []*Post
9+
10+
type Post struct {
11+
text string
12+
author std.Address
13+
createdAt time.Time
14+
}
15+
16+
func CreatePost(text string) {
17+
posts = append(posts, &Post{
18+
text: text,
19+
author: std.PrevRealm().Addr(), // provided by env
20+
createdAt: time.Now(),
21+
})
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package microposts
2+
3+
import "gno.land/p/demo/ufmt"
4+
5+
func Render(_ string) string {
6+
out := "# Posts\n"
7+
for i := len(posts) - 1; i >= 0; i-- {
8+
out += ufmt.Sprintf("### Post #%d\n", i))
9+
out += posts[i].String()
10+
}
11+
return out
12+
}
13+
14+
func (p Post) String() string {
15+
out := p.text + "\n"
16+
out += ufmt.Sprintf("_%s, by %s_\n",
17+
p.createdAt.Format("02 Jan 2006, 15:04"), p.author)
18+
return out
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package microposts
2+
3+
import (
4+
"std"
5+
"time"
6+
)
7+
8+
type Post struct {
9+
text string
10+
author std.Address
11+
createdAt time.Time
12+
}
13+
14+
func (p Post) String() string {
15+
out := p.text + "\n"
16+
out += "_" + p.createdAt.Format("02 Jan 2006, 15:04") + ", by " + p.author.String() + "_"
17+
return out
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package microposts
2+
3+
import (
4+
"std"
5+
"time"
6+
)
7+
8+
var posts []*Post // automatically persisted
9+
10+
func CreatePost(text string) {
11+
posts = append(posts, &Post{
12+
text: text,
13+
author: std.PrevRealm().Addr(), // provided by env
14+
createdAt: time.Now(),
15+
})
16+
}
17+
18+
func Render(_ string) string {
19+
out := "# Posts\n"
20+
for i := len(posts) - 1; i >= 0; i-- {
21+
out += "### Post " + strconv.Itoa(i) + "\n" + posts[i].String()
22+
}
23+
return out
24+
}
25+

presentations/2025-02-01--fosdem--manfred/presentation.slide

+11-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,20 @@ with built-in **state persistence** and **safe execution**.
5959
- global variables persist across transactions
6060
- no need for external storage or db
6161

62-
## microposts.gno
62+
## microposts
6363

6464
.image ./img/microposts.png _ 1000
6565

66+
## microposts/post.gno
67+
68+
// .code ./code/micropost1.gno
69+
.code ./code/micropost_post.gno
70+
71+
## microposts/realm.gno
72+
73+
// .code ./code/micropost2.gno
74+
.code ./code/micropost_realm.gno
75+
6676
## microposts demo
6777

6878
.image ./img/micropost1.png _ 500

0 commit comments

Comments
 (0)