From 5287039cf7b45d78bf6d92dd668c118c8aa8da4a Mon Sep 17 00:00:00 2001 From: Leon Hudak <33522493+leohhhn@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:30:37 +0200 Subject: [PATCH] chore(tabler): update tabler to use go (#61) * rm scripts update tools * update * ci * rm toolchain * update workflow * workflow * workflow * reset workflow --- Makefile | 17 +++-- README.md | 53 ++++++++++----- go.mod | 4 +- .../metadata.yml | 15 +++++ .../metadata.yml | 2 +- scripts/del-codeblock.sh | 11 ---- scripts/del-existing-rows.sh | 13 ---- scripts/format.go | 66 +++++++++++++++++++ scripts/lint.go | 32 ++++++--- scripts/{generate-table.go => table-tool.go} | 39 +++++++---- 10 files changed, 180 insertions(+), 72 deletions(-) create mode 100644 presentations/2023-03-13--gophercon_submission--jae/metadata.yml delete mode 100755 scripts/del-codeblock.sh delete mode 100755 scripts/del-existing-rows.sh create mode 100644 scripts/format.go rename scripts/{generate-table.go => table-tool.go} (86%) diff --git a/Makefile b/Makefile index b9f0e4b..2c8b14b 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,20 @@ ROWS=15 FILE="README.md" build: - ./scripts/del-existing-rows.sh $(ROWS) $(FILE) + # Delete existing table if it exists + go run ./scripts format --rmtable --readme README.md - go run scripts/generate-table.go -path ./presentations -out scripts/data.csv -rows $(ROWS) - cat scripts/data.csv | go run moul.io/mdtable csv > scripts/table.md + # Generate new table + go run ./scripts -path ./presentations -out ./scripts/data.csv + cat ./scripts/data.csv | go run moul.io/mdtable csv > ./scripts/table.md go run github.com/campoy/embedmd -w README.md + + # Remove codeblocks from embedmd + go run ./scripts format --readme README.md + # Clean up - rm scripts/data.csv scripts/table.md + rm ./scripts/data.csv ./scripts/table.md - ./scripts/del-codeblock.sh $(FILE) lint: - cd ./scripts && go run lint.go \ No newline at end of file + go run ./scripts lint --readme README.md --path ./presentations \ No newline at end of file diff --git a/README.md b/README.md index aa64b39..f3dfaf7 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,42 @@ presentations. [embedmd]:# (scripts/table.md) -|Date |Title |Speakers |Presentation |Recording | -|---- |----- |-------- |------------ |--------- | -|2024-09-23 |Distributed Communities - How to build timeless and decentralized apps, with Go |@thehowl |[Slides](presentations/2024-09-23--distributed-communities-morgan/slides.reveal.pdf) |--- | -|2024-08-20 |A gentle intro to gno.land |@leohhhn |[Slides](presentations/2024-08-20--gentle-intro-to-gnoland--leon/presentation.pdf) |[Video](https://www.youtube.com/watch?v=hTGeG0z09NU) | -|2024-08-05 |Intro to gno.land |@leohhhn |[Slides](https://docs.google.com/presentation/d/1tnplCWxhg-RFatDS3w1iJnO0vSfBAuw2ZA0ommNJQOU/edit?usp=sharing) |--- | -|2024-07-13 |Gno: Examples and Comparisons |@moul |[Slides](https://gnolang.github.io/workshops/presentations/2024-07-13--nebular--manfred/presentation.slide.html#1) |[Video](https://www.youtube.com/watch?v=Zsl3xu_Edcc) | -|2024-07-13 |Building with Gno.land: A Practical Workshop on Smart Contracts |@gfanton |[Slides](presentations/2024-07-13--nebular--gfanton/README.md) |[Video](https://www.youtube.com/watch?v=oBQ-t_E0QpI) | -|2024-07-09 |Building a Deterministic Interpreter in Go: Readability vs Performance |@jaekwon |[Slides](presentations/2024-07-09--gophercon-us--jae) |[Video](https://www.youtube.com/watch?v=betUkghf_jo) | -|2024-07-08 |Building a Decentralized App on gno.land |@deelawn |[Slides](presentations/2024-07-08--gophercon-us--dylan) |[Video](https://www.youtube.com/watch?v=lwL2VyjaV-A) | -|2024-06-17 |Envisioning a Go-Powered Ecosystem: The Ultimate Go Computer |@moul |[Slides](presentations/2024-06-17--gophercon-berlin--manfred) |[Video](https://youtu.be/dLE2-8QPK64?si=IidxNLGrwwS6jbYL) | -|2024-05-23 |Building Dynamic Applications With Go (and Gno!) |@deelawn |[Slides](presentations/2024-05-23--belgrade--dylan/slides.pdf) |[Video](https://www.youtube.com/watch?v=tNM1DHOxIQ8) | -|2024-04-11 |Intro to Gno Tokyo |@leohhhn |[Slides](presentations/2024-04-11--tokyo-intro-to-gno--leon/slides.pdf) |--- | -|2024-03-23 |Go to Gno |@leohhhn |[Slides](presentations/2024-03-23--seoul-go-to-gno--leon/Go_to_Gno_slides.pdf) |--- | -|2023-12-14 |GnoChess - a Retrospective |@thehowl |[Slides](presentations/2023-12-14--gnochess-a-retrospective--morgan/slides.reveal.md) |--- | -|2023-12-13 |Gno: What, Why, and How |@moul |[Slides](presentations/2023-12-13--rouen--manfred/slides.md) |--- | -|2023-10-09 |Generating Audio |@schollz |[Slides](presentations/2023-10-09--generating-audio--schollz/presentation.md) |[Video](https://www.youtube.com/watch?v=lmmUIEHhdqA&t=2s) | -|2023-09-26 |Chess The Gnolang Way |@thehowl |[Slides](presentations/2023-09-26--chess-the-gnolang-way--morgan/slides.reveal.md) |--- | +|Date |Title |Speakers |Presentation |Recording | +|---- |----- |-------- |------------ |--------- | +|2024-09-23 |Distributed Communities - How to build timeless and decentralized apps, with Go |[@thehowl](https://github.com/thehowl) |[Slides](https://gnolang.github.io/workshops/presentations/2024-09-23--distributed-communities/slides.html) |--- | +|2024-08-20 |A gentle intro to gno.land |[@leohhhn](https://github.com/leohhhn) |[Slides](presentations/2024-08-20--gentle-intro-to-gnoland--leon/presentation.pdf) |[Video](https://www.youtube.com/watch?v=hTGeG0z09NU) | +|2024-08-05 |Intro to gno.land |[@leohhhn](https://github.com/leohhhn) |[Slides](https://docs.google.com/presentation/d/1tnplCWxhg-RFatDS3w1iJnO0vSfBAuw2ZA0ommNJQOU/edit?usp=sharing) |--- | +|2024-07-13 |Building with Gno.land: A Practical Workshop on Smart Contracts |[@gfanton](https://github.com/gfanton) |[Slides](presentations/2024-07-13--nebular--gfanton/README.md) |[Video](https://www.youtube.com/watch?v=oBQ-t_E0QpI) | +|2024-07-13 |Gno: Examples and Comparisons |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2024-07-13--nebular--manfred/presentation.slide.html#1) |[Video](https://www.youtube.com/watch?v=Zsl3xu_Edcc) | +|2024-07-09 |Building a Deterministic Interpreter in Go: Readability vs Performance |[@jaekwon](https://github.com/jaekwon) |[Slides](presentations/2024-07-09--gophercon-us--jae) |[Video](https://www.youtube.com/watch?v=betUkghf_jo) | +|2024-07-08 |Building a Decentralized App on gno.land |[@deelawn](https://github.com/deelawn) |[Slides](presentations/2024-07-08--gophercon-us--dylan) |[Video](https://www.youtube.com/watch?v=lwL2VyjaV-A) | +|2024-06-17 |Envisioning a Go-Powered Ecosystem: The Ultimate Go Computer |[@moul](https://github.com/moul) |[Slides](presentations/2024-06-17--gophercon-berlin--manfred) |[Video](https://youtu.be/dLE2-8QPK64?si=IidxNLGrwwS6jbYL) | +|2024-05-23 |Building Dynamic Applications With Go (and Gno!) |[@deelawn](https://github.com/deelawn) |[Slides](presentations/2024-05-23--belgrade--dylan/slides.pdf) |[Video](https://www.youtube.com/watch?v=tNM1DHOxIQ8) | +|2024-04-11 |Intro to Gno Tokyo |[@leohhhn](https://github.com/leohhhn) |[Slides](presentations/2024-04-11--tokyo-intro-to-gno--leon/slides.pdf) |--- | +|2024-03-23 |Go to Gno |[@leohhhn](https://github.com/leohhhn) |[Slides](presentations/2024-03-23--seoul-go-to-gno--leon/Go_to_Gno_slides.pdf) |--- | +|2023-12-14 |GnoChess - a Retrospective |[@thehowl](https://github.com/thehowl) |[Slides](presentations/2023-12-14--gnochess-a-retrospective--morgan/slides.reveal.md) |--- | +|2023-12-13 |Gno: What, Why, and How |[@moul](https://github.com/moul) |[Slides](presentations/2023-12-13--rouen--manfred/slides.md) |--- | +|2023-10-09 |Generating Audio |[@schollz](https://github.com/schollz) |[Slides](presentations/2023-10-09--generating-audio--schollz/presentation.md) |[Video](https://www.youtube.com/watch?v=lmmUIEHhdqA&t=2s) | +|2023-09-26 |Chess The Gnolang Way |[@thehowl](https://github.com/thehowl) |[Slides](presentations/2023-09-26--chess-the-gnolang-way--morgan/slides.reveal.md) |--- | +|2023-09-11 |Gno.land: The Key To Perpetual Transparency |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2023-09-11--dappcon-key-perpetual-transparency--manfred/presentation.slide.html) |--- | +|2023-07-24 |Examining the Gno Core Stack |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2023-07-24--talk-nebular--manfred/presentations.slide.html#1) |--- | +|2023-07-23 |Getting Started with Gno! |[@moul](https://github.com/moul), [@thehowl](https://github.com/thehowl) |[Slides](presentations/2023-07-23--workshop-nebular--manfred-morgan/README.md) |--- | +|2023-06-26 |Go -> Gno |[@schollz](https://github.com/schollz) |[Slides](presentations/2023-06-26--go-to-gno--schollz/slides.pdf) |[Video](https://www.youtube.com/watch?v=F-_dadxcRJM) | +|2023-06-06 |Proof of Contribution in Gno.land |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2023-06-06--buidl-asia--manfred/presentations.slide.html) |--- | +|2023-06-05 |Gno.land for Go Developers |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2023-06-05--getting-to-gno-seoul--manfred/presentations.slide.html#1) |--- | +|2023-06-03 |A journey into Gno.land - the Evolution of Smart Contracts |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2023-06-03--eth-seoul--manfred/presentations.slide.html#1) |--- | +|2023-06-02 |Alice in Gno.land |[@zivkovicmilos](https://github.com/zivkovicmilos) |[Slides](presentations/2023-06-02--eth-belgrade--milos/README.md) |--- | +|2023-03-16 |How to build a forum in Gno.land |[@zivkovicmilos](https://github.com/zivkovicmilos) |[Slides](presentations/2023-03-16--online--milos/README.md) |[Video](https://www.youtube.com/watch?v=gmP-mH-64HA) | +|2023-03-13 |GopherCon Submission |[@jaekwon](https://github.com/jaekwon) |[Slides](presentations/2023-03-13--gophercon_submission--jae/README.md) |--- | +|2023-03-03 |Plan9 as Metaverse |[@jaekwon](https://github.com/jaekwon) |[Slides](presentations/2023-03-03--ethdenver_gnoland_plan9_as_metaverse--jae/README.md) |--- | +|2022-11-29 |Minimal meetup.com clone |[@moul](https://github.com/moul), [@pwnh4](https://github.com/pwnh4) |[Slides](https://github.com/xplrz/gnoland-meetup) |--- | +|2022-11-15 |Intro to gno.land |[@moul](https://github.com/moul) |[Slides](presentations/2022-11-15--istanbul--manfred/slides.pdf) |--- | +|2022-11-03 |Intro to gno.land |[@moul](https://github.com/moul) |[Slides](presentations/2022-11-03--lisbon--manfred/slides.pdf) |--- | +|2022-10-18 |Gnoland & Concurrent Smart Contracts |[@moul](https://github.com/moul) |[Slides](presentations/2022-10-18--cosmoverse--manfred/slides.pdf) |[Video](https://www.youtube.com/watch?v=gcZHjlqG8gg&list=PLUg1PF7xcA8WHJ6aXXPi4CckVd7WEukF6&index=8) | +|2022-09-29 |Intro to Gno |[@moul](https://github.com/moul), [@pwnh4](https://github.com/pwnh4) |[Slides](https://github.com/xplrz/gnoland-workshop) |--- | +|2022-09-13 |Intro to the Gno Smart Contract Platform and Blockchain |[@moul](https://github.com/moul) |[Slides](presentations/2022-09-13--berlin--manfred/slides.pdf) |[Video](https://www.youtube.com/watch?v=S36kA5RqLvs) | + + _This table is autogenerated based on the [./presentations](./presentations) folder._ diff --git a/go.mod b/go.mod index 5ddc972..e1d99a2 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/workshops -go 1.22.0 - -toolchain go1.22.3 +go 1.22 require ( github.com/campoy/embedmd v1.0.0 diff --git a/presentations/2023-03-13--gophercon_submission--jae/metadata.yml b/presentations/2023-03-13--gophercon_submission--jae/metadata.yml new file mode 100644 index 0000000..f015cbb --- /dev/null +++ b/presentations/2023-03-13--gophercon_submission--jae/metadata.yml @@ -0,0 +1,15 @@ +# Date of the workshop +date: "2023-03-13" +# Title of the workshop +title: "GopherCon Submission" +# GitHub usernames of the speakers +speakers: + - "jaekwon" +# Location of the workshop +location: "" +# At which event the workshop took place, if any +event: "" +# Workshop slides link. If the link is local, only put the file name, without any other path parts. +slides: "README.md" +# Workshop recording +recording: "" \ No newline at end of file diff --git a/presentations/2024-09-23--distributed-communities-morgan/metadata.yml b/presentations/2024-09-23--distributed-communities-morgan/metadata.yml index 2a18aa6..e4cd5aa 100644 --- a/presentations/2024-09-23--distributed-communities-morgan/metadata.yml +++ b/presentations/2024-09-23--distributed-communities-morgan/metadata.yml @@ -10,6 +10,6 @@ location: "Turin, Italy" # At which event the workshop took place, if any event: "" # Workshop slides link. If the link is local, only put the file name, without any other path parts. -slides: "slides.reveal.pdf" +slides: "https://gnolang.github.io/workshops/presentations/2024-09-23--distributed-communities/slides.html" # Workshop recording recording: "" \ No newline at end of file diff --git a/scripts/del-codeblock.sh b/scripts/del-codeblock.sh deleted file mode 100755 index 56a39bb..0000000 --- a/scripts/del-codeblock.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Define the file to be processed -FILE="README.md" - -# if found line, remove table of size 17 rows - -# Use sed to remove the code block backticks -sed -i '' '/^```md$/d; /^```$/d' "$FILE" - -echo "Successfully generated table for $FILE." diff --git a/scripts/del-existing-rows.sh b/scripts/del-existing-rows.sh deleted file mode 100755 index 47e3863..0000000 --- a/scripts/del-existing-rows.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -ROWS=$1 -FILE=$2 -NUM_LINES=$(($ROWS - 1)) -HEADER1="|Date |Title |Speakers |Presentation |Recording |" - -if grep -qF "$HEADER1" "$FILE"; then - echo "Old table found, deleting." - # Use sed to find and delete the two header lines and the next $ROWS lines - sed -i '' "/$HEADER1/{N;N;$(for i in $(seq 1 $NUM_LINES); do echo -n 'N;'; done)d;}" "$FILE" -fi - diff --git a/scripts/format.go b/scripts/format.go new file mode 100644 index 0000000..470eb42 --- /dev/null +++ b/scripts/format.go @@ -0,0 +1,66 @@ +package main + +import ( + "context" + "fmt" + "os" + "strings" + + "github.com/gnolang/gno/tm2/pkg/commands" +) + +func newFormatCmd(cfg *cfg) *commands.Command { + cmd := commands.NewCommand( + commands.Metadata{ + Name: "format", + ShortHelp: "remove codeblocks from the README table", + }, + commands.NewEmptyConfig(), + func(_ context.Context, args []string) error { + return execFormat(cfg) + }, + ) + return cmd +} + +// execFormat removes an existing table if rmTable is set, and removes the codeblock after table generation happened +func execFormat(cfg *cfg) error { + read, err := os.ReadFile(cfg.readmePath) + if err != nil { + panic(err) + } + + cts := string(read) + newContents := "" + + // Called to remove the old table + if cfg.rmTable { + lines := strings.Split(cts, "\n") + newLines := make([]string, 0, len(lines)) + for _, line := range lines { + if strings.Index(line, "|") != 0 { + newLines = append(newLines, line) + } + } + + newContents = strings.Join(newLines, "\n") + + } else { + // called to remove the codeblock + newContents = strings.Replace(cts, "```md", "", 1) + newContents = strings.Replace(newContents, "```", "", 1) + } + + if cts == newContents { + fmt.Println("Nothing to format.") + return nil + } + + err = os.WriteFile(cfg.readmePath, []byte(newContents), 0) + if err != nil { + panic(err) + } + + fmt.Println("Formatted README.md") + return nil +} diff --git a/scripts/lint.go b/scripts/lint.go index 63e7552..353eff4 100644 --- a/scripts/lint.go +++ b/scripts/lint.go @@ -1,19 +1,31 @@ package main import ( + "context" "fmt" "os" "slices" "strings" -) -const ( - presFolder = "../presentations" - readme = "../README.md" + "github.com/gnolang/gno/tm2/pkg/commands" ) -func main() { - dirs, err := os.ReadDir(presFolder) +func newLintCmd(cfg *cfg) *commands.Command { + cmd := commands.NewCommand( + commands.Metadata{ + Name: "lint", + ShortHelp: "lint the README table", + }, + commands.NewEmptyConfig(), + func(_ context.Context, args []string) error { + return execLint(cfg) + }, + ) + return cmd +} + +func execLint(cfg *cfg) error { + dirs, err := os.ReadDir(cfg.presentationsPath) if err != nil { panic(err) } @@ -31,18 +43,20 @@ func main() { slices.Sort(dates) slices.Reverse(dates) - rawContents, err := os.ReadFile(readme) + rawContents, err := os.ReadFile(cfg.readmePath) if err != nil { panic(err) } cts := string(rawContents) - for _, date := range dates[:15] { + for _, date := range dates { if !strings.Contains(cts, date) { - panic("could not find latest item in README table - did you run `make build`?") + panic("could not find some items in README table - did you run `make build`?") } } fmt.Println("All good!") + + return nil } diff --git a/scripts/generate-table.go b/scripts/table-tool.go similarity index 86% rename from scripts/generate-table.go rename to scripts/table-tool.go index 7ea3ff1..f0950c7 100644 --- a/scripts/generate-table.go +++ b/scripts/table-tool.go @@ -16,8 +16,9 @@ import ( type cfg struct { presentationsPath string - outputPath string - rows int + csvOutPath string + readmePath string + rmTable bool } type Metadata struct { @@ -32,6 +33,8 @@ var ( csvHeader = []string{"Date", "Title", "Speakers", "Presentation", "Recording"} ) +const ghLink = "https://github.com/" + func main() { cfg := &cfg{} @@ -45,6 +48,11 @@ func main() { return execGen(cfg) }) + cmd.AddSubCommands( + newLintCmd(cfg), + newFormatCmd(cfg), + ) + cmd.Execute(context.Background(), os.Args[1:]) } @@ -56,22 +64,29 @@ func (c *cfg) RegisterFlags(fs *flag.FlagSet) { "path to dir to walk for presentations files", ) fs.StringVar( - &c.outputPath, + &c.csvOutPath, "out", "./data.csv", "output csv path, including .csv", ) - fs.IntVar( - &c.rows, - "rows", - 15, - "number of rows to generate", + fs.StringVar( + &c.readmePath, + "readme", + "", + "path to the main README", + ) + + fs.BoolVar( + &c.rmTable, + "rmtable", + false, + "rm the table", ) } func execGen(cfg *cfg) error { searchDir := cfg.presentationsPath - outputCSV := cfg.outputPath // todo check for err + outputCSV := cfg.csvOutPath // todo check for err // Create the CSV file csvFile, err := os.Create(outputCSV) @@ -137,8 +152,7 @@ func execGen(cfg *cfg) error { }) // Write sorted rows to the CSV file - // Generate only the last N rows of data - for _, r := range rows[:cfg.rows] { + for _, r := range rows { err = writer.Write(r.Format()) if err != nil { return err @@ -173,7 +187,8 @@ func (m Metadata) Format() []string { func (m Metadata) parseSpeakers() string { var speakers []string for _, speaker := range m.Speakers { - speakers = append(speakers, "@"+speaker) + speaker = fmt.Sprintf("[@%s](%s%s)", speaker, ghLink, speaker) + speakers = append(speakers, speaker) } return strings.Join(speakers, ", ")