nielssp / uncomment

Self-hosted comment system for static sites.
Mozilla Public License 2.0
2 stars 0 forks source link
comment-system comments-system rust self-hosted

Uncomment

Uncomment is a self-hosted comment system for blogs and static sites written in Rust and TypeScript.

Features

Todo

Usage

Use docker to pull the latest stable version of Uncomment for use with an SQLite database:

docker pull nielssp/uncomment:sqlite

Create a new envioronment file with at least the following settings:

UNCOMMENT_HOST=https://your-website.com,https://uncomment.your-website.com
UNCOMMENT_SECRET_KEY=<secret key used (along with a random salt) for hashing password>
UNCOMMENT_DEFAULT_ADMIN_USERNAME=admin
UNCOMMENT_DEFAULT_ADMIN_PASSWORD=<password for first login>

You can generate a random secret key with openssl rand -base64 20.

Launch the Uncomment server:

docker run --rm --name uncomment -p 8080:8080 --env-file <your-env-file> -v <path-to-db-dir>:/db nielssp/uncomment:sqlite

Add the following to your website:

<div id="comments"></div>
<script data-uncomment
    data-uncomment-target="#comments"
    src="https://uncomment.your-website.com/en-GB/embed.js"></script>

PostgreSQL

To use PostgreSQL, pull the postgres tag instead:

docker pull nielssp/uncomment:postgres

Add a connection string to the environment file:

UNCOMMENT_DATABASE=postgresql://username:password@hostname:port/dbname

When using a local PostgreSQL database it may make sense to add --network=host to the docker run command.

Reverse proxy with nginx and letsencrypt

TODO: step by step

server {
  listen 443;
  server_name uncomment.your-website.com;

  location / {
    proxy_pass http://localhost:8080;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

  ssl on;
  # Certbot managed lines here
}

Server Configuration

Uncomment is configured via environment variables, you can put these in an environment file and pass them to docker via the --env-file argument.

Client Configuration

The client is configured via data-attributes added to the script tag used for embedding comments:

<div id="comments"></div>
<script data-uncomment
    data-uncomment-target="#comments"
    data-uncomment-require-name="true"
    data-uncomment-relative-dates="true"
    src="https://uncomment.your-website.com/en-GB/embed.js"></script>

The script tag must be marked with the data-uncomment attribute. By default the host-part of the src attribute is used as the base path for all API requests to the Uncomment backend, but this can be overridden using the data-uncomment-host attribute. So if you're serving the Uncomment script from https://cdn.your-site.com/embed.js with Uncomment running on https://uncomment.your-site.com you can use the following configuration:

<script data-uncomment
    data-uncomment-host="https://uncomment.your-site.com"
    data-uncomment-target="#comments"
    src="https://cdn.your-site.com/embed.js"></script>

Building from source

First download the source either using git:

git clone https://github.com/nielssp/uncomment.git

Or by downloading an archive from https://github.com/nielssp/uncomment/releases

Client

Requirements:

To build the frontend open a terminal in the source directory and run the following commands:

npm install
npm run build

The bundled client code is placed in the dist directory.

Server

Requirements:

To build the server open a terminal in the source directory and run one of the following commands (the first compiles Uncomment with SQLite support, the second compiles Uncomment with PostgreSQL support):

cargo build --release
cargo build --release --features postgres

The executable is placed in the target/release directory. You can run it with:

./target/release/uncomment

The server expects to find the dist directory in the current working directory. See the server configuration section for a list of environment variables that can be used to configure the server.