From 77050f23f2840e512561ffa5c14945afd9ba555b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?=
Date: Sat, 6 Feb 2021 23:02:29 +0100
Subject: [PATCH] chore: settings interface for github readme stats
---
README.md | 13 +++++++++----
views/settings.tpl.html | 28 ++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 2ac7ad2..23f93cb 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@
* [How to use](#-how-to-use)
* [Configuration Options](#-configuration-options)
* [API Endpoints](#-api-endpoints)
-* [Prometheus Export](#%EF%B8%8F-prometheus-export)
+* [Integrations](#-integrations)
* [WakaTime Integration](#%EF%B8%8F-wakatime-integration)
* [Best Practices](#-best-practices)
* [Developer Notes](#-developer-notes)
@@ -61,7 +61,7 @@ I'd love to get some community feedback from active Wakapi users. If you want, p
* ✅ REST API
* ✅ Partially compatible with WakaTime
* ✅ WakaTime integration
-* ✅ Support for [Prometheus](https://github.com/muety/wakapi#%EF%B8%8F-prometheus-export) exports
+* ✅ Support for Prometheus exports
* ✅ Self-hosted
## 🚧 Roadmap
@@ -195,7 +195,8 @@ The following API endpoints are available. A more detailed Swagger documentation
* `GET /api/compat/wakatime/v1/users/current/summaries` (see [Wakatime API docs](https://wakatime.com/developers#summaries))
* `GET /api/health`
-## ⤴️ Prometheus Export
+## 🤝 Integrations
+### Prometheus Export
If you want to export your Wakapi statistics to Prometheus to view them in a Grafana dashboard or so please refer to an excellent tool called **[wakatime_exporter](https://github.com/MacroPower/wakatime_exporter)**.
[![](https://github-readme-stats.vercel.app/api/pin/?username=MacroPower&repo=wakatime_exporter&show_owner=true)](https://github.com/MacroPower/wakatime_exporter)
@@ -204,9 +205,13 @@ It is a standalone webserver that connects to your Wakapi instance and exposes t
Simply configure the exporter with `WAKA_SCRAPE_URI` to equal `"https://wakapi.your-server.com/api/compat/wakatime/v1"` and set your API key accordingly.
-## ⤵️ WakaTime Integration
+### WakaTime Integration
Wakapi plays well together with [WakaTime](https://wakatime.com). For one thing, you can **forward heartbeats** from Wakapi to WakaTime to effectively use both services simultaneously. In addition, there is the option to **import historic data** from WakaTime for consistency between both services. Both features can be enabled in the _Integrations_ section of your Wakapi instance's settings page.
+### GitHub Readme Stats Integrations
+Wakapi 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.
+![](https://github-readme-stats.vercel.app/api/wakatime?username=n1try&layout=compact&api_domain=wakapi.dev)
+
## 👍 Best Practices
It is recommended to use wakapi behind a **reverse proxy**, like [Caddy](https://caddyserver.com) or _nginx_ to enable **TLS encryption** (HTTPS).
However, if you want to expose your wakapi instance to the public anyway, you need to set `server.listen_ipv4` to `0.0.0.0` in `config.yml`
diff --git a/views/settings.tpl.html b/views/settings.tpl.html
index 8667160..a933ce6 100644
--- a/views/settings.tpl.html
+++ b/views/settings.tpl.html
@@ -416,6 +416,24 @@
access to the respective endpoint. See Public Data setting.
{{ end }}
+
+
+
+ GitHub Readme Stats
+
+
+
Wakapi intregrates with GitHub Readme Stats to generate fancy cards for you.
+
+ {{ if gt .User.ShareDataMaxDays 0 }}
+
Example
+
+
+
Source URL:
+ https://github-readme-stats.vercel.app/api/wakatime?username={{ .User.ID }}&layout=compact&api_domain=%s
+
+
+ {{ end }}
+
@@ -513,10 +531,20 @@
e.setAttribute('src', e.getAttribute('src').replace('%s', baseUrl))
e.classList.remove('hidden')
})
+ document.querySelectorAll('.with-url-src-no-scheme').forEach(e => {
+ const strippedUrl = baseUrl.replace(/https?:\/\//, '')
+ e.setAttribute('src', e.getAttribute('src').replace('%s', strippedUrl))
+ e.classList.remove('hidden')
+ })
document.querySelectorAll('.with-url-inner').forEach(e => {
e.innerHTML = e.innerHTML.replace('%s', baseUrl)
e.classList.remove('hidden')
})
+ document.querySelectorAll('.with-url-inner-no-scheme').forEach(e => {
+ const strippedUrl = baseUrl.replace(/https?:\/\//, '')
+ e.innerHTML = e.innerHTML.replace('%s', strippedUrl)
+ e.classList.remove('hidden')
+ })
const btnRegenerate = document.querySelector('#btn-regenerate-summaries')
const formRegenerate = document.querySelector('#form-regenerate-summaries')