A bulletin board website app built with haskell and scotty. video demo: https://www.youtube.com/watch?v=UCR6re3PBNk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Gil Mizrahi d037678260 update to stackage lts 17 7 months ago
app Add a simple CLI management tool with a few commands 8 months ago
src/Web Enable open registration by default, add option to disable 8 months ago
.gitignore Using Sqlite and adding authentication 8 months ago
LICENSE update license year 8 months ago
bulletin-app.cabal invalidate sessions on password change 8 months ago
demo.png Adding example image 8 months ago
readme.md Enable open registration by default, add option to disable 8 months ago
stack.yaml update to stackage lts 17 7 months ago
stack.yaml.lock update to stackage lts 17 7 months ago

readme.md

Building a bulletin board using Haskell, scotty and friends

This started out as a blog post for scotty and friends but I've played with it more since and added a database (persistent-sqlite), user registration and authentication (including cookies and sessions), markdown support and a slightly nicer looking css.

Example image

Status: Feel free to play around with it.

Build

stack build

Run with

REGISTRATION='OpenRegistration' VISIBLE='Public' PORT=8080 SCOTTY_ENV='Development' CONN_STRING='file:/tmp/bullet.db' stack exec -- bulletin-app serve

where /tmp/bullet.db is the path to the database file.

Note that Development environment means the insecure flag on the cookies is set off. Using Production environment will set it on.

How to register

Right now general registration is turned off but it's possible to turn it on by uncommenting the relevant line at Web.Bulletin.Actions.MyUsers.router. Instead, we invite users to register.

When a user reaches a certain level they can start inviting other people. The leveling formula is described in the Web.Bulletin.Database.RegTokens.calcLevel function.

So once a user posts 10 times they can now invite 2 friends to register. The /invite provides the registration links.

Generate an invite CLI

If you are using REGISTRATION='InvitesOnly', users would only be able to register via a special link (which each is a single user only invite).

These links can be generated by active users that have reached higher levels, or via the CLI command.

Run the following command to generate an invite:

CONN_STRING='file:/tmp/bullet.db' stack exec -- bulletin-app generate_invites --amount 1

again, where /tmp/bullet.db is the path to the database file, and then go to the link in the browser to register.

Configuration

The following settings are available using environment variables:

  • SCOTTY_ENV: server environment, three options:
    • Development - (Default) One major thing to note here is that cookies are not flagged as secure so it can be used without TLS
    • Production - Cookies are marked as secure so can only really work with TLS.
    • Testing - Not really in use at the moment, sorry for being lazy and not writing tests.
  • CONN_STRING - (Required) sqlite3 connection string (see URI filename examples).
  • PORT
  • VISIBLE - Should the site content be available to users that are not logged in?
    • Public - (Default) yes.
    • Private - no.
  • REGISTRATION - Should registration be available to anyone?
    • OpenRegistration - (Default) yes.
    • InvitesOnly - no.

Commands

Run --help to get a list of commands.

Static executable

To compile a static executable using docker, uncomment the relevant lines in the stack.yaml file, and rebuild with stack build.

Or download one from the releases page.