Counts your hits, man.
Go to file
Joe Ardent aad60a5752 Make the sample javascript first register the hit, then fetch the count. 2024-03-28 22:16:18 -07:00
migrations use text for key 2024-03-28 09:37:39 -07:00
src Make the sample javascript first register the hit, then fetch the count. 2024-03-28 22:16:18 -07:00
user Make the sample javascript first register the hit, then fetch the count. 2024-03-28 22:16:18 -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
Cargo.lock use text for key 2024-03-28 09:37:39 -07:00
Cargo.toml use text for key 2024-03-28 09:37:39 -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
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
env.example adding hour-based visitation key, other stuff 2024-03-27 11:54:34 -07:00
favicon.ico adding hour-based visitation key, other stuff 2024-03-27 11:54:34 -07:00
index.html Make the sample javascript first register the hit, then fetch the count. 2024-03-28 22:16:18 -07:00

README.md

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.