diff --git a/.github/workflows/table-checker.yml b/.github/workflows/table-checker.yml new file mode 100644 index 0000000..100f380 --- /dev/null +++ b/.github/workflows/table-checker.yml @@ -0,0 +1,55 @@ +name: Check for new presentations + +on: + pull_request: + paths: + - 'presentations/**' + +jobs: + check-new-folder: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up environment + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Get the list of changed folders + id: diff + run: | + # Get only the added folders in presentations directory + diff_folders=$(git diff --name-status origin/main | grep '^A' | grep 'presentations/' | awk '{print $2}' | cut -d'/' -f2 | sort -u) + echo "Folders detected: $diff_folders" + echo "::set-output name=folders::$diff_folders" + + - name: Check new folders against table + run: | + # Path to your markdown table + MD_FILE="scripts/table.md" + + # Get the date of the top row in the table + top_row_date=$(grep -oP '^\|[0-9]{4}-[0-9]{2}-[0-9]{2}' $MD_FILE | head -n 1 | tr -d '|') + + # Loop through the folders detected + for folder in ${{ steps.diff.outputs.folders }}; do + folder_date=$(echo $folder | grep -oE '^[0-9]{4}-[0-9]{2}-[0-9]{2}') + echo "Comparing folder date: $folder_date with top row date: $top_row_date" + + if [[ "$folder_date" > "$top_row_date" ]]; then + echo "New folder $folder is newer than the latest entry in the table ($top_row_date)." + exit 1 + else + echo "Table is up to date." + fi + done + + - name: Success message + if: success() + run: echo "Table is up to date." + + - name: Fail message + if: failure() + run: echo "Please run the generation command to update the table." diff --git a/.github/workflows/table-gen.yml b/.github/workflows/table-gen.yml deleted file mode 100644 index faba457..0000000 --- a/.github/workflows/table-gen.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "generate table" - -on: - push: - paths: - - "presentations/**" - pull_request: - paths: - - "presentations/**" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch the full history for proper commit - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: Install mdtable - run: go install moul.io/mdtable@latest - - - name: Install embedmd - run: go install github.com/campoy/embedmd@latest - - - name: Install dependencies - run: go mod download - - - name: Build table - run: make build - - - name: Check if there are changes - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git diff - git diff --exit-code || echo "Changes detected in README.md" - - - name: Commit and push changes if needed - if: ${{ steps.Check_if_there_are_changes.outputs.exit_code == 0 }} # Only commit if changes exist - run: | - git add README.md - git commit -m "CI: Update README.md with generated table" - git push origin HEAD:${{ github.head_ref }} diff --git a/Makefile b/Makefile index 1fb500d..9ca7119 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,10 @@ ROWS=15 build: go run scripts/csvgen.go -path ./presentations -out scripts/data.csv -rows $(ROWS) cat scripts/data.csv | go run moul.io/mdtable csv > scripts/table.md - go run github.com/leohhhn/embedmd -w README.md - + go run github.com/campoy/embedmd -w README.md # Clean up - rm scripts/data.csv scripts/table.md \ No newline at end of file + rm scripts/data.csv scripts/table.md + + ./scripts/del-codeblock.sh + + diff --git a/README.md b/README.md index cb68dec..f9bf000 100644 --- a/README.md +++ b/README.md @@ -6,40 +6,6 @@ presentations. ## Previous workshops & talks [embedmd]:# (scripts/table.md) -|Date |Title |Speakers |Slides |Recording | -|---- |----- |-------- |------ |--------- | -|2023-09-11 |Gno.land: The Key To Perpetual Transparency |@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 |[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, @thehowl |[Slides](./README.md) |--- | -|2023-06-26 |Go -> Gno |@schollz |[Slides](./slides.pdf) |--- | -|2023-06-06 |Proof of Contribution in Gno.land |@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 |[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 |[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 |[Slides](./README.md) |--- | -|2023-03-16 |How to build a forum in Gno.land |@zivkovicmilos |[Slides](./README.md) |[Recording](https://www.youtube.com/watch?v=gmP-mH-64HA) | -|2023-03-03 |Plan9 as Metaverse |@jaekwon |[Slides](./README.md) |--- | -|2022-11-29 |Minimal meetup.com clone |@moul, @pwnh4 |[Slides](https://github.com/xplrz/gnoland-meetup) |--- | -|2022-11-15 |Intro to gno.land |@moul |--- |--- | -|2022-11-03 |Intro to gno.land |@moul |--- |--- | -|2022-10-18 |Gnoland & Concurrent Smart Contracts |@moul |--- |[Recording](https://www.youtube.com/watch?v=gcZHjlqG8gg&list=PLUg1PF7xcA8WHJ6aXXPi4CckVd7WEukF6&index=8) | -|2022-09-29 |Intro to Gno |@moul, @pwnh4 |[Slides](https://github.com/xplrz/gnoland-workshop) |--- | -|Date |Title |Speakers |Slides |Recording | -|---- |----- |-------- |------ |--------- | -|2023-09-11 |Gno.land: The Key To Perpetual Transparency |@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 |[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, @thehowl |[Slides](./README.md) |--- | -|2023-06-26 |Go -> Gno |@schollz |[Slides](./slides.pdf) |--- | -|2023-06-06 |Proof of Contribution in Gno.land |@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 |[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 |[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 |[Slides](./README.md) |--- | -|2023-03-16 |How to build a forum in Gno.land |@zivkovicmilos |[Slides](./README.md) |[Recording](https://www.youtube.com/watch?v=gmP-mH-64HA) | -|2023-03-03 |Plan9 as Metaverse |@jaekwon |[Slides](./README.md) |--- | -|2022-11-29 |Minimal meetup.com clone |@moul, @pwnh4 |[Slides](https://github.com/xplrz/gnoland-meetup) |--- | -|2022-11-15 |Intro to gno.land |@moul |--- |--- | -|2022-11-03 |Intro to gno.land |@moul |--- |--- | -|2022-10-18 |Gnoland & Concurrent Smart Contracts |@moul |--- |[Recording](https://www.youtube.com/watch?v=gcZHjlqG8gg&list=PLUg1PF7xcA8WHJ6aXXPi4CckVd7WEukF6&index=8) | -|2022-09-29 |Intro to Gno |@moul, @pwnh4 |[Slides](https://github.com/xplrz/gnoland-workshop) |--- | _This table is autogenerated based on the [./presentations](./presentations) folder._ diff --git a/go.mod b/go.mod index f2d17cd..5ddc972 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.22.0 toolchain go1.22.3 require ( + github.com/campoy/embedmd v1.0.0 github.com/gnolang/gno v0.2.0 - github.com/leohhhn/embedmd v0.0.0-20240927092809-8e38263bfca4 github.com/soypat/go-presentx v1.1.0 golang.org/x/tools v0.23.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 1414712..604f6a8 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= +github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -11,10 +13,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leohhhn/embedmd v0.0.0-20240927091403-cf387c5813fc h1:Er/gGadILy6w8uvl2xMqWCmQfFsIVVDTvZdUhKXPbV0= -github.com/leohhhn/embedmd v0.0.0-20240927091403-cf387c5813fc/go.mod h1:gIO/oEy8jBxhEijdPK0vHbBr+UvRkyeMyOW8LpCl+Ac= -github.com/leohhhn/embedmd v0.0.0-20240927092809-8e38263bfca4 h1:mGWEohV2wrK/WrJoJ4CVTgfGzuQOB48BFElMiBuERpw= -github.com/leohhhn/embedmd v0.0.0-20240927092809-8e38263bfca4/go.mod h1:gIO/oEy8jBxhEijdPK0vHbBr+UvRkyeMyOW8LpCl+Ac= github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/peterbourgon/ff/v3 v3.0.0/go.mod h1:UILIFjRH5a/ar8TjXYLTkIvSvekZqPm5Eb/qbGk6CT0= github.com/peterbourgon/ff/v3 v3.4.0 h1:QBvM/rizZM1cB0p0lGMdmR7HxZeI/ZrBWB4DqLkMUBc= diff --git a/presentations/2023-09-26--chess-the-gnolang-way--morgan/metadata.yml b/presentations/2023-09-26--chess-the-gnolang-way--morgan/metadata.yml new file mode 100644 index 0000000..e17e2b1 --- /dev/null +++ b/presentations/2023-09-26--chess-the-gnolang-way--morgan/metadata.yml @@ -0,0 +1,13 @@ +# Date of the workshop +date: "2023-09-26" +# Title of the workshop +title: "Chess The Gnolang Way" +# GitHub usernames of the speakers +speakers: + - "thehowl" +# Location of the workshop +location: "San Diego, USA" +# Workshop slides link +slides: "" +# Workshop recording +recording: "" \ No newline at end of file diff --git a/presentations/2023-10-09--generating-audio--schollz/metadata.yml b/presentations/2023-10-09--generating-audio--schollz/metadata.yml new file mode 100644 index 0000000..0ef7187 --- /dev/null +++ b/presentations/2023-10-09--generating-audio--schollz/metadata.yml @@ -0,0 +1,13 @@ +# Date of the workshop +date: "2023-10-09" +# Title of the workshop +title: "Generating Audio" +# GitHub usernames of the speakers +speakers: + - "schollz" +# Location of the workshop +location: "Online" +# Workshop slides link +slides: "" +# Workshop recording +recording: "" \ No newline at end of file diff --git a/scripts/csvgen.go b/scripts/csvgen.go index 11d2ded..7e6be08 100644 --- a/scripts/csvgen.go +++ b/scripts/csvgen.go @@ -8,7 +8,6 @@ import ( "os" "path/filepath" "sort" - "strconv" "strings" "github.com/gnolang/gno/tm2/pkg/commands" @@ -18,7 +17,7 @@ import ( type cfg struct { presentationsPath string outputPath string - rows string + rows int } type Metadata struct { @@ -30,7 +29,7 @@ type Metadata struct { } var ( - csvHeader = []string{"Date", "Title", "Speakers", "Slides", "Recording"} + csvHeader = []string{"Date", "Title", "Speakers", "Presentation", "Recording"} ) func main() { @@ -62,10 +61,10 @@ func (c *cfg) RegisterFlags(fs *flag.FlagSet) { "./data.csv", "output csv path, including .csv", ) - fs.StringVar( + fs.IntVar( &c.rows, "rows", - "15", + 15, "number of rows to generate", ) } @@ -120,6 +119,9 @@ func execGen(cfg *cfg) error { } // todo fix local slide links + //fmt.Printf("metadatafile: %s\n", metadataFile) + //fmt.Printf("abs: %s\n", abs) + //fmt.Printf("dir: %s\n", dir.Name()) // Check for empty fields if err = metadata.Check(abs); err != nil { @@ -136,11 +138,7 @@ func execGen(cfg *cfg) error { // Write sorted rows to the CSV file // Generate only the last N rows of data - rowNum, err := strconv.Atoi(cfg.rows) - if err != nil { - return err - } - for _, r := range rows[:rowNum] { + for _, r := range rows[:cfg.rows] { err = writer.Write(r.Format()) if err != nil { return err @@ -160,7 +158,7 @@ func (m Metadata) Format() []string { if m.Recording == "" { m.Recording = "---" } else { - m.Recording = fmt.Sprintf("[Recording](%s)", m.Recording) + m.Recording = fmt.Sprintf("[Video](%s)", m.Recording) } return []string{ diff --git a/scripts/del-codeblock.sh b/scripts/del-codeblock.sh new file mode 100755 index 0000000..e9f4411 --- /dev/null +++ b/scripts/del-codeblock.sh @@ -0,0 +1,11 @@ +#!/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 "Removed code block formatting from $FILE." diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 0000000..e9f4411 --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,11 @@ +#!/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 "Removed code block formatting from $FILE." diff --git a/tools.go b/tools.go index 99ae584..c06709f 100644 --- a/tools.go +++ b/tools.go @@ -4,7 +4,7 @@ package tools import ( - _ "github.com/leohhhn/embedmd" + _ "github.com/campoy/embedmd" _ "github.com/soypat/go-presentx" _ "golang.org/x/tools/cmd/present" _ "moul.io/mdtable"