Skip to content

Commit

Permalink
Merge branch 'master' into thescientist101/plugin-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
taciturnaxolotl authored Nov 8, 2024
2 parents 35cad26 + 2898f66 commit bbd2056
Show file tree
Hide file tree
Showing 14 changed files with 3,530 additions and 3,559 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
db: [sqlite, postgres, mysql, mariadb]
db: [sqlite, postgres]

steps:
- name: Check out code into the Go module directory
Expand Down
6 changes: 3 additions & 3 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ argument) or via environment variables. Here is an overview of all options.
| `app.avatar_url_template` /<br>`WAKAPI_AVATAR_URL_TEMPLATE` | (see [`config.default.yml`](config.default.yml)) | URL template for external user avatar images (e.g. from [Dicebear](https://dicebear.com) or [Gravatar](https://gravatar.com)) |
| `app.date_format` /<br>`WAKAPI_DATE_FORMAT` | `Mon, 02 Jan 2006` | Go time format strings to format human-readable date (see [`Time.Format`](https://pkg.go.dev/time#Time.Format)) |
| `app.datetime_format` /<br>`WAKAPI_DATETIME_FORMAT` | `Mon, 02 Jan 2006 15:04` | Go time format strings to format human-readable datetime (see [`Time.Format`](https://pkg.go.dev/time#Time.Format)) |
| `app.support_contact` /<br>`WAKAPI_SUPPORT_CONTACT` | `hostmaster@wakapi.dev` | E-Mail address to display as a support contact on the page |
| `app.support_contact` /<br>`WAKAPI_SUPPORT_CONTACT` | `hostmaster@waka.hackclub.com` | E-Mail address to display as a support contact on the page |
| `app.data_retention_months` /<br>`WAKAPI_DATA_RETENTION_MONTHS` | `-1` | Maximum retention period in months for user data (heartbeats) (-1 for unlimited) |
| `app.max_inactive_months` /<br>`WAKAPI_MAX_INACTIVE_MONTHS` | `12` | Maximum number of inactive months after which to delete user accounts without data (-1 for unlimited) |
| `server.port` /<br> `WAKAPI_PORT` | `3000` | Port to listen on |
Expand Down Expand Up @@ -141,7 +141,7 @@ argument) or via environment variables. Here is an overview of all options.
| `db.automgirate_fail_silently` /<br> `WAKAPI_DB_AUTOMIGRATE_FAIL_SILENTLY` | `false` | Whether to ignore schema auto-migration failures when starting up |
| `mail.enabled` /<br> `WAKAPI_MAIL_ENABLED` | `true` | Whether to allow Hackatime to send e-mail (e.g. for password resets) |
| `mail.welcome_enabled` /<br> `WAKAPI_WELCOME_ENABLED` | `true` | Whether Hackatime should send an e-mail on user signup |
| `mail.sender` /<br> `WAKAPI_MAIL_SENDER` | `Hackatime <noreply@wakapi.dev>` | Default sender address for outgoing mails |
| `mail.sender` /<br> `WAKAPI_MAIL_SENDER` | `Hackatime <noreply@waka.hackclub.com>` | Default sender address for outgoing mails |
| `mail.provider` /<br> `WAKAPI_MAIL_PROVIDER` | `smtp` | Implementation to use for sending mails (one of [`smtp`]) |
| `mail.smtp.host` /<br> `WAKAPI_MAIL_SMTP_HOST` | - | SMTP server address for sending mail (if using `smtp` mail provider) |
| `mail.smtp.port` /<br> `WAKAPI_MAIL_SMTP_PORT` | - | SMTP server port (usually 465) |
Expand Down Expand Up @@ -261,7 +261,7 @@ $ python scripts/download_heartbeats.py --api_key API_KEY [--url URL] [--from FR

```bash
python scripts/download_heartbeats.py --api_key 04648d14-15c9-432b-b901-dbeec70d4eaf \
--url https://wakapi.dev/api \
--url https://waka.hackclub.com/api \
--from 2023-01-01 \
--to 2023-01-31 \
--output wakapi_export.csv
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Clone the repo run `go build` and then `./hackatime -config config.yml`. More in

## 🔧 API endpoints

See our [Swagger API Documentation](https://wakapi.dev/swagger-ui).
See our [Swagger API Documentation](https://waka.hackclub.com/swagger-ui).

For signing up user programaticaly you can use the `/signup` endpoint with the admin token as Bearer and it will return a json object similar to the following:

Expand Down Expand Up @@ -93,15 +93,15 @@ section of your Hackatime instance's settings page.
Hackatime also integrates
with [GitHub Readme Stats](https://github.com/anuraghazra/github-readme-stats#wakatime-week-stats) to generate fancy
cards for you. Here is an example. To use this, don't forget to **enable public data**
under [Settings -> Permissions](https://wakapi.dev/settings#permissions).
under [Settings -> Permissions](https://waka.hackclub.com/settings#permissions).

![](https://github-readme-stats.vercel.app/api/wakatime?username=n1try&api_domain=wakapi.dev&bg_color=2D3748&title_color=2F855A&icon_color=2F855A&text_color=ffffff&custom_title=Hackatime%20Week%20Stats&layout=compact&range=last_7_days)
![](https://github-readme-stats.vercel.app/api/wakatime?username=U062UG485EE&api_domain=waka.hackclub.com&bg_color=2D3748&title_color=2F855A&icon_color=2F855A&text_color=ffffff&custom_title=Hackatime%20Week%20Stats&layout=compact&range=last_7_days)

<details>
<summary>Click to view code</summary>

```markdown
![](https://github-readme-stats.vercel.app/api/wakatime?username={yourusername}&api_domain=wakapi.dev&bg_color=2D3748&title_color=2F855A&icon_color=2F855A&text_color=ffffff&custom_title=Hackatime%20Week%20Stats&layout=compact)
![](https://github-readme-stats.vercel.app/api/wakatime?username={yourusername}&api_domain=waka.hackclub.com&bg_color=2D3748&title_color=2F855A&icon_color=2F855A&text_color=ffffff&custom_title=Hackatime%20Week%20Stats&layout=compact)
```

</details>
Expand All @@ -111,7 +111,7 @@ under [Settings -> Permissions](https://wakapi.dev/settings#permissions).

There is a [WakaTime plugin](https://github.com/lowlighter/metrics/tree/master/source/plugins/wakatime) for
GitHub [Metrics](https://github.com/lowlighter/metrics/) that is also compatible with Hackatime. To use this, don't forget
to **enable public data** under [Settings -> Permissions](https://wakapi.dev/settings#permissions).
to **enable public data** under [Settings -> Permissions](https://waka.hackclub.com/settings#permissions).

Preview:

Expand All @@ -129,7 +129,7 @@ Preview:
plugin_wakatime_days: 7 # Display last week stats
plugin_wakatime_sections: time, projects, projects-graphs # Display time and projects sections, along with projects graphs
plugin_wakatime_limit: 4 # Show 4 entries per graph
plugin_wakatime_url: http://wakapi.dev # Wakatime url endpoint
plugin_wakatime_url: http://waka.hackclub.com # Wakatime url endpoint
plugin_wakatime_user: .user.login # User
```
Expand All @@ -146,9 +146,9 @@ get started:
store ([Firefox](https://addons.mozilla.org/en-US/firefox/addon/wakatimes), [Chrome](https://chrome.google.com/webstore/detail/wakatime/jnbbnacmeggbgdjgaoojpmhdlkkpblgi?hl=de))
2. Open the extension settings dialog
3. Configure it like so (see screenshot below):
- API Key: Your personal API key (get it at [wakapi.dev](https://wakapi.dev))
- API Key: Your personal API key (get it at [waka.hackclub.com](https://waka.hackclub.com))
- Logging Type: _Only the domain_
- API URL: `https://wakapi.dev/api/compat/wakatime/v1` (alternatively, replace _wakapi.dev_ with your self-hosted
- API URL: `https://waka.hackclub.com/api/compat/wakatime/v1` (alternatively, replace _waka.hackclub.com_ with your self-hosted
instance hostname)
4. Save
5. Start browsing!
Expand Down
4 changes: 2 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ db:
security:
insecure_cookies: false # should be set to 'false', except when not running with HTTPS (e.g. on localhost)
cookie_max_age: 172800
allow_signup: true
allow_signup: false
signup_captcha: false
invite_codes: true # whether to enable invite codes for overriding disabled signups
invite_codes: false # whether to enable invite codes for overriding disabled signups
disable_frontpage: false
expose_metrics: true
trusted_header_auth: false # whether to enable trusted header auth for reverse proxies, use with caution!! (https://github.com/muety/wakapi/issues/534)
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type appConfig struct {
DataCleanupDryRun bool `yaml:"data_cleanup_dry_run" default:"false" env:"WAKAPI_DATA_CLEANUP_DRY_RUN"` // for debugging only
MaxInactiveMonths int `yaml:"max_inactive_months" default:"-1" env:"WAKAPI_MAX_INACTIVE_MONTHS"`
AvatarURLTemplate string `yaml:"avatar_url_template" default:"api/avatar/{username_hash}.svg" env:"WAKAPI_AVATAR_URL_TEMPLATE"`
SupportContact string `yaml:"support_contact" default:"hostmaster@wakapi.dev" env:"WAKAPI_SUPPORT_CONTACT"`
SupportContact string `yaml:"support_contact" default:"hostmaster@waka.hackclub.com" env:"WAKAPI_SUPPORT_CONTACT"`
DateFormat string `yaml:"date_format" default:"Mon, 02 Jan 2006" env:"WAKAPI_DATE_FORMAT"`
DateTimeFormat string `yaml:"datetime_format" default:"Mon, 02 Jan 2006 15:04" env:"WAKAPI_DATETIME_FORMAT"`
CustomLanguages map[string]string `yaml:"custom_languages"`
Expand Down
2 changes: 1 addition & 1 deletion etc/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ wakapi.yourdomain.tld {
}

log {
output file /var/log/caddy/wakapi.dev.access.log
output file /var/log/caddy/waka.hackclub.com.access.log
}

reverse_proxy http://[::1]:3000
Expand Down
2 changes: 1 addition & 1 deletion models/compat/shields/v1/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// https://shields.io/endpoint

const (
defaultLabel = "wakapi.dev"
defaultLabel = "waka.hackclub.com"
defaultColor = "2F855A"
)

Expand Down
22 changes: 22 additions & 0 deletions models/compat/wakatime/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ func NewFromUser(user *models.User) *User {
}
}

func RedactedFromUser(user *models.User) *User {
cfg := config.Get()
tz, _ := time.Now().Zone()
if user.Location != "" {
tz = user.Location
}

avatarURL := user.AvatarURL(cfg.App.AvatarURLTemplate)

if !strings.HasPrefix(avatarURL, "http") {
avatarURL = fmt.Sprintf("%s%s/%s", cfg.Server.GetPublicUrl(), cfg.Server.BasePath, avatarURL)
}

return &User{
DisplayName: user.ID,
TimeZone: tz,
CreatedAt: user.CreatedAt,
ModifiedAt: user.CreatedAt,
Photo: avatarURL,
}
}

func (u *User) WithLatestHeartbeat(h *models.Heartbeat) *User {
u.LastHeartbeatAt = h.Time
u.LastProject = h.Project
Expand Down
2 changes: 1 addition & 1 deletion routes/compat/wakatime/v1/leaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (h *LeadersHandler) buildViewModel(globalLeaderboard, languageLeaderboard m
}
}),
},
User: v1.NewFromUser(entry.User),
User: v1.RedactedFromUser(entry.User),
})
}

Expand Down
2 changes: 1 addition & 1 deletion routes/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (h *SummaryHandler) GetIndex(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, redirectAddress, http.StatusFound)
}

q.Set("interval", "today")
q.Set("interval", "high_seas")
r.URL.RawQuery = q.Encode()
} else if q.Get("interval") != "" {
// Send a Set-Cookie header to persist the interval
Expand Down
2 changes: 1 addition & 1 deletion scripts/download_heartbeats.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# globals
http: requests.Session = requests.Session()
api_url: str = 'https://wakapi.dev/api'
api_url: str = 'https://waka.hackclub.com/api'

Heartbeats = List[Dict[str, Any]]

Expand Down
8 changes: 4 additions & 4 deletions scripts/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# This script installs Wakapi.
#
# Quick install: `curl https://wakapi.dev/get | bash`
# Quick install: `curl https://waka.hackclub.com/get | bash`
#
# This script will install Wakapi to the directory you're in. To install
# somewhere else (e.g. /usr/local/bin), cd there and make sure you can write to
# that directory, e.g. `cd /usr/local/bin; curl https://wakapi.dev/get | sudo bash`
# that directory, e.g. `cd /usr/local/bin; curl https://waka.hackclub.com/get | sudo bash`
#
# Acknowledgments:
# - Micro Editor for this script: https://micro-editor.github.io/
Expand Down Expand Up @@ -75,9 +75,9 @@ B. Define GETWAKAPI_HTTP to be a command (with arguments deliminated by spaces)
For examples of option B, this script uses the below values for wget and curl:
$ curl https://wakapi.dev/get | GETWAKAPI_HTTP="curl -L" sh
$ curl https://waka.hackclub.com/get | GETWAKAPI_HTTP="curl -L" sh
$ wget -O- https://wakapi.dev/get | GETWAKAPI_HTTP="wget -O-" sh
$ wget -O- https://waka.hackclub.com/get | GETWAKAPI_HTTP="wget -O-" sh
EOA
exit 1
Expand Down
4 changes: 2 additions & 2 deletions services/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func (s *ActivityService) getChartPastYear(user *models.User, darkTheme, hideAtt

if !hideAttribution {
canvas.Group()
canvas.Title("Wakapi.dev")
canvas.Image(w-60, h-24, 60, 24, "https://wakapi.dev/assets/images/logo-gh.svg")
canvas.Title("waka.hackclub.com")
canvas.Image(w-60, h-24, 60, 24, "https://waka.hackclub.com/assets/images/logo-gh.svg")
canvas.Gend()
}

Expand Down
Loading

0 comments on commit bbd2056

Please sign in to comment.