Moe-Counter Compatible Website Hit Counter
Mayu is a drop-in replacement for Moe-Counter, designed to be lightweight and easy to use.
Mayu is written in Gleam and uses SQLite as its database.
Don't know Gleam or functional paradigms? Take a look at the source tree and see just how easy it is to understand! It's all contained under 300 (273) effective lines of code!
Mayu currently has nine available themes selectable using the theme query parameter of any get operation.
E.g., mayu.due.moe/get/@demo?theme=urushi
asoulgelbooru-h(NSFW)gelboorumoebooru-h(NSFW)moeboorurule34(NSFW)urushilaingarukura
Mayu 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, up to a maximum of 12.
$ git clone git@github.com:Fuwn/mayu.git
$ cd mayu
$ gleam run
$ # or
$ nix rundocker run --volume 'mayu:/mayu/data/' -p '80:3000' --rm fuwn/mayu:latestThis Docker command uses a named volume, mayu, which allows Mayu's database to persist between container restarts.
Mayu will use SQLite by default and will place the database file, count.db, within the data/ directory of the project's root directory.
Mayu 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.
Mayu 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.
Mayu is configured through environment variables, all of which are optional.
| Variable | Description |
|---|---|
MAYU_THEMES |
Comma-separated allowlist of themes to load, e.g. asoul,garukura. When unset, every theme is loaded. Restricting it lowers memory use and caps the maximum response size. |
MAYU_VERSION |
Version string shown on the index page. Set automatically by the Docker image. |
MAYU_PRUNE_MIN_COUNT |
Counters with fewer than this many hits are eligible for pruning. |
MAYU_PRUNE_AFTER_DAYS |
Counters not incremented within this many days are eligible for pruning. |
MAYU_PRUNE_EVERY_HOURS |
How often, in hours, the prune sweep runs. |
Counter pruning is disabled unless all three MAYU_PRUNE_* variables are set to positive integers. When enabled, each sweep deletes counters that are both idle and low: not incremented within MAYU_PRUNE_AFTER_DAYS and below MAYU_PRUNE_MIN_COUNT hits. Actively used counters and high-count counters are always kept, so abandoned throwaway counters are reclaimed without affecting real ones.
/heart-beat:alive/get/@name: Animage/xml+svgcounter, defaulting to themeasoul, modifiable using thethemequery parameter/record/@name: JSON object containing the database'sname,num,created_at, andupdated_atfields for countername
- A-SOUL_Official
- Moebooru
- Rule 34 (NSFW)
- Gelbooru (NSFW)
- Urushi
- Lain Iwakura
- GaruKura
This project is licensed under the GNU General Public License v3.0.