zerosonesfun / flarum-log
Drink Log: track who's drinking and open a log discussion with one click.
Package info
github.com/zerosonesfun/flarum-log
Type:flarum-extension
pkg:composer/zerosonesfun/flarum-log
Requires
- flarum/core: ^1.8.0
Requires (Dev)
- flarum/testing: ^1.0.0
This package is auto-updated.
Last update: 2026-03-09 22:51:00 UTC
README
A Flarum extension that adds a Drinking button, tracks who’s drinking (live count + per-user totals), and opens a dated log discussion with an optional Log tag.
- Compatible: Flarum 1.8.x
- Install:
composer require zerosonesfun/flarum-log:"*" - Best experience: Install FoF Direct Links so the composer opens with title, Log tag, and a simple body template already filled in.
Features
- “X Drinking” button (logged-in only): in the sidebar on desktop (under “Start a discussion”), and in the drawer under the search bar on mobile.
Xis the number of users who have clicked in the last 30 minutes (configurable 1–1440). - Cooldown: Each user can add to the live count once per cooldown window; the number goes down as older clicks expire.
- One click does two things:
- Records your “drinking” click (live count + your profile total).
- Opens the new discussion composer with title
Log - MM/DD/YYYYand, when configured, the Log tag. With FoF Direct Links, the composer also opens with a small body template (Date, Time, Location, Amount, Variety).
- Profile total: Each user’s public profile shows their total drinks (e.g. “1 drink” or “1.5k drinks”). It increases when they use the button (after cooldown) or when they manually create a discussion and add the Log tag, and decreases by 1 when they delete one of their own discussions that has the Log tag.
- Profile “Drink Logs” tab: On a user’s profile, a Drink Logs nav item appears under Posts (when Tags is enabled and a Log tag is configured). It shows the number of discussions they’ve created with the Log tag; clicking it loads a list of those discussions.
- Manual Log tag: If someone starts a new discussion and adds the Log tag in the composer (without using the Drinking button), their profile total still increases by 1.
Installation
composer require zerosonesfun/flarum-log:"*"
php flarum migrate
Enable Drink Log in Admin → Extensions.
Recommended: FoF Direct Links (best experience)
For the best experience, install FriendsOfFlarum/direct-links:
composer require fof/direct-links
With Direct Links enabled and a Log tag slug set in Drink Log’s settings, clicking the Drinking button opens the composer via a direct link with:
- Title pre-filled:
Log - DD/MM/YYYY - Primary tag pre-selected: your configured Log tag
- Body pre-filled with a short template:
Date,Time,Location,Amount,Variety
Without Direct Links, the composer still opens in-app with the title set, and the Log tag is attached when you post (for “Log - date” discussions).
Optional: Tags extension and Log tag
If you use flarum/tags:
- Enable the Tags extension.
- In Administration → Tags, create a tag with the slug you set in Drink Log’s Log tag slug (default
log). The extension does not create the tag for you.
New “Log - date” discussions started from the Drinking button get that tag attached automatically. If a user manually adds the Log tag to any new discussion, their profile drink total also increases by 1. This extension never deletes or changes existing tags.
Admin settings
In Administration → Extensions → Drink Log you can set:
- Button label – Text on the button. Use
{count}for the number (e.g.{count} Drinking). - Cooldown (minutes) – Minutes before a user can add to the live count again (1–1440; default 30).
- Log tag slug – Tag slug to attach to “Log - date” discussions and to use with Direct Links. Leave empty to disable auto-tagging and direct-link composer.
Building the frontend (developers)
cd js
npm install
npm run build
This updates js/dist/forum.js and js/dist/admin.js. Commit those files if you ship a pre-built bundle.
Troubleshooting
“Drink Logs” tab doesn’t appear on user profiles
The tab only shows when the forum has a valid Log tag. Check:
- Tags extension is enabled (Administration → Extensions).
- A tag exists whose slug matches Drink Log’s “Log tag slug” (default
log). Create it under Administration → Tags if needed. - Clear Flarum cache so the forum payload includes the tag id:
php flarum cache:clear
Then hard-refresh the forum (Ctrl+F5 / Cmd+Shift+R). - If you installed from source (e.g. git), run
npm run buildin the extension’sjsfolder and deploy the updatedjs/dist/forum.js.
Profile drink total doesn’t decrease when a user deletes a log discussion
The extension now listens for both Deleting (hard delete) and Hidden (soft delete / “delete” in the UI). After updating, hiding or deleting a discussion that has the Log tag will decrement the author’s total. Clear cache and refresh; if it still doesn’t update, confirm the discussion had the Log tag and the Tags extension is enabled.
Security
- Only logged-in users see and can use the Drinking button.
- The “record drink” API requires authentication; cooldown is enforced per user on the backend.
- Profile totals are public; only the count is stored (no extra personal data).
License
MIT.