A bunch of front page updates.
This commit is contained in:
parent
aa8bc37ef1
commit
514f7c4513
5 changed files with 201 additions and 44 deletions
|
@ -1,5 +1,6 @@
|
|||
.avatar {
|
||||
flex-shrink: 0;
|
||||
background-image: var(--avatar-url);
|
||||
background-color: var(--background-colour);
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
.chat-quote {
|
||||
display: block;
|
||||
background-color: #212121;
|
||||
border: 1px solid #808080;
|
||||
background-color: var(--accent-colour);
|
||||
border: 1px solid var(--accent-colour);
|
||||
color: #fff;
|
||||
margin: 1px;
|
||||
margin: 2px;
|
||||
|
||||
&__line {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 1px 4px;
|
||||
background-color: fade(#000, 80%);
|
||||
|
||||
&:nth-child(odd) {
|
||||
background-color: fade(#000, 60%);
|
||||
background-color: fade(#000, 90%);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,16 +43,15 @@
|
|||
&__online {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
margin: 6px;
|
||||
|
||||
&__user {
|
||||
color: var(--user-colour);
|
||||
text-decoration: none;
|
||||
font-size: 0;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background-image: var(--avatar-url);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin: 2px;
|
||||
transition: box-shadow .2s;
|
||||
|
||||
|
@ -61,4 +60,58 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__statistics {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&__statistic {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 45%;
|
||||
padding: 4px 0;
|
||||
|
||||
&__name {
|
||||
font-size: 1.3em;
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
&__value {
|
||||
font-size: 1.5em;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
}
|
||||
|
||||
&__latest {
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
|
||||
&__avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
&__content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
&__username {
|
||||
font-size: 1.5em;
|
||||
line-height: 1.4em;
|
||||
color: var(--user-colour);
|
||||
}
|
||||
|
||||
&__joined {
|
||||
font-size: .9em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,24 +12,43 @@ if (config_get_default(false, 'Site', 'embed_linked_data')) {
|
|||
|
||||
$news = news_posts_get(0, 5, null, true);
|
||||
|
||||
$statistics = cache_get('index:stats:v1', function () {
|
||||
$stats = cache_get('index:stats:v2', function () {
|
||||
return [
|
||||
'users' => (int)db_query('
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
')->fetchColumn(),
|
||||
'lastUser' => db_query('
|
||||
'users' => db_query('
|
||||
SELECT
|
||||
u.`user_id`, u.`username`, u.`user_created`,
|
||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
||||
FROM `msz_users` as u
|
||||
LEFT JOIN `msz_roles` as r
|
||||
ON r.`role_id` = u.`display_role`
|
||||
ORDER BY u.`user_id` DESC
|
||||
LIMIT 1
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_deleted` IS NULL
|
||||
) as `all`,
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_active` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
) as `online`,
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_active` >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
||||
) as `active`
|
||||
')->fetch(PDO::FETCH_ASSOC),
|
||||
'comments' => (int)db_query('
|
||||
SELECT COUNT(`comment_id`)
|
||||
FROM `msz_comments_posts`
|
||||
WHERE `comment_deleted` IS NULL
|
||||
')->fetchColumn(),
|
||||
'forum_topics' => (int)db_query('
|
||||
SELECT COUNT(`topic_id`)
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `topic_deleted` IS NULL
|
||||
')->fetchColumn(),
|
||||
'forum_posts' => (int)db_query('
|
||||
SELECT COUNT(`post_id`)
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `post_deleted` IS NULL
|
||||
')->fetchColumn(),
|
||||
];
|
||||
}, 600);
|
||||
}, 900);
|
||||
|
||||
$changelog = cache_get('index:changelog:v1', function () {
|
||||
return db_query('
|
||||
|
@ -46,21 +65,37 @@ $changelog = cache_get('index:changelog:v1', function () {
|
|||
')->fetchAll(PDO::FETCH_ASSOC);
|
||||
}, 300);
|
||||
|
||||
$onlineUsers = db_query('
|
||||
SELECT
|
||||
u.`user_id`, u.`username`,
|
||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
||||
FROM `msz_users` as u
|
||||
LEFT JOIN `msz_roles` as r
|
||||
ON r.`role_id` = u.`display_role`
|
||||
WHERE u.`user_active` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
ORDER BY RAND()
|
||||
LIMIT 104
|
||||
')->fetchAll(PDO::FETCH_ASSOC);
|
||||
$latestUser = cache_get('index:latest_user:v1', function () {
|
||||
return db_query('
|
||||
SELECT
|
||||
u.`user_id`, u.`username`, u.`user_created`,
|
||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
||||
FROM `msz_users` as u
|
||||
LEFT JOIN `msz_roles` as r
|
||||
ON r.`role_id` = u.`display_role`
|
||||
WHERE `user_deleted` IS NULL
|
||||
ORDER BY u.`user_id` DESC
|
||||
LIMIT 1
|
||||
')->fetch(PDO::FETCH_ASSOC);
|
||||
}, 1800);
|
||||
|
||||
$onlineUsers = cache_get('index:online_users:v1', function () {
|
||||
return db_query('
|
||||
SELECT
|
||||
u.`user_id`, u.`username`,
|
||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
||||
FROM `msz_users` as u
|
||||
LEFT JOIN `msz_roles` as r
|
||||
ON r.`role_id` = u.`display_role`
|
||||
WHERE u.`user_active` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
ORDER BY RAND()
|
||||
LIMIT 104
|
||||
')->fetchAll(PDO::FETCH_ASSOC);
|
||||
}, 30);
|
||||
|
||||
echo tpl_render('home.' . (user_session_active() ? 'home' : 'landing'), [
|
||||
'users_count' => $statistics['users'],
|
||||
'last_user' => $statistics['lastUser'],
|
||||
'statistics' => $stats,
|
||||
'latest_user' => $latestUser,
|
||||
'online_users' => $onlineUsers,
|
||||
'chat_quote' => chat_quotes_random(),
|
||||
'featured_changelog' => $changelog,
|
||||
|
|
|
@ -18,20 +18,69 @@
|
|||
|
||||
<div class="container index__container">
|
||||
{{ container_title('<i class="fas fa-chart-bar fa-fw"></i> Statistics') }}
|
||||
<div class="container__content">
|
||||
{% if users_count < 1 %}
|
||||
This is a fresh installation, <a href="/auth.php?m=register" class="index__stats__emphasis index__stats__link">create an account</a>!
|
||||
{% else %}
|
||||
We have <span class="index__stats__emphasis">{{ users_count|number_format }}</span> users and
|
||||
the last person to join was <a href="/profile.php?u={{ last_user.user_id }}" class="index__stats__emphasis index__stats__link" style="{{ last_user.user_colour|html_colour }}">{{ last_user.username }}</a>,
|
||||
<time datetime="{{ last_user.user_created|date('c') }}" title="{{ last_user.user_created|date('r') }}">{{ last_user.user_created|time_diff }}</time>!
|
||||
{% endif %}
|
||||
|
||||
<div class="index__statistics">
|
||||
|
||||
<div class="index__statistic">
|
||||
<div class="index__statistic__name">
|
||||
<i class="fas fa-users fa-fw"></i> Users
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.users.all|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index__statistic">
|
||||
<div class="index__statistic__name">
|
||||
<i class="fas fa-comment-dots fa-fw"></i> Comments
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.comments|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index__statistic">
|
||||
<div class="index__statistic__name">
|
||||
<i class="fas fa-user-check fa-fw"></i> Online
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.users.online|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index__statistic">
|
||||
<div class="index__statistic__name">
|
||||
<i class="fas fa-user-clock fa-fw"></i> Active (24 hr)
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.users.active|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index__statistic">
|
||||
<div class="index__statistic__name">
|
||||
<i class="fas fa-list fa-fw"></i> Topics
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.forum_topics|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index__statistic">
|
||||
<div class="index__statistic__name">
|
||||
<i class="fas fa-comments fa-fw"></i> Posts
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.forum_posts|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if online_users|length > 0 %}
|
||||
<div class="container index__container">
|
||||
{{ container_title('<i class="fas fa-users fa-fw"></i> Online users') }}
|
||||
{{ container_title('<i class="fas fa-users fa-fw"></i> Online Users') }}
|
||||
|
||||
<div class="index__online">
|
||||
{% for user in online_users %}
|
||||
|
@ -43,6 +92,24 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if latest_user.user_id|default(0) > 0 %}
|
||||
<div class="container index__container">
|
||||
{{ container_title('<i class="fas fa-user-plus fa-fw"></i> Newest User') }}
|
||||
|
||||
<a class="index__latest" style="{{ latest_user.user_colour|html_colour }}" href="/profile.php?u={{ latest_user.user_id }}">
|
||||
<div class="avatar index__latest__avatar" style="--avatar-url: url('/profile.php?m=avatar&u={{ latest_user.user_id }}')"></div>
|
||||
<div class="index__latest__content">
|
||||
<div class="index__latest__username">
|
||||
{{ latest_user.username }}
|
||||
</div>
|
||||
<div class="index__latest__joined">
|
||||
Joined <time datetime="{{ latest_user.user_created|date('c') }}" title="{{ latest_user.user_created|date('r') }}">{{ latest_user.user_created|time_diff }}</time>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="container index__container">
|
||||
{{ container_title('<i class="fas fa-wrench fa-fw"></i> Changelog', false, '/changelog.php') }}
|
||||
<div class="changelog__content">
|
||||
|
|
Loading…
Add table
Reference in a new issue