Counts your hits, man.
Find a file
2024-03-17 15:54:03 -07:00
migrations backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
src tidy, buff the readme 2024-03-17 15:54:03 -07:00
.gitignore backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
.rustfmt.toml backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
build.rs backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
Cargo.lock backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
Cargo.toml Quiet, clippy! 2024-03-17 15:29:01 -07:00
env.example backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
LICENSE.md backend works in theory, but I don't have a way to display the count, and no tests. 2024-03-17 14:57:17 -07:00
README.md tidy, buff the readme 2024-03-17 15:54:03 -07:00

Hitman counts your hits, man.

This is a simple webpage hit/visit counter service. To run in development, copy the provided env.example file to .env. By default, it will look for a database file in your home directory called .hitman.db. You can let hitman create it for you, or you can use the sqlx db create command (get by running cargo install sqlx-cli; see https://crates.io/crates/sqlx-cli ); if you do that, don't forget to also run sqlx migrate run, to create the tables. This project uses SQLx's compile-time SQL checking macros, so your DB needs to have the tables to allow the SQL checks to work.

How does it work?

If you wish to use this on your webpage, you need to add a couple lines. First, a "tracking pixel" that registers the current page's view:

<img src=http://localhost:5000/hit style="visibility:hidden">

Then, some javascript to retrieve the hit counts:

help I don't know how to javascript, we need to get http://localhost:5000/hits/all (or 'day' or
'week'), and that will return the number of recorded hits for this page for that time period.

It uses the referer header to get the page it was called from, and uses that as the key for counting the hit.