Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/its-just-nans/go-calendar
Generate a calendar from a JSON file
https://github.com/its-just-nans/go-calendar
calendar calendar-generator generator go golang json
Last synced: about 1 month ago
JSON representation
Generate a calendar from a JSON file
- Host: GitHub
- URL: https://github.com/its-just-nans/go-calendar
- Owner: Its-Just-Nans
- License: mit
- Created: 2023-12-03T17:53:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-17T21:35:59.000Z (about 1 year ago)
- Last Synced: 2024-08-05T06:09:20.240Z (5 months ago)
- Topics: calendar, calendar-generator, generator, go, golang, json
- Language: Go
- Homepage: https://pkg.go.dev/github.com/Its-Just-Nans/go-calendar
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-calendar
Generate a calendar from a JSON file.
![Example](./example.svg)
## Options with args
| Option | Description | Default |
| ------- | ------------------------------- | ---------- |
| -k KEY | Key of the date | date |
| -c KEY | Key of the counter | |
| -d | First day of the week | 1 (Monday) |
| -i FILE | Path to the JSON file | data.json |
| -o FILE | Path to the output file | out.svg |
| -q | Quiet mode | false |
| -h | Hexa color (alpha is optionnal) | 00C8C8FF |## Usage
There are differents possible usages depending on your JSON file.
JSON file with dates
```json
[
{
"date": "2022-11-06",
},
{
"date": "2022-11-07",
},
]
```You will need to specify the key of the date and the key of the counter
```sh
go run github.com/Its-Just-Nans/go-calendar -k date
```JSON file with a counter
```json
[
{
"date": "2022-11-06",
"num": 9
},
{
"date": "2022-11-06",
"num": 1
},
]
```You will need to specify the key of the date and the key of the counter
```sh
go run github.com/Its-Just-Nans/go-calendar -k date -c num
```## Example
Generate calendar from Github contributions
Using [gh api](https://cli.github.com/manual/gh) and [jq](https://github.com/jqlang/jq), you can get your contributions from Github with
```sh
gh api graphql -F owner='Its-Just-Nans' -f query='
query( $owner: String!) {
user(login: $owner) {
contributionsCollection {
contributionCalendar {
totalContributions
weeks {
contributionDays {
contributionCount
weekday
date
}
}
}
}
}}' | jq '[.data.user.contributionsCollection.contributionCalendar.weeks | .[].contributionDays |.[] | {date: (.date), num:(.contributionCount)}]' > out.json
```Then you can generate the calendar with
```sh
go run github.com/Its-Just-Nans/go-calendar -k date -c num -i out.json -o contributions.svg
```## License
[License MIT](./LICENSE)