A bulletin board website app built with haskell and scotty. video demo: https://www.youtube.com/watch?v=UCR6re3PBNk
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Gil Mizrahi 63ba17c51e update stack lts pirms 2 dienas
app Add a simple CLI management tool with a few commands pirms 11 mēnešiem
src/Web update stack lts pirms 2 dienas
.gitignore Using Sqlite and adding authentication pirms 11 mēnešiem
LICENSE update license year pirms 10 mēnešiem
bulletin-app.cabal invalidate sessions on password change pirms 10 mēnešiem
demo.png Adding example image pirms 11 mēnešiem
readme.md Enable open registration by default, add option to disable pirms 10 mēnešiem
stack.yaml update stack lts pirms 2 dienas
stack.yaml.lock update stack lts pirms 2 dienas

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.