Git Product home page Git Product logo

comment-castles's Introduction

Comment Castles

Comment Castles is an internet forum project. Users write posts, nested comments and profiles. You must follow a user in order to see their content. There is an instance running at commentcastles.org!

Other Features:

  • OAuth 2 JSON API
  • public and private groups
  • inbox for direct comments you receive
  • help page
  • light mode and dark mode

Install

Install one of the tagged releases, preferably the most recent.

Create a PostgreSQL 11 database and execute all the code in sql/structure.sql. This will create all the database tables, triggers, etc. PostgreSQL 11+ is probably fine.

Install Redis. This is only for the session store. Redis versions 2 and 6 worked for us, so most versions are probably fine.

Make sure you have Node.js installed. I am using v20.10.0 locally and the live site uses v20.12.1.

Run npm install to download all the Node.js dependencies that are listed in package.json.

Set the following environment variables:

  • PGHOST: PostgreSQL host (usually localhost)
  • PGUSER: PostgreSQL username
  • PGDATABASE: PostgreSQL database name
  • PGPASSWORD: PostgreSQL password
  • PGPORT: PostgreSQL port
  • HTTP_PORT: Port this app will use
  • REDIS_PORT: Redis port
  • IS_PROD: This is a redundant production flag (there's already the built-in NODE_ENV) that must be set. If NODE_ENV is "production" then set this flag to 1, otherwise use 0.
  • SESSION_NAME: express-session name
  • SESSION_SECRET: express-session secret
  • NODE_ENV: built-in node environment flag

On Windows you can use a .env and npm start to set the environment variables. Here's a sample .env:

PGHOST=localhost
PGUSER=postgres
PGDATABASE=mydb
PGPASSWORD=123abc
PGPORT=5432
HTTP_PORT=80
REDIS_PORT=6379
IS_PROD=1
SESSION_NAME=mysesh
SESSION_SECRET=wOgw3oQpmbYbie7V
NODE_ENV=production

On Linux we used an ecosystem.config.js and pm2 start ecosystem.config.js to set the environment variables. Here is a sample ecosystem.config.js:

module.exports = {
    apps : [{
        name: "myappid",
        script: "./app.js",
        env: {
            PGHOST: "localhost",
            PGUSER: "postgres",
            PGDATABASE: "mydb",
            PGPASSWORD: "123abc",
            PGPORT: 5432,
            HTTP_PORT: 80,
            REDIS_PORT: 6379,
            IS_PROD: 1,
            SESSION_NAME: "mysesh",
            SESSION_SECRET: "wOgw3oQpmbYbie7V",
            NODE_ENV: "production",
        }
    }]
}

There must exist a row in the tuser database table that has a user_id set to 1. This user_id serves as the default following list. So after an instance of this application is launched, you should immediately sign up as this admin user. If you want to use a user_id other than 1, then you can change it in src/config/index.js via adminUserId.

On the API page, a post ID and comment ID are used in URLs on the page. If you want these links to work, you must create a post and comment and then set their IDs to match the ones used on the page.

Update

When you deploy new commits to your instance of this app that is already running, make sure to also execute any new commands that are in sql/migrations.sql.

If you deployed your instance before commit 46d52bff7765b250317ee297d570800447cb4afa, then you need to run scripts/gen-user-public-ids.js in order to generate public IDs for users that are already in the database.

If you deployed your instance before commit c88bb90499aa616cd4f1d2b777d21e9a90d470c4, then you need to run scripts/populate-domain-names.js.

If you deployed your instance before commit 90b98831eeb5785391b371cf46712f1a0b4a0e47, then you need to run scripts/set-last-comment-times.js.

comment-castles's People

Contributors

ferg1e avatar omgimalexis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

comment-castles's Issues

Add i18n

Could be nice to have i18n and choose the language interface I want in the settings.
I can't help with the code, but I can help translate into french and a little bit with Italian

More comment sorting options

Comments are sorted chronologically, there is no other option. I think we achieve this by simply sorting on the ltree path value - so the structure of the ltree path values may affect how we can sort comments.

Search

Search form to search through post and comment content/text. Not sure if it's worth it to implement search, but it might be fun to explore.

Split up source code into smaller files

All the website routes are in routes/active.js and all the SQL queries are in db/index.js. These two files should be split up into smaller files - possibly grouping things into files (as opposed to using a single file for each function).

Archive links

Have a side bar with archive links, in case some posts an paywalled article. Like what lobste.rs does.

It should be a dropdown menu with the big archive sites, since there seems to be a war between the various archiving sites over which is better.

Use SQL transactions

There are a couple spots in the code that should be wrapped in an SQL transaction. For example, when someone edits a post the post data changes, groups are deleted and groups are added again.

Use user public id for "eyes" instead of username

"eyes" refers to another user that the current user is using as their whitelist. When logged out this "eyes" value is a username. Instead of using the username we should use the user public id.

Add something that is fun

My main idea is some sort of avatar dress up system. But it could be anything. We need something fun to attract attention. But be careful not to spend tons of time on something pointless.

PM/DM system

Possibly allow users to send private messages to each other.

TODOs in code

There are a handful of to do items in the source code marked with comments. Just search the source code for "TODO".

Remove hardcoded 'stink' username and '1' user_id from source code

I think 'stink' appears once at the top of the website/active router. And I believe the 1 user_id appears 3 or 4 times in the API router. These hardcoded values currently server as the default whitelist (it is assumed that is_eyes is true for this account). We may need to put these defaults in the config, or maybe we use the lowest user_id that has is_eyes equal to true.

A follow attempt by a logged out user should complete upon log in

If you're logged out and try to follow a user, then you're simply redirected to the sign up form and the followee user is forgotten. The followee user's public_id should flow through to the end of the login process so that once the user logs in they will auto follow the intended user or be given the option to follow the intended user.

Change site colors

Ability for user to change the text and background colors of the site via a basic web form. Possibly save them for other people to use.

Remove comment_mode

Remove comment_mode in the tuser database table and also from source code. There used to be separate view_mode settings for posts and comments. But now there's a single view_mode setting for both (both are using post_mode under the hood). May want to also rename post_mode to view_mode in source code and the database.

Option to hide username for individual posts and comments

It might be good to allow users to hide their username for a single post or comment. In terms of the whitelist, I guess you'd hide/show all these anons (ie. from all users) at once via a single "user" (maybe a special "anon" user).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.