mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-25 13:00:41 +03:00
Online users support and new messages on mainpage
This commit is contained in:
parent
922b8e5732
commit
8fe083ded0
4 changed files with 38 additions and 38 deletions
|
@ -59,7 +59,7 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn
|
||||||
- send public to common/public
|
- send public to common/public
|
||||||
- user.ejs for per theme
|
- user.ejs for per theme
|
||||||
- categori search title like thread search
|
- categori search title like thread search
|
||||||
|
- edit template
|
||||||
### front-end
|
### front-end
|
||||||
- working reset button
|
- working reset button
|
||||||
- better pagination
|
- better pagination
|
||||||
|
|
|
@ -4,13 +4,24 @@ const app = Router();
|
||||||
|
|
||||||
app.get("/", async (req, res) => {
|
app.get("/", async (req, res) => {
|
||||||
|
|
||||||
const categories = await CategoryModel.count(),
|
const [
|
||||||
users = await UserModel.count({ deleted: false }),
|
categories, users, threads, messages, newestMember, newestMessages, onlineUserCount, onlineUsers
|
||||||
threads = await ThreadModel.count({ state: "OPEN" }),
|
] = await Promise.all([
|
||||||
messages = await MessageModel.count({ deleted: false }),
|
CategoryModel.count(),
|
||||||
newestMember = await UserModel.findOne({ deleted: false }, "name").sort({ time: -1 });
|
UserModel.count({ deleted: false }),
|
||||||
|
ThreadModel.count({ state: "OPEN" }),
|
||||||
|
MessageModel.count({ deleted: false }),
|
||||||
|
UserModel.findOne({ deleted: false }, "name id").sort({ time: -1 }),
|
||||||
|
MessageModel.find({ deleted: false }).sort({ time: -1 }).limit(10),
|
||||||
|
UserModel.count({ deleted: false, lastSeen: { $gt: Date.now() - 1000 * 60 * 5 } }),
|
||||||
|
UserModel.find({ deleted: false, hideLastSeen: false, lastSeen: { $gt: Date.now() - 1000 * 60 * 5 } }, "name id")
|
||||||
|
])
|
||||||
|
|
||||||
res.reply("index", { categories, users, threads, messages, newestMember: newestMember.name });
|
|
||||||
|
res.reply("index", {
|
||||||
|
categories, users, threads, messages,
|
||||||
|
newestMember, newestMessages, onlineUserCount, onlineUsers
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,34 +22,31 @@
|
||||||
<div class="col-12 col-xl-9">
|
<div class="col-12 col-xl-9">
|
||||||
<div class="category">
|
<div class="category">
|
||||||
|
|
||||||
<h2 class="h4 text-white bg-danger mb-0 p-4 rounded-top">Forum category</h2>
|
<h2 class="h4 text-white bg-danger mb-0 p-4 rounded-top">New messages</h2>
|
||||||
<table class="table table-striped table-bordered table-responsive">
|
<table class="table table-striped table-bordered table-responsive">
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="forum-col">Forum</th>
|
<th scope="col" class="forum-col">Message</th>
|
||||||
<th scope="col">Topics</th>
|
<th scope="col">Date</th>
|
||||||
<th scope="col">Posts</th>
|
<th scope="col" class="last-post-col">Author</th>
|
||||||
<th scope="col" class="last-post-col">Last post</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="thread">
|
<% newestMessages.forEach(message => { %>
|
||||||
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h3 class="h5 mb-0"><a href="#0" class="text-uppercase">Forum name</a></h3>
|
<p class="mb-0">
|
||||||
<p class="mb-0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In laoreet pellentesque lorem sed elementum.</p>
|
<a href="<%= message.getLink() %>"> <%= message.content.slice(0, 100) %></a>
|
||||||
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>5</div>
|
<div><%= new Date(message.time).toLocaleString() %></div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>18</div>
|
<div class="avatar">by <a href="<%= message.getLink() %>"><%= message.author.name %></a><img src="<%=message.author.avatar %>"></div>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<h4 class="h6 mb-0 font-weight-bold"><a href="#0">Post name</a></h4>
|
|
||||||
<div>by <a href="#0">Author name</a></div>
|
|
||||||
<div>05 Apr 2017, 20:07</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% }) %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,22 +59,17 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h2 class="h4 card-title">Members online</h2>
|
<h2 class="h4 card-title">Members online</h2>
|
||||||
<ul class="list-unstyled mb-0">
|
<ul class="list-unstyled mb-0">
|
||||||
<li><a href="/users">You</a></li>
|
<li>
|
||||||
|
<% onlineUsers.forEach(user => { %>
|
||||||
|
<a href="/users/<%=user.id %>"><%= user.name %></a>
|
||||||
|
<% }); %>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-8">Total:</dt>
|
<dt class="col-8">Total:</dt>
|
||||||
<dd class="col-4 mb-0">-</dd>
|
<dd class="col-4 mb-0"><%= onlineUserCount %></dd>
|
||||||
</dl>
|
|
||||||
<dl class="row mb-0">
|
|
||||||
<dt class="col-8">Members:</dt>
|
|
||||||
<dd class="col-4 mb-0">-</dd>
|
|
||||||
</dl>
|
|
||||||
<dl class="row mb-0">
|
|
||||||
<dt class="col-8">Guests:</dt>
|
|
||||||
<dd class="col-4 mb-0">-</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -85,11 +77,9 @@
|
||||||
<div class="col-12 col-sm-6 col-xl-12">
|
<div class="col-12 col-sm-6 col-xl-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<h2 class="h4 card-title">Forum statistics</h2>
|
<h2 class="h4 card-title">Forum statistics</h2>
|
||||||
|
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-8">Total forums:</dt>
|
<dt class="col-8">Total categories:</dt>
|
||||||
<dd class="col-4 mb-0"><%= categories %></dd>
|
<dd class="col-4 mb-0"><%= categories %></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
|
@ -107,7 +97,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<div>Newest member:</div>
|
<div>Newest member:</div>
|
||||||
<div><a href="#0"><%= newestMember %></a></div>
|
<div><a href="/users/<% newestMember.id %>"><%= newestMember.name %></a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
</h3>
|
</h3>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div> </div>
|
|
||||||
<div class="avatar">by <a href="<%= thread.getLink() %>"><%= thread.author.name %></a><img src="<%=thread.author.avatar %>"></div>
|
<div class="avatar">by <a href="<%= thread.getLink() %>"><%= thread.author.name %></a><img src="<%=thread.author.avatar %>"></div>
|
||||||
<div><%= new Date(thread.time).toLocaleString() %></div>
|
<div><%= new Date(thread.time).toLocaleString() %></div>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue