not manx
4449477268
|
5 years ago | |
---|---|---|
BantFlags | 5 years ago | |
Docs | 5 years ago | |
Environment | 5 years ago | |
src | 5 years ago | |
.gitattributes | 5 years ago | |
.gitignore | 5 years ago | |
BantFlags.sln | 5 years ago | |
LICENSE | 5 years ago | |
README.org | 5 years ago | |
bantflags.meta.js | 5 years ago | |
bantflags.user.js | 5 years ago |
README.org
BantFlags
A user script and backend enabling user created flags on bant, originally based on extraflags.
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
- .NET Core 3.1
- MariaDB / MySQL
.NET dependancies
- Nito.AsyncEX
- Newtonsoft.Json
- MySql.Data
- Microsoft.AspNetCore.Mvc.NewtonsoftJson
- Microsoft.AspNetCore.StaticFiles
- Microsoft.AspNetCore.Razor
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Tools
- Magick.NET-Q8-AnyCPU
Setup
- Install .NET Core
- Clone and build the BantFlags solution.
-
Create the database using database.sql.
- Change the password.
-
configure
BantFlags/appsettings.example.json
with your connection string and webroot (where you'll serve the flags from without a trailing slash) and rename it toappsettings.json
- example appsettings.json
-
ASP.NET Core applications look for a folder called
wwwroot
in the same directory as the application for static files. However you can choose to logically seperate these by providing a vaild directory towebroot
.- That is to say, if the bantflags application is in
/var/www/bantflags/BantFlags.dll
, the program will look for the folder/var/www/bantflags/wwwroot/
to host static content, or whatever directory is provided towwwroot
.
- That is to say, if the bantflags application is in
-
If you're hosting on your GNU/Linux distribution of choice, Create a folder called
keys
in the same directory as the bantflags executable.-
E.G.
/var/www/bantflags/keys/
- This is because ASP.NET Core uses some cryptic bullshit anti
forgery token when processing HTML forms, and it's unable to
persistantly store the decryption keys in memory on
GNU/Linux. This directory will store said keys when you or
users upload flags to /upload. The path uses
AppDomain.CurrentDomain.BaseDirectory
internally, I.E. wherever the program is.
- This is because ASP.NET Core uses some cryptic bullshit anti
forgery token when processing HTML forms, and it's unable to
persistantly store the decryption keys in memory on
GNU/Linux. This directory will store said keys when you or
users upload flags to /upload. The path uses
-
-
Add flags to the backend by uploading them to the flag console (/Upload).
- Flags must be 16x11 pixels and under 15kb. Their names must not exceed 100 characters and cannot contain either "||" or ",".
-
Configure your webserver of choice to forward requests to kestral
-
Run with
dotnet BantFlags.dll
or create a service to run it as a daemon. - ???
- profit.
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 the flags/
directory. This
will be whatever value you gave to webroot
(or
/path/to/bantflags/wwwroot/
if no value is provided) + flags/
.
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 |
Backwards Compatibility
The API is 1:1 compatable with all previous versions of
bantflags. Further improvements are achieved by encoding a version
variable when poking endpoints which allows for breaking changes in
the script and backend while guaranteeing data can be parsed on both
ends. See Docs/{endpoint} for changes and compatibility.