A bulletin board website app built with haskell and scotty. video demo: https://www.youtube.com/watch?v=UCR6re3PBNk
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
Gil Mizrahi 63ba17c51e update stack lts 2 dagar sedan
app Add a simple CLI management tool with a few commands 11 månader sedan
src/Web update stack lts 2 dagar sedan
.gitignore Using Sqlite and adding authentication 11 månader sedan
LICENSE update license year 10 månader sedan
bulletin-app.cabal invalidate sessions on password change 10 månader sedan
demo.png Adding example image 11 månader sedan
readme.md Enable open registration by default, add option to disable 10 månader sedan
stack.yaml update stack lts 2 dagar sedan
stack.yaml.lock update stack lts 2 dagar sedan

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.