1
0
mirror of https://github.com/mgerb/top-of-reddit synced 2026-01-13 03:52:49 +00:00

update go, add 2021 and 2022 lists

This commit is contained in:
2023-03-04 16:11:05 -06:00
parent 23e053fc2b
commit 913bbcd4f6
13 changed files with 1892 additions and 743 deletions

View File

@@ -6,9 +6,10 @@ import (
"os"
"sort"
"strconv"
"strings"
"time"
"github.com/mgerb/top-of-reddit/src/model"
"github.com/mgerb/top-of-reddit/model"
"github.com/olekukonko/tablewriter"
"github.com/boltdb/bolt"
@@ -116,11 +117,12 @@ func writeStatsToFile(posts []model.RedditPost) error {
data := [][]string{}
for _, v := range countList {
title := "[" + v[0].Title + "]" + "(https://www.reddit.com" + v[0].Permalink + ")"
escapedTitle := strings.ReplaceAll(v[0].Title, "|", "\\|")
title := "[" + escapedTitle + "]" + "(https://www.reddit.com" + v[0].Permalink + ")"
data = append(data, []string{v[0].Subreddit, strconv.Itoa(len(v)), title, strconv.Itoa(v[0].Score)})
}
file, _ := os.Create("counts.md")
file, _ := os.Create("README.md")
table := tablewriter.NewWriter(file)
table.SetAutoWrapText(false)

20
src/scripts/generate.sh Executable file
View File

@@ -0,0 +1,20 @@
# get first argument
if [ -z "$1" ]; then
echo "Please provide a year e.g. 'generate.sh 2023'"
exit 1
fi
rm README.md subreddits.txt wordcloud_$1.png;
go run generate-stats.go $1;
wordcloud_cli \
--text subreddits.txt \
--imagefile wordcloud_$1.png \
--color red \
--background white \
--height 2000 \
--width 2000 \
--margin 10 \
--mask ./circle.png

View File

@@ -1,9 +0,0 @@
wordcloud_cli \
--text subreddits.txt \
--imagefile output.png \
--color red \
--background white \
--height 2000 \
--width 2000 \
--margin 10 \
--mask ./circle.png