Skip to content

Commit 9a43ff0

Browse files
committed
Add new version descriptions to the CHANGELOG, update the README, and provide a Chinese version.
1 parent 01b52db commit 9a43ff0

5 files changed

Lines changed: 244 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## 0.14.0
4+
5+
### Added
6+
- **Comment Replies**: Implemented a comment reply feature. Users can now reply to specific messages, with a link that scrolls to the original message.
7+
- **Authenticated Media**: Added support for fetching media from private Matrix rooms for authenticated users.
8+
- **Internationalization (i18n)**: Introduced multilingual support, allowing the UI language to be configured. Shipped with English and Chinese translations.
9+
- **Read-Only Mode**: Added a `commentEnabled` configuration option to disable commenting, providing a read-only view of the comment section.
10+
11+
### Changed
12+
- **Performance**: Overhauled media caching by replacing the `localStorage` system with a more robust **IndexedDB** implementation, significantly reducing redundant downloads and improving load times.
13+
- **Performance**: Eliminated comment section flickering during updates (e.g., loading more comments, posting) by using keyed rendering. This preserves the playback state of embedded media.
14+
- **UI**: Improved the reply functionality with rich-text hover previews, SVG icons, message highlighting on scroll, and better `<blockquote>` styling.
15+
16+
### Fixed
17+
- **"View More" Spam**: Prevented duplicate comments from being loaded by disabling the "View more" button during both initial and subsequent comment fetches.
18+
- **Reply Tooltips**: Fixed issues where reply tooltips would overlap with the browser's native title attribute and would not disappear correctly on mobile devices.
19+
- **Layout & Styling**: Resolved various CSS issues, including:
20+
- Code blocks and audio players overflowing their containers.
21+
- Incorrect wrapping for inline code.
22+
- Poorly rendered tooltips in dark mode.
23+
- Incorrect icon sizes and whitespace in the reply editor.
24+
325
## 0.13.0
426

527
- Fix for missing `end` tokens, in sync responses from Synapse >= v1.61.0 (Thanks to Tom Price for !20).

README.md

Lines changed: 98 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
[简体中文](./README.zh-CN.md)
2+
3+
---
4+
15
![](./assets/readme-header.png)
26

3-
An embeddable web client for federated comments using the Matrix network.
7+
An embeddable web client for federated comments using the Matrix network. This fork revitalizes the original Cactus Comments with new features and bug fixes.
48

