mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-22 20:10:40 +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.
|
- POST `/api/users/:id/admin` for give admin permissions for a user.
|
||||||
|
|
||||||
- GET `/api/threads/:id` for fetch thread.
|
- 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` for create thread.
|
||||||
- POST `/api/threads/:id/delete` for delete thread.
|
- POST `/api/threads/:id/delete` for delete thread.
|
||||||
- POST `/api/threads/:id/undelete` for undelete thread.
|
- POST `/api/threads/:id/undelete` for undelete thread.
|
||||||
|
|
|
@ -25,7 +25,7 @@ app.get("/:id/", async (req, res) => {
|
||||||
const query = { threadID: id };
|
const query = { threadID: id };
|
||||||
if (!user || !user.admin) query.deleted = false;
|
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 => {
|
.then(messages => messages.map(message => {
|
||||||
message.content = message.content.replaceAll("&", "&")
|
message.content = message.content.replaceAll("&", "&")
|
||||||
.replaceAll("<", "<").replaceAll(">", ">")
|
.replaceAll("<", "<").replaceAll(">", ">")
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<% if (!message.deleted){ %>
|
<% if (!message.deleted){ %>
|
||||||
<a onclick="delete_message('<%=message.id %>');">Delete</a>
|
<a onclick="delete_message('<%=message.id %>');">Delete</a>
|
||||||
<a onclick="edit_message('<%=message.id %>');">Edit</a>
|
<a onclick="edit_message('<%=message.id %>');">Edit</a>
|
||||||
<% }else if (user.admin){ %>
|
<% }else { %>
|
||||||
<a onclick="undelete_message('<%=message.id %>');">Undelete</a>
|
<a onclick="undelete_message('<%=message.id %>');">Undelete</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -93,12 +93,10 @@
|
||||||
<textarea rows="4" cols="100" name="content"></textarea>
|
<textarea rows="4" cols="100" name="content"></textarea>
|
||||||
<input name="threadID" type="hidden" value="<%= thread.id %>"></input>
|
<input name="threadID" type="hidden" value="<%= thread.id %>"></input>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<% if (user){ %>
|
<% if (user){ %>
|
||||||
<button class="btn-primary">Send!</button>
|
<button class="btn-primary">Send!</button>
|
||||||
<%} else {%>
|
<%} 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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,9 +109,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="numbers">
|
<div class="numbers">
|
||||||
<% for(let i=0;i <= Math.ceil(messages.length/10) ;i++){ %>
|
<a class="number" href="<%= thread.getLink() %>?page=<%= page %>"><%= page+1 %></a>
|
||||||
<a class="number <%= i==page?'active':'' %>" href="<%= thread.getLink() %>?page=<%= i %>"><%= i+1 %></a>
|
|
||||||
<% } %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="after">
|
<div class="after">
|
||||||
|
|
Loading…
Reference in a new issue