Skip to content

danmenzies-jerram/schnack

 
 

Repository files navigation

schnack.js

Schnack is a simple Disqus-like drop-in commenting system written in JavaScript.

What the schnack?

Features:

  • Tiny! It takes only ~8 KB!!! to embed Schnack.
  • Open source and self-hosted.
  • Ad-free and Tracking-free. Schnack will not disturb your users.
  • It's simpy to moderate, with a minimal and slick UI to allow/reject comments or trust/block users.
  • webpush protocol to notify the site owner about new comments awaiting for moderation.
  • Third party providers for authentication like Github, Twitter, Google and Facebook. Users are not required to register a new account on your system and you don't need to manage a user management system.

Quickstart

This is the fastest way to setup schnack.

Requirements:

  • Node.js (>= v6)
  • npm (>= v5)

Clone or download schnack:

git clone https://github.com/schn4ck/schnack

Go to the schnack directory:

cd schnack

Install dependencies:

npm install

Copy and edit the config file according to configuration section:

cp config.tpl.json config.json
vim config.json                 # or open with any editor of your choice

Run the server:

npm start

Embed in your HTML page:

<div class="comments-go-here"></div>
<script src="https://comments.example.com/embed.js"
    data-schnack-slug="post-slug"
    data-schnack-target=".comments-go-here">
</script>

or initialize schnack programmatically:

<div class="comments-go-here"></div>

<script src="http://comments.example.com/client.js"></script>
<script>
    new Schnack({
        target: '.comments-go-here',
        slug: 'post-slug',
        host: 'http://comments.example.com'
    });
</script>

You will find further information on the schnack page.

Configuration

Notify Providers:

Setting up Jira

The Jira notifier adds a task to the backlog of your nominated project. This allows your team to assign a workflow to the moderation / approval process.

1: Setup the Application in Jira

  1. Log into Jira using a privileged account, then visit Atlassian Account API Token Manager
  2. Click Create API Token and enter a label
  3. When the Your new API token modal is shown, click the Copy to clipboard button
  4. Using your favourite Base64 Encoding tool, create the Base64 encoded string my-email@example.com:my-copied-atlassian-token
  5. Copy the resulting string to the notify.jira.basic_auth.base64 property

2: Assign a board to receive notifications

  1. Collect a list of the boards available by running npm run jira-boards
  2. Find the board you'd like to push notifications to, and note the projectKey
  3. Add the projectKey to the notify.jira.project_key

3: Test

  1. Send a test task to the board, by running npm run jira-test

Authentication Providers:

  • Twitter
  • GitHub
  • Google Accounts
  • Facebook
  • Mastodon
  • AWS Cognito

Setting up Cognito

Set up a user pool

  1. Log in to your Amazon AWS Account, and find the Cognito service
  2. Sign up for Cognito if you have not already
  3. Click Manage User Pools
  4. Click Create a user pool
  5. Create a pool name (can be anything you like)
  6. Click Step Through Settings and follow the wizard to set up the new user pool

Set up an authentication app

  1. From the main screen / control panel for your new user pool, click App Integration=> App client settings
  2. Check Enabled Identity Providers => Select All (making sure Cognito User Pool is also checked)
  3. Enter your Sign-in URL (http://mydomain/auth/cognito/callback)
  4. Check OAuth 2.0 => Authorization code grant
  5. Check at least Allowed OAuth Scopes => aws.cognito.signin.user.admin (others can be used, if required)
  6. Note the App client => ID, and copy to the oauth.cognito.client_id property in the config.json file

Get / create a domain prefix

  1. From the main screen / control panel for your new user pool, click App Integration=> Domain name
  2. If there isn't one already, create a new domain prefix
  3. Note the domain prefix, and copy to the oauth.cognito.domain_prefix property in the config.json file
  4. Note the region (between the auth and the amazoncognito parts of the domain, eg eu-west-1) and copy to the oauth.cognito.region property in the config.json file

Get the client secret

  1. From the main screen / control panel for your new user pool, click General settings => App clients
  2. Find the app you'd like to integrate (or create a new app client, if needed)
  3. Click the Show Details button
  4. Note the App client secret, and copy and copy to the oauth.cognito.client_secret property in the config.json file

CORS Issues

If you bump into CORS issues when attempting authentication across different ports during development, you may need to use a proxy tunnel to pipe requests from one port to another. Eg:

https://comments.localhost.lcl => https://localhost:8080 https://schnack.localhost.lcl => https://localhost:3000

This can be achieved using third party servers like Apache or Nginx, combined with Proxy Pass to forward traffic from a neutral port (like 443), to the server ports.

If you do this, you will also need to update test/index.html with the address of the proxied Schnack server.

Included SSL Certificates

The SSL Certificates included in the /certs directory are for development purposes only. These are used to make it possible to fetch data and perform authentication over SSL, on localhost. DO NOT use them in a production environment.

Who is behind Schnack?

Schnack is yet another happy collaboration between Webkid and Gregor Aisch, with a few minor additions from Jerram Digital.

Who is using Schnack?

Schnack will never track who is using it, so we don't know! If you are a Schnack user, let us know and we'll add your website here. So far Schnack is being used on:

Related projects

This is not a new idea, so there are a few projects that are doing almost the same thing:

About

🗣️ Simple self-hosted node app for Disqus-like drop-in commenting on static websites

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 90.4%
  • HTML 7.9%
  • CSS 1.4%
  • Other 0.3%