From acede7d03badfad60c11ffa53066af05c9e447f5 Mon Sep 17 00:00:00 2001 From: shr3dd3r Date: Sat, 5 Aug 2023 06:26:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=B8=D0=BB=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=86=D0=B8=D0=B8:?= =?UTF-8?q?=20API=20=D0=B8=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 5 ++++- api/_db.php | 3 +++ {api => docs}/API.md | 11 +++++++---- docs/DB.md | 38 ++++++++++++++++++++++++++++++++++++++ docs/DIRS.md | 4 +++- 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 api/_db.php rename {api => docs}/API.md (73%) create mode 100644 docs/DB.md diff --git a/TODO.md b/TODO.md index 8833028..b903698 100644 --- a/TODO.md +++ b/TODO.md @@ -2,8 +2,10 @@ - Фронт - Админ-панель + - Детальная стата по инстансу - Демонстрация наполнения и управление БД - - Статистика по инстансу + - "Большая Красная Кнопка" + - Общая статистика по инстансу - Главная страница - Страница регистрации - Страница с отображением поста-картинки @@ -16,6 +18,7 @@ - Мыло - Пароль - Айди приглашения + - Роли (админ, модер, участник) и права доступа - Аватарки - Бан - Полное удаление diff --git a/api/_db.php b/api/_db.php new file mode 100644 index 0000000..15c5adc --- /dev/null +++ b/api/_db.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/api/API.md b/docs/API.md similarity index 73% rename from api/API.md rename to docs/API.md index 4a67ce0..aa24d63 100644 --- a/api/API.md +++ b/docs/API.md @@ -13,6 +13,8 @@ Files starting from "_" ("_example.php") are intended for internal use only. ## Version 1 +- _db.php: connection to database and all related +- _auth.php: things related to authentification - stats.php (GET/POST): all general statistics about this instance - admin/ (POST): private statistics about this instance @@ -30,8 +32,9 @@ Files starting from "_" ("_example.php") are intended for internal use only. - post/create.php (POST): create new post with image - post/edit.php (POST): edit tags of post - post/delete.php (POST): delete post +- post/vote.php (POST): rate the existing post -- post/comments/ (GET/POST): show all comments from post by id -- post/comments/create.php (POST): create new comment -- post/comments/edit.php (POST): edit existing comment -- post/comments/delete.php (POST): remove existing comment \ No newline at end of file +- comments/ (GET/POST): show all comments from section by id +- comments/create.php (POST): create new comment at selected section +- comments/edit.php (POST): edit existing comment +- comments/delete.php (POST): remove existing comment \ No newline at end of file diff --git a/docs/DB.md b/docs/DB.md new file mode 100644 index 0000000..911b3f0 --- /dev/null +++ b/docs/DB.md @@ -0,0 +1,38 @@ +# Databases + +## How to setup DB + +We are using MariaDB, but any MySQL-compatible database should be enough. There are instructions how to setup it for using with E949. + +```bash +mysql -u root -p +``` + +```mysql +CREATE USER e949@localhost IDENTIFIED BY 'password'; +CREATE DATABASE e949 CHARACTER SET = 'utf8'; +GRANT ALL PRIVILEGES ON e949.* TO e949@localhost; +FLUSH PRIVILEGES; +EXIT +``` + +```bash +mysql -u e949 -p +``` + +```mysql +USE e949; +CREATE TABLE posts ( + id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique identifier of post', + author_id BIGINT UNSIGNED NOT NULL COMMENT 'Identifier of post author', + comment_section_id BIGINT UNSIGNED NULL COMMENT 'Identifier of post comment section', + posted_at TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'When post was published', + tags VARCHAR(2048) NOT NULL COMMENT 'Comma-delimited list of post tags', + title VARCHAR(8192) NULL COMMENT 'Caption for the post', + votes_up INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Amount of positive reactions', + votes_down INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Amount of negative reactions', + views BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Amount of post views', + pic_path VARCHAR(256) NOT NULL COMMENT 'Path or URL of picture', + preview_path VARCHAR(256) NULL COMMENT 'Path or URL of preview version of picture' + ); +``` \ No newline at end of file diff --git a/docs/DIRS.md b/docs/DIRS.md index 6ed71ee..fe0037a 100644 --- a/docs/DIRS.md +++ b/docs/DIRS.md @@ -1,4 +1,6 @@ # Repo Directory Structure +**api**: E949 PHP API **docs**: all documentation here -**html_drafts**: peaces of html markup \ No newline at end of file + +**front**: things for frontend, like CSS \ No newline at end of file