From 004f2e9964c36e62b4da8d272cfd76c56dc81f1d Mon Sep 17 00:00:00 2001 From: Ahmed Date: Sun, 14 Jun 2026 16:24:32 +0300 Subject: init: coffee cups contributions tracker --- .build.yml | 15 + LICENSE | 21 ++ README.md | 119 +++++++ ccc.html | 924 +++++++++++++++++++++++++++++++++++++++++++++++++++++ data.json | 94 ++++++ hooks/post-receive | 8 + 6 files changed, 1181 insertions(+) create mode 100755 .build.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 ccc.html create mode 100644 data.json create mode 100644 hooks/post-receive diff --git a/.build.yml b/.build.yml new file mode 100755 index 0000000..6fce0a4 --- /dev/null +++ b/.build.yml @@ -0,0 +1,15 @@ +image: alpine/edge +oauth: pages.sr.ht/PAGES:RW +packages: + - hut +environment: + site: ccc.demo.gumx.cc +sources: + - https://git.sr.ht/~gumxcc/ccc +tasks: + - package: | + cd ccc + mv ccc.html index.html + tar -cvz index.html > ../site.tar.gz + - upload: | + hut pages publish -d $site site.tar.gz diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dd35f66 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Ahmed Mohamed Alaa + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5ade843 --- /dev/null +++ b/README.md @@ -0,0 +1,119 @@ +# ccc + +Coffee Cups Contributions. A single-file, dependency-free coffee intake tracker with a GitHub-style heatmap. No build step, no framework, plain HTML, CSS, and JavaScript. + +Live at [coffee.gumx.cc](https://coffee.gumx.cc). Source at [git.gumx.cc/ccc](https://git.gumx.cc/ccc). + +--- + +## Features + +- **Contributions heatmap** — 53 × 7 grid (Sunday-aligned) covering the past 52 weeks, rendered in SVG. Month labels along the top, Mon/Wed/Fri labels on the left. Today's cell has a visible outline. +- **5-level greyscale scale** — cup counts are bucketed proportionally to `MAX_CUPS` using `Math.round`. A legend is shown below the heatmap. +- **Hover tooltips** — hovering any cell shows the date and cup count in a fixed-position tooltip. +- **Two modes** — local mode (full editing, localStorage) or static site mode (read-only, fetches from a remote URL). +- **Stats** — today's cups, current streak, total cups, and daily average. +- **Light and dark mode** — full `prefers-color-scheme` support via CSS custom properties. The heatmap re-renders if the OS theme changes mid-session. + +--- + +## Files + +| File | Description | +|---|---| +| `ccc.html` | The entire application — one self-contained HTML file | +| `data.json` | Example data file for static site mode | +| `README.md` | This document | +| `LICENSE` | MIT licence | + +--- + +## Local Mode + +Local mode is active when `DATA_URL` is set to `""` (the default). All data is persisted to `localStorage` under the key `ccc_v1`. + +### Logging Coffee + +A **− / count / +** adjuster lets you set how many cups to log (1–10). The **+** button disables when `logCount` would exceed the remaining cups for today. The **log coffee** button disables when today has already reached `MAX_CUPS`. Both controls re-evaluate after every action. + +Clicking **log coffee** adds the selected count to today's total, hard-capped at `MAX_CUPS`. + +### Editing Past Days + +Click any heatmap cell to open an inline popover for that day. The popover shows: + +- The date +- **− / number input / +** to adjust the count (0–`MAX_CUPS`) +- **set** and **cancel** buttons + +Keyboard shortcuts work inside the popover: **Enter** confirms, **Escape** cancels. Clicking anywhere outside the popover also cancels. Setting a day's count to 0 removes the entry entirely. + +A hint below the log controls reads: *"click any cell to edit that day's count"*. + +### Import and Export + +- **Export JSON** — downloads your current data as `ccc-data.json`. +- **Import JSON** — opens a file picker; selecting a valid JSON file replaces the current data. Invalid files show an alert. + +The data format is described below. + +--- + +## Static Site Mode + +Static site mode is active when `DATA_URL` is set to a non-empty URL string. On load, the app fetches `data.json` (or whatever file is at that URL) and renders the heatmap from it. + +In static site mode: + +- All editing controls are hidden. +- Import and export are unavailable. +- A **"static site mode — read-only"** notice appears below the title. +- Data is never written to `localStorage`. + +To use static site mode, host `ccc.html` and `data.json` on any static hosting service (GitHub Pages, Netlify, etc.), then set `DATA_URL` to the full URL of `data.json`. + +--- + +## Configuration + +The `CONFIG` block is at the top of the ` + + + \ No newline at end of file diff --git a/data.json b/data.json new file mode 100644 index 0000000..7f45a82 --- /dev/null +++ b/data.json @@ -0,0 +1,94 @@ +{ + "entries": { + "2026-01-01": 2, + "2026-01-02": 2, + "2026-01-03": 3, + "2026-01-04": 3, + "2026-01-05": 3, + "2026-01-06": 1, + "2026-01-07": 2, + "2026-01-08": 2, + "2026-01-09": 1, + "2026-01-10": 2, + "2026-01-11": 1, + "2026-01-12": 4, + "2026-01-13": 3, + "2026-01-14": 1, + "2026-01-15": 1, + "2026-01-16": 1, + "2026-01-17": 2, + "2026-01-18": 3, + "2026-01-19": 3, + "2026-01-20": 3, + "2026-01-21": 2, + "2026-01-22": 2, + "2026-01-23": 1, + "2026-01-24": 1, + "2026-01-25": 2, + "2026-01-26": 2, + "2026-01-27": 1, + "2026-01-28": 2, + "2026-01-29": 1, + "2026-01-30": 2, + "2026-01-31": 2, + "2026-02-01": 1, + "2026-02-02": 1, + "2026-02-03": 1, + "2026-02-04": 3, + "2026-02-07": 2, + "2026-02-08": 2, + "2026-02-09": 3, + "2026-02-10": 1, + "2026-02-11": 3, + "2026-02-13": 2, + "2026-02-14": 2, + "2026-02-15": 2, + "2026-02-16": 2, + "2026-02-17": 1, + "2026-02-18": 1, + "2026-02-19": 1, + "2026-02-23": 2, + "2026-02-24": 1, + "2026-02-25": 2, + "2026-02-27": 1, + "2026-02-28": 1, + "2026-03-01": 1, + "2026-03-02": 2, + "2026-03-03": 1, + "2026-03-04": 1, + "2026-03-06": 1, + "2026-03-07": 2, + "2026-03-09": 2, + "2026-03-10": 2, + "2026-03-12": 1, + "2026-03-13": 1, + "2026-03-14": 2, + "2026-03-15": 3, + "2026-03-16": 3, + "2026-03-17": 1, + "2026-03-18": 1, + "2026-03-19": 2, + "2026-03-20": 1, + "2026-03-21": 1, + "2026-03-23": 1, + "2026-03-24": 3, + "2026-03-25": 3, + "2026-03-26": 3, + "2026-03-27": 4, + "2026-03-28": 4, + "2026-03-29": 4, + "2026-03-30": 2, + "2026-03-31": 2, + "2026-04-01": 1, + "2026-04-02": 2, + "2026-04-03": 2, + "2026-04-04": 3, + "2026-04-05": 1, + "2026-04-06": 2, + "2026-04-07": 1, + "2026-04-08": 3, + "2026-04-09": 2, + "2026-04-10": 2, + "2026-04-11": 2 + } +} \ No newline at end of file diff --git a/hooks/post-receive b/hooks/post-receive new file mode 100644 index 0000000..051bd55 --- /dev/null +++ b/hooks/post-receive @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +WORK=/home/git/build/ccc +WEBROOT=/var/www/coffee.gumx.cc +mkdir -p "$WEBROOT/fonts" +cp "$WORK/ccc.html" "$WEBROOT/index.html" +rsync -rlptD "$WORK/fonts/" "$WEBROOT/fonts/" 2>/dev/null || true +echo "ccc deployed to coffee.gumx.cc" -- cgit v1.2.3