- Delete docs because they're outdated - Move Environment to env - Update server so it can be ran independently of the (main) functionご主人様
parent
65d43fd73d
commit
a479b49b3f
@ -1,4 +0,0 @@
|
|||||||
* /api/flags
|
|
||||||
returns a plaintext list of all the resolved flags, seperated by
|
|
||||||
newline characters (\n). This is maintained by the database service
|
|
||||||
and updated whenever changes are committed to the flag console.
|
|
@ -1,70 +0,0 @@
|
|||||||
* /api/get
|
|
||||||
** Recieved Data
|
|
||||||
All versions of the script send a comma seperated list of post
|
|
||||||
numbers, =post_nrs= and a board =board=. Modern versions of bantflags
|
|
||||||
also send a version number, =version=, which decides how the returned
|
|
||||||
data will be formatted.
|
|
||||||
|
|
||||||
Data looks like this:
|
|
||||||
#+BEGIN_SRC http
|
|
||||||
POST https://flags.plum.moe/api/get
|
|
||||||
Content-Type: application/x-www-form-urlencoded
|
|
||||||
|
|
||||||
post_nrs=12345,12346,14444&board=bant&version=1
|
|
||||||
#+END_SRC
|
|
||||||
** Sent Data
|
|
||||||
*** GetPosts
|
|
||||||
Returns an =IEnumerable<IGrouping<int, DataRow>>= of post numbers and
|
|
||||||
their flags where the post numbers are contained in
|
|
||||||
=post_nrs=. =board= limits the query to only the board we're currently
|
|
||||||
on.
|
|
||||||
*** GetPosts_V1
|
|
||||||
Minimum script version: 0
|
|
||||||
|
|
||||||
Flags are converted from an =IEnumerable<IGrouping<int, DataRow>>= to
|
|
||||||
a =List<Dictionary<string, string>>= by joining the values in the
|
|
||||||
=DataRow= by "||", which are then split and converted into an array by
|
|
||||||
the script.
|
|
||||||
|
|
||||||
We're doing a needless conversion at both ends which slows the whole
|
|
||||||
process down, but it's how extraflags is set up and we need to support
|
|
||||||
it.
|
|
||||||
|
|
||||||
Data looks like this:
|
|
||||||
#+BEGIN_SRC javascript
|
|
||||||
[
|
|
||||||
{
|
|
||||||
{"post_nr": "123"},
|
|
||||||
{"regions": "flag1||flag2||flag3"}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{"post_nr": "456"},
|
|
||||||
{"regions": "flag4||flag3||flag3"}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** getPosts_V2
|
|
||||||
Minimum script version: 2
|
|
||||||
|
|
||||||
Flags are converted from an =IEnumerable<IGrouping<int, DataRow>>= to
|
|
||||||
a =Dictionary<int, IEnumerable<string>>= which can then be parsed by
|
|
||||||
the script without any conversion. This format is the same as returned
|
|
||||||
from the database query, sans the extra information returned by a
|
|
||||||
=DataRow=
|
|
||||||
|
|
||||||
Data looks like this:
|
|
||||||
#+BEGIN_SRC javascript
|
|
||||||
[
|
|
||||||
123: [
|
|
||||||
"flag1",
|
|
||||||
"flag2",
|
|
||||||
"flag3"
|
|
||||||
],
|
|
||||||
456: [
|
|
||||||
"flag4",
|
|
||||||
"flag3",
|
|
||||||
"flag3"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
#+END_SRC
|
|
@ -1,18 +0,0 @@
|
|||||||
* /api/post
|
|
||||||
** Recieved Data
|
|
||||||
Data is sent from the script to the backend after a post has been
|
|
||||||
made, containing the post number, =post_nr=, =board= identifier, and
|
|
||||||
selected flags, =regions=. Modern versions of the script also encode a
|
|
||||||
=version= which is used when splitting =regions= into individual flags
|
|
||||||
|
|
||||||
Data looks like this:
|
|
||||||
#+BEGIN_SRC http :pretty
|
|
||||||
POST https://flags/plum.moe/api/post
|
|
||||||
Content-Type: application/x-www-form-urlencoded
|
|
||||||
|
|
||||||
post_nr=12345&board=bant®ions=Patchouli,dount,VIP&version=1
|
|
||||||
#+END_SRC
|
|
||||||
** Sent Data
|
|
||||||
The backend returns either a JSON object of the post, as it would be
|
|
||||||
returned by =/api/get=, or an error message specific to the issue if
|
|
||||||
the form data is invalid.
|
|
@ -1,15 +0,0 @@
|
|||||||
* /Upload
|
|
||||||
The flag console is the preferred way for adding and modifying flags
|
|
||||||
in the database. It provides controls for adding, deleting and
|
|
||||||
renaming flags, all of which are visible before being committed by
|
|
||||||
someone with with password, which is set using the =staging-password=
|
|
||||||
section in =appsettings.json=. Changes may be unstaged on an
|
|
||||||
individual basis, but committed changes must be done all at once.
|
|
||||||
|
|
||||||
Flags have several hard-coded requirements for being uploaded using
|
|
||||||
the console. The image must be 16 by 11 pixels in size, be a PNG file
|
|
||||||
and have a valid PNG header. Names of files must be under 100
|
|
||||||
characters in length, and not contain either "," or
|
|
||||||
"||". Additionally, you cannot name a flag "Empty, or there were
|
|
||||||
errors. Please re-set your flags." as this is used, well, when someone
|
|
||||||
hasn't set their flags right.
|
|
@ -1,16 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=bantflags serb
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
# Set to the location of the application
|
|
||||||
WorkingDirectory=/var/www/bantflags/src/
|
|
||||||
ExecStart=/usr/bin/env sbcl --eval '(progn (push #p"/var/www/bantflags/src" ql:*local-project-directories*) (ql:quickload :bantflags) (main))'
|
|
||||||
Restart=always
|
|
||||||
# restarts 10 seconds after it goes bang
|
|
||||||
RestartSec=10
|
|
||||||
KillSignal=SIGINT
|
|
||||||
SyslogIdentifier=bantflags
|
|
||||||
User=nginx
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,102 +0,0 @@
|
|||||||
DROP DATABASE IF EXISTS `bantflags`;
|
|
||||||
CREATE DATABASE `bantflags`;
|
|
||||||
|
|
||||||
USE `bantflags`;
|
|
||||||
|
|
||||||
CREATE USER IF NOT EXISTS flags@localhost IDENTIFIED BY 'default';
|
|
||||||
GRANT ALL PRIVILEGES ON bantflags.* TO flags@localhost;
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
|
|
||||||
CREATE TABLE `flags` (
|
|
||||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
|
||||||
`flag` varchar(100) NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `flag` (`flag`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
|
|
||||||
|
|
||||||
CREATE TABLE `posts` (
|
|
||||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_nr` int(10) NOT NULL DEFAULT '0',
|
|
||||||
`board` varchar(10) NOT NULL DEFAULT 'bant',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `post_nr_board` (`post_nr`,`board`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
|
|
||||||
|
|
||||||
CREATE TABLE `postflags` (
|
|
||||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
|
||||||
`post_nr` int(10) NOT NULL DEFAULT '0',
|
|
||||||
`flag` int(10) NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `flag` (`flag`),
|
|
||||||
KEY `post_nr` (`post_nr`),
|
|
||||||
CONSTRAINT `flag` FOREIGN KEY (`flag`) REFERENCES `flags` (`id`) ON DELETE CASCADE,
|
|
||||||
CONSTRAINT `post_nr` FOREIGN KEY (`post_nr`) REFERENCES `posts` (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
|
|
||||||
|
|
||||||
DELIMITER $$
|
|
||||||
CREATE DEFINER=`flags`@`localhost` PROCEDURE `insert_post`(
|
|
||||||
IN `@post_nr` INT,
|
|
||||||
IN `@board` VARCHAR(5)
|
|
||||||
)
|
|
||||||
LANGUAGE SQL
|
|
||||||
NOT DETERMINISTIC
|
|
||||||
CONTAINS SQL
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
BEGIN
|
|
||||||
INSERT IGNORE INTO `posts` (`post_nr`, `board`) VALUES (`@post_nr`, `@board`);
|
|
||||||
END
|
|
||||||
$$
|
|
||||||
|
|
||||||
CREATE DEFINER=`flags`@`localhost` PROCEDURE `insert_post_flags`(
|
|
||||||
IN `@post_nr` INT,
|
|
||||||
IN `@flag` VARCHAR(100)
|
|
||||||
)
|
|
||||||
LANGUAGE SQL
|
|
||||||
NOT DETERMINISTIC
|
|
||||||
CONTAINS SQL
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
BEGIN
|
|
||||||
insert into postflags (post_nr, flag) VALUES (
|
|
||||||
(select id from posts where post_nr = `@post_nr`),
|
|
||||||
(select id from flags where flag = `@flag`)
|
|
||||||
);
|
|
||||||
END
|
|
||||||
$$
|
|
||||||
|
|
||||||
CREATE DEFINER=`flags`@`localhost` PROCEDURE `rename_flag`(
|
|
||||||
IN `@old` VARCHAR(100),
|
|
||||||
IN `@new` VARCHAR(100)
|
|
||||||
)
|
|
||||||
LANGUAGE SQL
|
|
||||||
NOT DETERMINISTIC
|
|
||||||
CONTAINS SQL
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
BEGIN
|
|
||||||
UPDATE flags SET flags.flag = `@new` WHERE flags.flag = `@old`;
|
|
||||||
END
|
|
||||||
$$
|
|
||||||
|
|
||||||
CREATE DEFINER=`flags`@`localhost` PROCEDURE `delete_flag`(
|
|
||||||
IN `@flag` VARCHAR(100)
|
|
||||||
)
|
|
||||||
LANGUAGE SQL
|
|
||||||
NOT DETERMINISTIC
|
|
||||||
CONTAINS SQL
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
BEGIN
|
|
||||||
DELETE flags.* FROM flags WHERE flags.flag = `@flag`;
|
|
||||||
END
|
|
||||||
$$
|
|
||||||
|
|
||||||
CREATE DEFINER=`flags`@`localhost` PROCEDURE `insert_flag`(
|
|
||||||
IN `@flag` VARCHAR(100)
|
|
||||||
)
|
|
||||||
LANGUAGE SQL
|
|
||||||
NOT DETERMINISTIC
|
|
||||||
CONTAINS SQL
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO `flags` (`flag`) VALUES (`@flag`);
|
|
||||||
END
|
|
||||||
$$
|
|
||||||
DELIMITER ;
|
|
@ -1,36 +0,0 @@
|
|||||||
events {
|
|
||||||
worker_connections 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
types {
|
|
||||||
text/html html htm shtm;
|
|
||||||
text/css css;
|
|
||||||
image/gif gif;
|
|
||||||
image/jpeg jpg jpeg;
|
|
||||||
image/png png;
|
|
||||||
}
|
|
||||||
|
|
||||||
default_type application/octet-stream;
|
|
||||||
sendfile on;
|
|
||||||
tcp_nopush on;
|
|
||||||
charset utf-8;
|
|
||||||
index index.htm index.html;
|
|
||||||
|
|
||||||
server {
|
|
||||||
root /var/www/flags;
|
|
||||||
server_name flags.plum.moe;
|
|
||||||
listen 80;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://127.0.0.1:5000;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection $http_connection;
|
|
||||||
proxy_cache_bypass $http_upgrade;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue