mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-12-22 23:59:08 +03:00
fix for pages
This commit is contained in:
parent
0ee3d3be8b
commit
75c36abd75
3 changed files with 7 additions and 11 deletions
|
@ -22,7 +22,7 @@ But in front end, the API will works with session.
|
|||
- POST `/api/users/:id/admin` for give admin permissions for a user.
|
||||
|
||||
- GET `/api/threads/:id` for fetch thread.
|
||||
- GET `/api/threads/:id/messages/:limit` for fetch messages in thread.
|
||||
- GET `/api/threads/:id/messages/` for fetch messages in thread.
|
||||
- POST `/api/threads` for create thread.
|
||||
- POST `/api/threads/:id/delete` for delete thread.
|
||||
- POST `/api/threads/:id/undelete` for undelete thread.
|
||||
|
|
|
@ -22,10 +22,10 @@ app.get("/:id/", async (req, res) => {
|
|||
const thread = await ThreadModel.get(id)
|
||||
if (thread && (user?.admin || !thread.deleted)) {
|
||||
thread.views++;
|
||||
const query = { threadID: id };
|
||||
const query = { threadID: id };
|
||||
if (!user || !user.admin) query.deleted = false;
|
||||
|
||||
const messages = await MessageModel.find(query).sort({ time: 1 }).skip(page * 10).limit(page * 10 + 10)
|
||||
const messages = await MessageModel.find(query).sort({ time: 1 }).limit(10).skip(page * 10)
|
||||
.then(messages => messages.map(message => {
|
||||
message.content = message.content.replaceAll("&", "&")
|
||||
.replaceAll("<", "<").replaceAll(">", ">")
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<% if (!message.deleted){ %>
|
||||
<a onclick="delete_message('<%=message.id %>');">Delete</a>
|
||||
<a onclick="edit_message('<%=message.id %>');">Edit</a>
|
||||
<% }else if (user.admin){ %>
|
||||
<% }else { %>
|
||||
<a onclick="undelete_message('<%=message.id %>');">Undelete</a>
|
||||
<% } %>
|
||||
</div>
|
||||
|
@ -92,13 +92,11 @@
|
|||
<form id="send">
|
||||
<textarea rows="4" cols="100" name="content"></textarea>
|
||||
<input name="threadID" type="hidden" value="<%= thread.id %>"></input>
|
||||
|
||||
|
||||
|
||||
<% if (user){ %>
|
||||
<button class="btn-primary">Send!</button>
|
||||
<button class="btn-primary">Send!</button>
|
||||
<%} else {%>
|
||||
<a class="btn-outline-primary" href="/login?redirect=<%= thread.getLink() %>">Login for send</a>
|
||||
<a class="btn-outline-primary" href="/login?redirect=<%= thread.getLink() %>">Login for send</a>
|
||||
<% }%>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -111,9 +109,7 @@
|
|||
|
||||
|
||||
<div class="numbers">
|
||||
<% for(let i=0;i <= Math.ceil(messages.length/10) ;i++){ %>
|
||||
<a class="number <%= i==page?'active':'' %>" href="<%= thread.getLink() %>?page=<%= i %>"><%= i+1 %></a>
|
||||
<% } %>
|
||||
<a class="number" href="<%= thread.getLink() %>?page=<%= page %>"><%= page+1 %></a>
|
||||
</div>
|
||||
|
||||
<div class="after">
|
||||
|
|
Loading…
Reference in a new issue