59
[![pipeline status](https://gitlab.com/cactus-comments/cactus-client/badges/main/pipeline.svg)](https://gitlab.com/cactus-comments/cactus-client/-/commits/main)
610
[![](https://img.shields.io/badge/chat-%23cactus%3Acactus.chat-informational)](https://matrix.to/#/%23cactus:cactus.chat)
@@ -14,32 +18,110 @@ There are two components to Cactus Comments:
1418

1519
This repository is only the web client.
1620

17-
1821
# Demo
1922

20-
You can play with a live demo at [cactus.chat/demo](https://cactus.chat/demo/)
23+
You can play with a live demo at [nigzu.com](https://nigzu.com).
24+
25+
## Screenshots
26+
27+
![](./assets/reply-and-preview.gif)
28+
![](./assets/loading-and-night-mode.gif)
29+
30+
# Features
2131

32+
- **Modern Architecture**: Refactored to support **Node.js v22+**.
33+
- **Enhanced Media Support**:
34+
- **Authenticated Media**: Supports Matrix's authenticated media endpoints (`isAuthenticated: true`) with a three-tier caching system (Memory, IndexedDB, Network) for optimized loading.
35+
- **Full Reply Functionality**:
36+
- **Quote Replies**: Clear context for replies.
37+
- **Hover Preview**: Instantly preview the content of a reply (text, image, video).
38+
- **Click to Jump**: Navigate to the original message.
39+
- **Read-Only Mode**: A `commentEnabled: false` option to disable commenting, perfect for archives or announcements.
40+
- **Internationalization**:
41+
- **Language Switching**: `language` option to set the display language.
42+
- **Flexible Translations**: Supports custom translation files (JS or JSON) with smart fallbacks.
43+
- **UI/UX Fixes**:
44+
- Fixed layout overflows and text wrapping issues.
45+
- **Incremental Loading**: "Load More" now appends comments instead of refreshing the entire section, preventing flickers and improving performance.
2246

23-
# Example Usage
47+
# Quick Start
2448

25-
Here is a minimal HTML page with the latest Cactus Comments release:
49+
1. Download the latest release from the [release page](https://github.com/code-gal/cactus-client).
50+
2. Upload `cactus.js`, `style.css`, and `cactus-lang.js` to your server or CDN.
51+
3. Include the files in your HTML:
2652

2753
```html
28-
<link rel="stylesheet" type="text/css" href="https://latest.cactus.chat/style.css" />
29-
<script type="text/javascript" src="https://latest.cactus.chat/cactus.js"
30-
data-default-homeserver-url="https://matrix.cactus.chat:8448"
31-
data-server-name="cactus.chat"
32-
data-site-name="my-blog"
33-
data-comment-section-id="example-page">
34-
</script>
54+
<link rel="stylesheet" href="path/to/your/style.css" type="text/css">
55+
<script type="text/javascript" src="path/to/your/cactus.js"></script>
56+
<script type="text/javascript" src="path/to/your/cactus-lang.js"></script>
3557
```
3658

37-
This is a valid configuration for the client. You also need to use an appservice.
38-
You can [host your own](https://cactus.chat/docs/server/self-host/), or [use the public one at cactus.chat](https://cactus.chat/docs/getting-started/quick-start/#register-your-site).
59+
4. Add the comment section container and initialize the client:
3960

40-
Check out the [Quick Start guide](https://cactus.chat/docs/getting-started/quick-start/) on our website for a more complete tutorial.
61+
```html
62+
<div id="comment-section"></div>
63+
64+
<script>
65+
initComments({
66+
// Required
67+
node: document.getElementById("comment-section"),
68+
defaultHomeserverUrl: "https://matrix.cactus.chat:8448",
69+
serverName: "cactus.chat",
70+
siteName: "your-site-name", // The unique name you registered for your site.
71+
commentSectionId: "unique-page-id", // A unique ID for each page's comment section.
72+
73+
// Optional - New Features!
74+
isAuthenticated: true, // Set to true if your homeserver uses authenticated media.
75+
commentEnabled: true, // Set to false for read-only mode.
76+
language: 'en', // e.g., 'en', 'cn', 'fr'.
77+
translationsData: 'cactusTranslations', // Translation file, you can also provide it on your own website.
78+
79+
// Other optional parameters...
80+
pageSize: 10,
81+
loginEnabled: true,
82+
guestPostingEnabled: true,
83+
});
84+
</script>
85+
```
4186

87+
You also need to use an appservice. You can [host your own](https://cactus.chat/docs/server/self-host/), or [use the public one at cactus.chat](https://cactus.chat/docs/getting-started/quick-start/#register-your-site). For self-hosting, see the instructions below.
88+
89+
# Configuration
90+
91+
The `initComments` function accepts the following parameters:
92+
93+
| Name | Type | Required | Default | Description |
94+
| :--- | :--- | :--- | :--- | :--- |
95+
| `node` | HTMLElement/String | Yes | - | The HTML element (or a selector string) to be replaced by the comment section. |
96+
| `defaultHomeserverUrl` | String | Yes | - | The URL of the Matrix homeserver that has the Cactus Comments appservice. |
97+
| `serverName` | String | Yes | - | The server name of the Matrix homeserver. |
98+
| `siteName` | String | Yes | - | The unique identifier for your site registered with the Cactusbot. |
99+
| `commentSectionId` | String | Yes | - | A unique identifier for the comment section, used to create the room alias. |
100+
| `pageSize` | Integer | No | 10 | Number of comments to load initially and on "load more". |
101+
| `loginEnabled` | Boolean | No | true | If true, users can log in with their Matrix credentials. |
102+
| `guestPostingEnabled` | Boolean | No | true | If true, users can post comments as guests without logging in. |
103+
| `updateInterval` | Float | No | 0 | Interval in seconds to fetch new comments. 0 or negative disables it. |
104+
| `isAuthenticated` | Boolean | No | false | Enable for homeservers with authenticated media. |
105+
| `commentEnabled` | Boolean | No | true | Set to `false` to make the comment section read-only. |
106+
| `translationsData` | String | No | `cactusTranslations` | The variable name for translation data. Defaults to the one in `cactus-lang.js`. |
107+
| `language` | String | No | `en` | An ISO 639 language code (e.g., `cn`, `fr`, `en`). |
108+
109+
# Self-Hosting
110+
111+
When self-hosting the Matrix server (e.g., Synapse) and the [Cactus Appservice](https://gitlab.com/cactus-comments/cactus-appservice), make sure to:
112+
113+
1. **Enable Guest Access** in your `homeserver.yaml`:
114+
```yaml
115+
allow_guest_access: true
116+
```
117+
2. **Enable Legacy Appservice Authorization**: The Cactus Appservice requires an older authorization mechanism. Add this to your `homeserver.yaml` to allow the bot to register and manage rooms correctly:
118+
```yaml
119+
use_appservice_legacy_authorization: true
120+
```
121+
> **Warning**: This is required for the appservice to create its management bot and for you to register sites. Without it, the appservice will fail with a `401 CHAT.CACTUS.APPSERVICE_UNAUTHORIZED` error.
42122

43123
# Documentation
44124

45-
The complete documentation is available at our website, [cactus.chat](https://cactus.chat).
125+
The complete documentation for the original project is available at our website, [cactus.chat](https://cactus.chat). Note that it may not cover the new features introduced in this fork.
126+
127+
For more instructions and detailed tutorials on this new branch, please refer to the article (in Chinese): [Rejuvenating the Matrix Commenting System: New Features I Developed for Cactus Comments](https://nigzu.com/matrix-cactus-comments-new-features-installation-tutorial/).

README.zh-CN.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
[English](./README.md)
2+
3+
---
4+
![](./assets/readme-header.png)
5+
6+
一个基于 Matrix 联邦网络的、可嵌入的网页评论客户端。本项目分支为原 Cactus Comments 带来了多项新功能和问题修复。
7+
8+
[![pipeline status](https://gitlab.com/cactus-comments/cactus-client/badges/main/pipeline.svg)](https://gitlab.com/cactus-comments/cactus-client/-/commits/main)
9+
[![](https://img.shields.io/badge/chat-%23cactus%3Acactus.chat-informational)](https://matrix.to/#/%23cactus:cactus.chat)
10+
[![](https://img.shields.io/badge/donate-via%20opencollective-orange)](https://opencollective.com/cactus-comments)
11+
12+
Cactus Comments 由两部分组成:
13+
14+
- 可嵌入的 Web 客户端 (本仓库)
15+
- 服务端的 Appservice ([点击这里](https://gitlab.com/cactus-comments/cactus-appservice))
16+
17+
本仓库仅包含 Web 客户端部分。
18+
19+
# 在线演示
20+
21+
你可以在[nigzu.com](https://nigzu.com)上体验新功能的实时演示。
22+
23+
## 截图
24+
25+
![](./assets/reply-and-preview.gif)
26+
![](./assets/loading-and-night-mode.gif)
27+
28+
# ✨ 新功能亮点
29+
30+
- **架构更新**: 重构了项目配置,现已支持在 **Node.js v22+** 环境下进行开发和部署。
31+
- **媒体功能升级**:
32+
- **安全媒体支持**: 新增 `isAuthenticated: true` 选项,用于支持 Matrix 服务端的媒体认证,并内置三级缓存系统(内存、IndexedDB、网络请求)以优化加载速度。
33+
- **完整的消息回复功能**:
34+
- **引用回复**: 清晰地展示消息的上下文关系。
35+
- **悬停预览**: 鼠标悬停在引用上可立即预览原文(支持文本、图片、视频)。
36+
- **点击跳转**: 点击引用可快速定位到原始消息。
37+
- **只读模式**: 新增 `commentEnabled: false` 配置,可将评论区设置为只读,适用于内容归档或展示场景。
38+
- **全面的多语言支持**:
39+
- **语言切换**: 通过 `language` 选项自由设定显示语言。
40+
- **灵活的翻译方案**: 支持独立的 JS 或 JSON 翻译文件,并提供智能回退机制。
41+
- **前端体验修复**:
42+
- 修复了多项核心样式问题,如元素溢出、文本换行等。
43+
- **增量加载**: 点击“查看更多”现在只会追加新评论,避免了整个评论区刷新带来的闪烁和状态问题。
44+
45+
# 快速开始
46+
47+
1.[release](https://github.com/code-gal/cactus-client)下载最新的版本。
48+
2.`cactus.js``style.css``cactus-lang.js` 三个文件上传到您的服务器或 CDN。
49+
3. 在您的网站 HTML 页面中引入这些文件:
50+
51+
```html
52+
<link rel="stylesheet" href="path/to/your/style.css" type="text/css">
53+
<script type="text/javascript" src="path/to/your/cactus.js"></script>
54+
<script type="text/javascript" src="path/to/your/cactus-lang.js"></script>
55+
```
56+
57+
4. 在页面中添加评论区容器,并初始化脚本:
58+
59+
```html
60+
<div id="comment-section"></div>
61+
62+
<script>
63+
initComments({
64+
// 必填参数
65+
node: document.getElementById("comment-section"),
66+
defaultHomeserverUrl: "https://matrix.cactus.chat:8448",
67+
serverName: "cactus.chat",
68+
siteName: "your-site-name", // 您注册的站点唯一名称
69+
commentSectionId: "unique-page-id", // 每个页面评论区的唯一ID
70+
71+
// 可选参数 - 新功能!
72+
isAuthenticated: true, // 如果您的 Matrix 服务端开启了媒体认证,请设置为 true
73+
commentEnabled: true, // 设置为 false 以开启只读模式
74+
language: 'cn', // 语言代码, 例如 'en', 'cn', 'fr'
75+
translationsData: 'cactusTranslations' //翻译文件,你也可以在自己的网站上提供
76+
// 其他可选参数...
77+
pageSize: 10,
78+
loginEnabled: true,
79+
guestPostingEnabled: true,
80+
});
81+
</script>
82+
```
83+
84+
您还需要一个正常运行的 appservice。您可以[自托管](https://cactus.chat/docs/server/self-host/),或使用官方位于 [cactus.chat](https://cactus.chat/docs/getting-started/quick-start/#register-your-site) 的公共服务。关于自托管的注意事项,请参考下文。
85+
86+
# 配置参数
87+
88+
`initComments` 函数接受以下参数:
89+
90+
| 名称 | 类型 | 必填 | 默认值 | 描述 |
91+
| :--- | :--- | :--- | :--- | :--- |
92+
| `node` | HTML 元素或字符串 || - | 页面上将被评论区替换的 HTML 元素(或其选择器字符串)。 |
93+
| `defaultHomeserverUrl` | 字符串 || - | 部署了 Cactus Comments 应用服务的 Matrix 主服务器 URL。 |
94+
| `serverName` | 字符串 || - | Matrix 主服务器的域名。 |
95+
| `siteName` | 字符串 || - | 您通过 Cactusbot 注册的站点唯一标识符。 |
96+
| `commentSectionId` | 字符串 || - | 评论区的唯一标识符,用于生成 Matrix 房间别名。 |
97+
| `pageSize` | 整数 || 10 | 初始加载以及每次点击“查看更多”时加载的评论数量。 |
98+
| `loginEnabled` | 布尔值 || true | 若为 true,用户可使用 Matrix 凭据在页面登录。 |
99+
| `guestPostingEnabled` | 布尔值 || true | 若为 true,用户可无需登录以访客身份发表评论。 |
100+
| `updateInterval` | 浮点数 || 0 | 获取新评论的时间间隔(秒)。若为零或负值,则不自动更新。 |
101+
| `isAuthenticated` | 布尔值 || false | 为开启了媒体认证的 homeserver 启用此项。 |
102+
| `commentEnabled` | 布尔值 || true | 设置为 `false` 可使评论区变为只读模式。 |
103+
| `translationsData` | 字符串 || `cactusTranslations` | 翻译数据的变量名。默认为 `cactus-lang.js` 中定义的 `cactusTranslations`|
104+
| `language` | 字符串 || `en` | 符合 ISO 639 标准的语言代码,如 `cn``fr``en`|
105+
106+
# 自托管部署
107+
108+
当您自托管 Matrix 服务端 (例如 Synapse) 和 [Cactus Appservice](https://gitlab.com/cactus-comments/cactus-appservice) 时,请确保:
109+
110+
1. **启用访客模式**: 在您的 `homeserver.yaml` 中:
111+
```yaml
112+
allow_guest_access: true
113+
```
114+
2. **启用旧版 Appservice 授权**: Cactus Appservice 依赖一个较旧的授权机制。请在 `homeserver.yaml` 中添加以下配置,以确保机器人可以被正确创建并管理房间:
115+
```yaml
116+
use_appservice_legacy_authorization: true
117+
```
118+
> **警告**: 此选项对于应用服务创建其管理机器人以及您注册站点至关重要。若未启用,应用服务将因 `401 CHAT.CACTUS.APPSERVICE_UNAUTHORIZED` 错误而失败。
119+
120+
# 文档
121+
122+
原项目的完整文档位于其官方网站 [cactus.chat](https://cactus.chat)。请注意,该文档可能未覆盖此分支中引入的新功能。
123+
124+
该新分支的更多说明和详细教程参考文章(中文):[让Matrix评论系统重焕新生:我为 Cactus Comments 开发了些新功能](https://nigzu.com/matrix-cactus-comments-new-features-installation-tutorial/)。

assets/loading-and-night-mode.gif

6.2 MB
Loading

assets/reply-and-preview.gif

1.77 MB
Loading

0 commit comments

Comments
 (0)