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.
bantflags/README.org

84 lines
3.2 KiB

* BantFlags
A user script and backend enabling user created flags on [[https://boards.4chan.org/bant][/bant/]],
originally based on [[https://github.com/flaghunters/Extra-Flags-for-4chan][extraflags]].
[[https://flags.plum.moe/bantflags.user.js][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~.
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. I haven't tested the
example nginx config.
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
*** Dependancies
- hunchentoot
- [[https://github.com/C-xC-c/hunchenhelpers][hunchenhelpers]], my hunchentoot helper library
- 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. Type the following into your repl:
#+BEGIN_SRC lisp
(ql:quickload :bantflags)
(bantflags:main)
#+END_SRC
You will almost certainly have several issues building clsql, the
database connector used. I've [[https://plum.moe/words/bludgeoning-clsql-and-mariadb.html][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*
| id | post_nr | board |
| 1 | 12345 | bant |
| 2 | 56789 | bant |
*flags*
| id | flag |
| 1 | patchouli |
| 2 | chen |
*postflags*
| id | post_nr | flag |
| 1 | 1 | 1 |
| 2 | 1 | 2 |
| 2 | 2 | 2 |
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
| route | purpse |
|------------+--------------------------------------------|
| /api/get | Get flags using post numbers in the thread |
| /api/post | Add flags to the database |
| /api/flags | List 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.