notflan / bantflags

Userscript and server for user-created flags on /bant/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BantFlags

A user script and backend enabling user created flags on /bant/, originally based on extraflags.

Install bantflags

Userscript

The userscript uses of GM_xmlhttpRequest to get and post flags with the backend . A user’s flags are stored between pages using GM_setValue and GM_getValue, or their GreaseMonkey4 equivalents.

Old versions of GreaseMonkey will be able to recieve updates to the script through the @updateURL and @downloadURL directives, though these were depricated sometime in GreaseMonkey 3.x and updates are only checked from the location the script was downloaded from so be careful where you upload links.

On self hosting, changing back_end to your domain should be all you need to do, but don’t take this as fact.

The userscript has been designed specifically to target ECMAScript 2015 (ES6), making liberal use of arrow functions, and const/let declarations. Update your hecking browser.

Backend

Prerequisites

  • I use SBCL
  • Some mysql, I use Mariadb
  • Quicklisp

Dependancies

  • hunchentoot
  • hunchenhelpers, my hunchentoot helper library (yes I’m proud of the name)
  • clsql
  • jonathan, the JSON encoder/decoder
  • cl-ppcre

Setup

  1. clone the project
  2. Symlink src/ to your ~/quicklisp/local-projects
  3. Move src/config.example.org to src/config.org and change it to whatever your settings are.
  4. Initialise the database by doing something like mysql << env/database.sql, This will create all the tables you will need, plus an entry for the `empty flag`
  5. Type the following into your repl:
(ql:quickload :bantflags)
(bantflags:main)
  1. To use bantflags as a Systemd service, I have included an example service and an init.el file for the service to run, since Systemd will automatically kill it if you just eval bantflags:main.

You will almost certainly have several issues building clsql, the database connector used. I’ve written a blog post on some of the issues I’ve encountered personally, but there’s no guarantee it’ll work. Piece of shit.

Database

Tables look like this:

posts

idpost_nrboard
112345bant
256789bant

flags

idflag
1patchouli
2chen

postflags

idpost_nrflag
111
212
222

where post_nr and flag in postflags are the id fields in their respective tables.

API

The backend exposes three endpoints for the userscript to get and post flags. Flags themselves are hosted from flags/ which is www-root/flags/ from config.lisp on the filesystem

routepurpse
/api/getGet flags using post numbers in the thread
/api/postAdd flags to the database
/api/flagsList the flags we support
/flags/*The flag images

Notes

You will get an error like =Recursive lock attempt #<SB-THREAD:MUTEX “global-message-log-lock” owner: #<SB-THREAD:THREAD “hunchentoot-worker-127.0.0.1:54454” RUNNING {1001DED5E3}>>.= if you try and log to a file that doesn’t exist / you don’t have permissions to read/write.

About

Userscript and server for user-created flags on /bant/

License:GNU Affero General Public License v3.0


Languages

Language:JavaScript 56.8%Language:Common Lisp 43.2%