⭐ Moe-Counter Compatible Website Hit Counter Written in Gleam
mayu.due.moe
hit-counter
svg
moe
1# ⭐ Mayu
2
3> Moe-Counter Compatible Website Hit Counter
4
5Mayu is a drop-in replacement for [Moe-Counter](https://github.com/journey-ad/Moe-Counter), designed
6to be lightweight and easy to use.
7
8Mayu is written in [Gleam](https://gleam.run) and uses [SQLite](https://sqlite.org) as its database.
9
10<br>
11
12<img src="https://mayu.due.moe/get/@demo" width="50%">
13
14<img src="https://mayu.due.moe/get/@demo?theme=urushi" width="50%">
15
16<br>
17
18Don't know Gleam or functional paradigms? Take a look at the [source tree](./src) and see just how
19easy it is to understand! It's all contained under 300 (273) effective lines of code!
20
21## Usage
22
23Mayu currently has nine available themes selectable using the `theme` query parameter of any `get` operation.
24
25E.g., [mayu.due.moe/get/@demo?theme=urushi](https://mayu.due.moe/get/@demo?theme=urushi)
26
27- `asoul`
28- `gelbooru-h` (NSFW)
29- `gelbooru`
30- `moebooru-h` (NSFW)
31- `moebooru`
32- `rule34` (NSFW)
33- `urushi`
34- `lain`
35- `garukura`
36
37Mayu will pad the counter number with zeroes until it reaches a length of 6 characters. You can modify this behaviour by changing the `padding` query parameter of any `get` operation.
38
39### Local
40
41```bash
42$ git clone git@github.com:Fuwn/mayu.git
43$ cd mayu
44$ gleam run
45$ # or
46$ nix run
47```
48
49### Docker
50
51```shell
52docker run --volume 'mayu:/mayu/data/' -p '80:3000' --rm fuwn/mayu:latest
53```
54
55This Docker command uses a named volume, `mayu`, which allows Mayu's database to persist between container restarts.
56
57### Database
58
59Mayu will use SQLite by default and will place the database file, `count.db`, within the `data/` directory of the project's root directory.
60
61Mayu has the same default database layout as Moe-Counter, so if you've already used Moe-Counter previously, Mayu will work off of any previously accumulated counter data, so long as you transfer the database file over.
62
63Mayu additionally adds two database columns: `created_at` and `updated_at`, which will not affect standard operations in any way, but will allow for additional data to be available should you perform a `record` operation.
64
65### Routes
66
67- `/heart-beat`: `alive`
68- `/get/@name`: An `image/xml+svg` counter, defaulting to theme `asoul`, modifiable using the `theme` query parameter
69- `/record/@name`: JSON object containing the database's `name`, `num`, `created_at`, and `updated_at` fields for counter `name`
70
71## Resource Attributions
72
73- [A-SOUL_Official](https://space.bilibili.com/703007996)
74- [Moebooru](https://github.com/moebooru/moebooru)
75- [Rule 34](https://rule34.xxx) (NSFW)
76- [Gelbooru](https://gelbooru.com) (NSFW)
77- [Urushi](https://x.com/udon0531/status/1350738347681959936)
78- [Lain Iwakura](https://x.com/lililjiliijili/status/869722811236929538)
79- [GaruKura](https://www.pixiv.net/artworks/119693017)
80
81## Licence
82
83This project is licensed under the [GNU General Public License v3.0](LICENSE).