2022-09-09 11:37:52 +00:00
# Setting up Cactus Comments (optional)
2024-01-09 07:53:01 +00:00
The playbook can install and configure the [Cactus Comments ](https://cactus.chat ) system for you.
2022-09-09 11:37:52 +00:00
2024-01-09 07:53:01 +00:00
Cactus Comments is a **federated comment system** built on Matrix. It respects your privacy, and puts you in control.
2022-09-09 11:37:52 +00:00
2024-10-19 10:19:22 +00:00
See the project's [documentation ](https://cactus.chat/docs/getting-started/introduction/ ) to learn what it does and why it might be useful to you.
2022-09-09 11:37:52 +00:00
2024-01-09 07:53:01 +00:00
The playbook contains 2 roles for configuring different pieces of the Cactus Comments system:
- `matrix-cactus-comments` - the backend appservice integrating with the Matrix homeserver
- `matrix-cactus-comments-client` - a static website server serving the [cactus-client ](https://cactus.chat/docs/client/introduction/ ) static assets (`cactus.js` and `styles.css` )
You can enable whichever component you need (typically both).
2022-09-09 11:37:52 +00:00
## Configuration
2024-10-19 11:22:13 +00:00
Add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file:
2022-09-09 11:37:52 +00:00
2022-09-09 11:43:49 +00:00
```yaml
2022-09-09 11:37:52 +00:00
#################
2024-10-10 18:15:07 +00:00
## Cactus Comments ##
2022-09-09 11:37:52 +00:00
#################
2024-01-08 17:57:18 +00:00
# This enables the backend (appservice)
2022-09-09 11:37:52 +00:00
matrix_cactus_comments_enabled: true
# To allow guest comments without users needing to log in, you need to have guest registration enabled.
2024-01-08 17:57:18 +00:00
# To do this you need to uncomment one of the following lines (depending if you are using Synapse or Dendrite as a homeserver)
# If you don't know which one you use: The default is Synapse ;)
2022-09-09 11:37:52 +00:00
# matrix_synapse_allow_guest_access: true
2024-01-08 17:57:18 +00:00
# matrix_dendrite_allow_guest_access: true
2024-01-09 07:53:01 +00:00
2024-10-17 13:17:56 +00:00
# This enables client assets static files serving on `https://matrix.example.com/cactus-comments`.
2024-01-09 07:53:01 +00:00
# When the backend (appservice) is enabled, this is also enabled automatically,
# but we explicitly enable it here.
matrix_cactus_comments_client_enabled: true
2024-10-14 05:42:02 +00:00
# Uncomment and adjust this part if you'd like to host the client assets at a different location.
2024-01-09 07:53:01 +00:00
# These variables are only make used if (`matrix_cactus_comments_client_enabled: true`)
# matrix_cactus_comments_client_hostname: "{{ matrix_server_fqn_matrix }}"
# matrix_cactus_comments_client_path_prefix: /cactus-comments
2022-09-09 11:37:52 +00:00
```
## Installing
2024-10-12 18:03:46 +00:00
After configuring the playbook, run the [installation ](installing.md ) command: `just install-all` or `just setup-all`
2022-09-09 11:37:52 +00:00
## Usage
2022-09-09 12:13:35 +00:00
Upon starting Cactus Comments, a `bot.cactusbot` user account is created automatically.
2024-10-17 17:33:36 +00:00
To get started, send a `help` message to the `@bot.cactusbot:example.com` bot to confirm it's working.
2024-10-10 19:01:07 +00:00
2024-10-19 10:19:22 +00:00
Then, register a site by sending `register <YourSiteName>` (where `<YourSiteName>` is a unique identifier you choose. It does not have to match your domain). You will then be invited into a moderation room.
2024-10-10 19:01:07 +00:00
2024-10-19 10:19:22 +00:00
Now you are good to go and can embed the comment section on your website!
2022-09-09 11:37:52 +00:00
2024-10-19 10:19:22 +00:00
## Embed Cactus Comments
2022-09-09 11:37:52 +00:00
2024-10-19 10:19:22 +00:00
The official [documentation ](https://cactus.chat/docs/getting-started/quick-start/ ) provides a useful guide to embed Cactus Comments on your website.
2022-09-09 11:37:52 +00:00
2024-10-19 10:19:22 +00:00
After including the JavaScript and CSS asset files, insert a `<div>` where you'd like to display the comment section:
````html
2022-09-09 11:37:52 +00:00
< div id = "comment-section" > < / div >
2024-10-19 10:19:22 +00:00
````
Then, you need to initialize the comment section. Make sure to replace `example.com` with your base domain and `<YourSiteName>` with the one that has been registered above:
```html
2022-09-09 11:37:52 +00:00
< script >
initComments({
node: document.getElementById("comment-section"),
defaultHomeserverUrl: "https://matrix.example.com:8448",
serverName: "example.com",
2024-10-19 10:19:22 +00:00
siteName: "< YourSiteName > ",
2022-09-09 11:37:52 +00:00
commentSectionId: "1"
})
< / script >
```
2024-10-19 10:19:22 +00:00
### Adjust the domain name for self-hosting
To have the assets served from your homeserver (not from `cactus.chat` ), you need to adjust the domain name on the official documentation.
Make sure to replace `example.com` with your base domain before you include the following lines, instead of the one provided by the official documentation:
```html
< script type = "text/javascript" src = "https://matrix.example.com/cactus-comments/cactus.js" > < / script >
< link rel = "stylesheet" href = "https://matrix.example.com/cactus-comments/style.css" type = "text/css" >
```