diff --git a/APIDOCS.md b/APIDOCS.md index 7b69e8a..9ecb3b7 100644 --- a/APIDOCS.md +++ b/APIDOCS.md @@ -28,7 +28,6 @@ But in front end, the API will works with session. - GET `/api/users/:id` for fetch user. - DELETE `/api/users/:id/` for delete user. - PATCH `/api/users/:id/` for edit user. -- POST `/api/users/:id/undelete` for undelete user. - GET `/api/threads/:id` for fetch thread. - DELETE `/api/threads/:id/` for delete thread. diff --git a/README.md b/README.md index db6c729..ab76a01 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Run `node util/reset` to **reset the database**, and run `node util/admin` for g Edit `config.json` for default themes of users... ## API -Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn about API in `util/APIDOCS.md`. +Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn about API in `APIDOCS.md`. ## Credits * [Akif9748](https://github.com/Akif9748) - Project mainteiner, main developer, made **old** frontend @@ -34,15 +34,15 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn ## TO-DO list | To do | Is done? | Priority | | ----- | -------- | -------- | -| Search & message a | 🟡 | MEDIUM | -| Footer | 🟡 | LOW | +| Page support for search | 🟡 | LOW | +| Footer | 🟢 | LOW | | Local pfp store | 🔴 | MEDIUM | | IPs of users will add SecretModel | 🔴 | MEDIUM | -| better theme patch UserModel | 🟡 | VERY LOW | | Category | ⚪ | MEDIUM | | Profile Message | 🔴 | LOW | +| Last seen, last seen info | 🔴 | LOW | | Better Auth | 🔴 | MEDIUM | - +- Add theme selection to footer, and, and, and fix footer, add navbar css to footer and import common css in meta ## Major Version History - V4: Caching - V3: New Theme diff --git a/index.js b/index.js index e32f96a..97103a5 100644 --- a/index.js +++ b/index.js @@ -7,11 +7,24 @@ const { UserModel, BanModel } = require("./models"), port = process.env.PORT || 3000, mongoose = require("mongoose"), express = require('express'), + // multer = require("multer"), fs = require("fs"), app = express(); app.ips = []; - +//Upload file +/* +const storage = multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, "public/data"); + }, + filename: function (req, file, cb) { + const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9); + cb(null, file.fieldname + "-" + uniqueSuffix + ".png"); + }, +}); +const upload = multer({ storage: storage }); +app.post("/stats", upload.single("uploaded_file"),*/ require("dotenv").config(); mongoose.connect(process.env.MONGO_DB_URL, async () => console.log("Database is connected with", (app.ips = await BanModel.find({})).length, "banned IPs")); diff --git a/public/css/navbar.css b/public/css/common.css similarity index 100% rename from public/css/navbar.css rename to public/css/common.css diff --git a/public/css/modal.css b/public/css/modal.css index 79aee1b..ad2060b 100644 --- a/public/css/modal.css +++ b/public/css/modal.css @@ -1,48 +1,75 @@ -/* MODAL */ -.modal{ - position:fixed; - left:0; - top:0; - width:100%; - height:100%; - background:red; - background: #5b5b5bde; - + +form { + display: flex; + align-items: center; + flex-direction: column; + max-width: 500px; + margin: 0 auto; + width: 100%; + padding: 8px; } -.modal-content{ - position:absolute; - top:50%; - left:50%; - transform: translate(-50%,-50%); + +.input { + padding: 8px 10px; + font-family: inherit; + display: block; + font-weight: 600; + color: var(--input-clr); + width: 100%; + margin-bottom: 10px; + border: 2px solid var(--borders); +} + +/* MODAL */ +.modal { + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + background: #5b5b5bde; + +} + +.modal-content { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); background: white; padding: 10px; - opacity: 0; - display: block; - animation: fadeIn 1s forwards; + opacity: 0; + display: block; + animation: fadeIn 1s forwards; } -.modal.no-active{ -display:none; +.modal.no-active { + display: none; } -.modal-close{ +.modal-close { position: absolute; -top: 0; -right: 10px; -font-size: 36px; -color: var(--main); -cursor: pointer; + top: 0; + right: 10px; + font-size: 36px; + color: var(--main); + cursor: pointer; } @keyframes fadeIn { - from { opacity: 0; } - to { opacity: 1;} -} + from { + opacity: 0; + } -@media(max-width:760px){ - .modal-content{ - width:95%; + to { + opacity: 1; } } + +@media(max-width:760px) { + .modal-content { + width: 95%; + } +} \ No newline at end of file diff --git a/public/modal.js b/public/modal.js deleted file mode 100644 index 00b1313..0000000 --- a/public/modal.js +++ /dev/null @@ -1,19 +0,0 @@ -var modal_open = document.querySelectorAll("[data-modal-open]"); -modal_open.forEach(onclick_load) - -function onclick_load(item, index) { - var block = item.getAttribute("data-modal-open"); - console.log("evet"); - console.log(item) - document.querySelector(block).classList.toggle("no-active"); - document.querySelector("#user-edit").querySelector(".modal-close").onclick = function() { - document.querySelector(block).classList.toggle("no-active"); - } - - item.onclick = function() { - document.querySelector(block).classList.toggle("no-active"); - }; - - - -} diff --git a/routes/api/routes/users.js b/routes/api/routes/users.js index 724b69e..b82ff80 100644 --- a/routes/api/routes/users.js +++ b/routes/api/routes/users.js @@ -55,9 +55,9 @@ app.patch("/:id/", async (req, res) => { if (req.user.id !== member.id && !user.admin) return res.error(403, "You have not got permission for this."); if (!Object.values(req.body).some(Boolean)) return res.error(400, "Missing member informations in request body."); - const { avatar, name, about, theme, admin } = req.body; + const { avatar, name, about, theme, admin, deleted } = req.body; - if (admin?.length && !req.user.admin) return res.error(403, "You have not got permission for edit 'admin' information, or bad request."); + if ((admin?.length || "deleted" in req.body) && !req.user.admin) return res.error(403, "You have not got permission for edit 'admin' and 'deleted' information, or bad request."); if (avatar && URLRegex.test(avatar)) member.avatar = avatar; @@ -68,10 +68,10 @@ app.patch("/:id/", async (req, res) => { } if (about) member.about = about; - if (theme) - member.theme = member.theme === "default" ? "black" : "default"; + if (theme || ["default", "black"].includes(theme)) member.theme = theme; if (typeof admin === "boolean" || ["false", "true"].includes(admin)) member.admin = admin; + if (deleted === false) member.deleted = false; member.edited = true; await member.save(); diff --git a/views/edit_user.ejs b/views/edit_user.ejs index 3398bce..9ea25d8 100644 --- a/views/edit_user.ejs +++ b/views/edit_user.ejs @@ -40,7 +40,7 @@ const object = {}; new FormData(e.target).forEach((value, key) => object[key] = value); - console.log(object) + const res = await request("/api/users/<%=member.id%>", "PATCH", object); if (res) alert(`User is updated!`); location.reload(); diff --git a/views/extra/footer.ejs b/views/extra/footer.ejs index da6e7b6..869649a 100644 --- a/views/extra/footer.ejs +++ b/views/extra/footer.ejs @@ -1,17 +1,21 @@ + \ No newline at end of file diff --git a/views/extra/meta.ejs b/views/extra/meta.ejs index 66aaa87..14d9a85 100644 --- a/views/extra/meta.ejs +++ b/views/extra/meta.ejs @@ -6,8 +6,9 @@ - <% if (theme === "black") { %> - - <% } %> + + <% if (theme === "black") { %> + + <% } %> \ No newline at end of file diff --git a/views/extra/navbar.ejs b/views/extra/navbar.ejs index 268cea3..43e7c7c 100644 --- a/views/extra/navbar.ejs +++ b/views/extra/navbar.ejs @@ -1,4 +1,3 @@ - <% if (user?.admin){ %>
@@ -23,13 +22,11 @@ async function invert() { await fetch('/api/users/<%= user.id %>', { method: 'PATCH', - body: JSON.stringify({ - theme: "<%=user.theme === `default` ? `black` : `default` %>" - }), + body: JSON.stringify({ theme: "<%=user.theme === `default` ? `black` : `default` %>" }), headers: { "Content-Type": "application/json" } - }) + }); location.reload() } diff --git a/views/user.ejs b/views/user.ejs index d73251f..1e75c73 100644 --- a/views/user.ejs +++ b/views/user.ejs @@ -6,46 +6,74 @@ - - - - - <%if (user) {%> - - <% }; %> + <%- include("extra/navbar") %> - - -
<% if (user?.admin || user?.id === member.id) { %> - Edit user! + + + Edit user! + + + + <% } %> <% if (member.deleted) {%> @@ -53,15 +81,18 @@ data-modal-open="#deneme" bu elemente tıklanıldığında Undelete user! <% } else if (user?.admin){ %> Delete user! - <% }; %> + <% } %>
-

Admin

-
Admin + <% } %> + +
<%= member.about %>
- +

Name:

<%= member.name %>

- -

Created at:

<%= new Date(member.time).toLocaleString() %>

-

Message:

<%= counts.message %>

@@ -93,40 +121,8 @@ color: black;">

Thread:

<%= counts.thread %>

- - - - - - -
- - - - - +<%- include("extra/footer") %> - + \ No newline at end of file