zerosonesfun/flarum-log 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zerosonesfun/flarum-log

最新稳定版本:1.4.2

Composer 安装命令:

composer require zerosonesfun/flarum-log

包简介

Drink Log: track who's drinking and open a log discussion with one click.

README 文档

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.
    X is 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:
    1. Records your “drinking” click (live count + your profile total).
    2. Opens the new discussion composer with title Log - MM/DD/YYYY and, 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:

  1. Enable the Tags extension.
  2. 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:

  1. Tags extension is enabled (Administration → Extensions).
  2. A tag exists whose slug matches Drink Log’s “Log tag slug” (default log). Create it under Administration → Tags if needed.
  3. 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).
  4. If you installed from source (e.g. git), run npm run build in the extension’s js folder and deploy the updated js/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.

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固