Transaction
6E097A4FD03C75…EE646ED83BD3
Block 25,658 · index 0 · indexed
Summary
- Hash
- 6E097A4FD03C7516860612704752395654D7804D90ACC8C7D70BEE646ED83BD3
- Block
- 25,658
- Size
- 4569 bytes
- Gas used
- 10,131,531 / 12,157,897
- Fee
- 1000000ugnot
- Memo
- gnopublish
- Status
- success
Messages
- Package
- gno.land/p/moul/mdlist/v0
Arguments · 9
- #1mdlist
- #2README.md
- #3# `gno.land/p/moul/mdlist/v0` _TODO: describe this package._ <!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) --> --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:**  > ⚠️ **Disclaimer:** provided as-is, without warranty; not security-audited. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md). <!-- END GNOCONTRACTS FOOTER -->
- #4gnomod.toml
- #5module = "gno.land/p/moul/mdlist/v0" gno = "0.9"
- #6mdlist.gno
- #7// Package mdlist is a proof-of-concept for composable UIs patterns. // // It allows specifying a data source and then dynamically rendering it as // a list or a grid. package mdlist import ( "strings" "gno.land/p/moul/md/v0" ) // XXX: configurable length UL // XXX: moul/pager.Pager-powered auto mdlist // XXX: func (l List) Render(path string) string { // XXX: add .Table() type Entries []Entry type Entry struct { // Title is the title of the entry. Required. Title string // Body is the body of the entry. Required. Body string // Link is the URL of the entry. Optional. Link string // Links is a list of additional URLs of the entry. Optional. Links []string } // BulletList returns entries as a markdown bullet list without truncation. func (l Entries) BulletList() string { return l.BulletListTruncated(-1, -1) } // BulletListTruncated returns entries as a markdown bullet list with truncation. func (l Entries) BulletListTruncated(titleMaxLength, bodyMaxLength int) string { items := make([]string, len(l)) for i, entry := range l { title := truncateText(entry.Title, titleMaxLength, false) if entry.Link != "" { title = md.Link(title, entry.Link) } body := truncateText(entry.Body, bodyMaxLength, true) links := strings.Join(entry.Links, " ") item := md.Bold(title) + ": " + md.Italic(body) + " " + links items[i] = strings.TrimSpace(item) } return md.BulletList(items) } // NumberedList returns entries as a markdown numbered list without truncation. func (l Entries) NumberedList() string { return l.NumberedListTruncated(-1, -1) } // NumberedListTruncated returns entries as a markdown numbered list with truncation. func (l Entries) NumberedListTruncated(titleMaxLength, bodyMaxLength int) string { items := make([]string, len(l)) for i, entry := range l { title := truncateText(entry.Title, titleMaxLength, false) if entry.Link != "" { title = md.Link(title, entry.Link) } body := truncateText(entry.Body, bodyMaxLength, true) links := strings.Join(entry.Links, " ") item := md.Bold(title) + ": " + md.Italic(body) + " " + links items[i] = strings.TrimSpace(item) } return md.OrderedList(items) } // Paragraphs returns entries as simple paragraphs with bold titles. func (l Entries) Paragraphs() string { paragraphs := make([]string, len(l)) for i, entry := range l { title := entry.Title if entry.Link != "" { title = md.Link(title, entry.Link) } paragraph := md.Bold(title) + ". " + entry.Body if len(entry.Links) > 0 { paragraph += " " + strings.Join(entry.Links, " ") } paragraphs[i] = paragraph } return strings.Join(paragraphs, "\n\n") } func (l Entries) Columns() string { columns := make([]string, len(l)) for i, entry := range l { title := entry.Title if entry.Link != "" { title = md.Link(title, entry.Link) } body := entry.Body links := strings.Join(entry.Links, " ") columns[i] = md.H2(title) + md.Paragraph(body) + md.Paragraph(links) } return md.Columns(columns, false) } func truncateText(content string, maxLength int, withNewLines bool) string { // If maxLength is -1, don't truncate if maxLength < 0 { if !withNewLines { content = strings.ReplaceAll(content, "\n", " ") } return content } if !withNewLines { content = strings.ReplaceAll(content, "\n", " ") } if len(content) > maxLength { return content[:maxLength-3] + "..." } return content }
- #8/gno.MemPackageType
- #9 MPUserProd
Result log
msg:0,success:true,log:,events:[]