diff --git a/assets/less/mio/classes/index.less b/assets/less/mio/classes/index.less new file mode 100644 index 00000000..91f63b2a --- /dev/null +++ b/assets/less/mio/classes/index.less @@ -0,0 +1,28 @@ +.index { + display: flex; + flex-direction: row-reverse; + + &__sidebar { + width: 300px; + margin-left: 2px; + } + + &__main { + flex: 1 1 auto; + } + + &__stats { + &__emphasis { + font-weight: 700; + } + + &__link { + color: inherit; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } + } +} diff --git a/assets/less/mio/main.less b/assets/less/mio/main.less index 2b23af38..dd42f753 100644 --- a/assets/less/mio/main.less +++ b/assets/less/mio/main.less @@ -58,6 +58,8 @@ body { @import "classes/footer"; @import "classes/header"; @import "classes/profile"; +@import "classes/index"; +@import "classes/changelog"; // Settings @import "classes/settings/content"; @@ -89,6 +91,3 @@ body { // Member listing @import "classes/members/user"; @import "classes/members/users"; - -// Changelog -@import "classes/changelog"; diff --git a/public/index.php b/public/index.php index a25cd100..30c33541 100644 --- a/public/index.php +++ b/public/index.php @@ -5,6 +5,7 @@ require_once __DIR__ . '/../misuzu.php'; $config = $app->getConfig(); $tpl = $app->getTemplating(); +$db = Database::connection(); if ($config->get('Site', 'embed_linked_data', 'bool', false)) { $tpl->vars([ @@ -16,24 +17,60 @@ if ($config->get('Site', 'embed_linked_data', 'bool', false)) { ]); } -$featuredNews = Database::connection() - ->query(' - SELECT - p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, - u.`user_id`, u.`username`, - COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` - FROM `msz_news_posts` as p - LEFT JOIN `msz_users` as u - ON p.`user_id` = u.`user_id` - LEFT JOIN `msz_roles` as r - ON u.`display_role` = r.`role_id` - WHERE p.`is_featured` = true - ORDER BY p.`created_at` DESC - LIMIT 3 - ')->fetchAll(); +$featuredNews = $db->query(' + SELECT + p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, + u.`user_id`, u.`username`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` + FROM `msz_news_posts` as p + LEFT JOIN `msz_users` as u + ON p.`user_id` = u.`user_id` + LEFT JOIN `msz_roles` as r + ON u.`display_role` = r.`role_id` + WHERE p.`is_featured` = true + ORDER BY p.`created_at` DESC + LIMIT 3 +')->fetchAll(PDO::FETCH_ASSOC); + +$usersCount = (int)$db->query(' + SELECT COUNT(`user_id`) + FROM `msz_users` +')->fetchColumn(); + +$lastUser = $db->query(' + SELECT + u.`user_id`, u.`username`, u.`created_at`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` + FROM `msz_users` as u + LEFT JOIN `msz_roles` as r + ON r.`role_id` = u.`display_role` + ORDER BY u.`created_at` DESC + LIMIT 1 +')->fetch(PDO::FETCH_ASSOC); + +$featuredChangelog = $db->query(' + SELECT + c.`change_id`, c.`change_log`, + a.`action_name`, a.`action_colour`, a.`action_class`, + DATE(`change_created`) as `change_date`, + !ISNULL(c.`change_text`) as `change_has_text` + FROM `msz_changelog_changes` as c + LEFT JOIN `msz_changelog_actions` as a + ON a.`action_id` = c.`action_id` + WHERE DATE(c.`change_created`) >= ( + SELECT DATE(`change_created`) + FROM `msz_changelog_changes` + ORDER BY `change_created` DESC + LIMIT 2, 1 + ) + ORDER BY c.`change_created` DESC +')->fetchAll(PDO::FETCH_ASSOC); //var_dump(Database::connection()->query('SHOW SESSION STATUS LIKE "Questions"')->fetch()['Value']); -echo $tpl->render('home.landing', [ +echo $tpl->render('home.index', [ + 'users_count' => $usersCount, + 'last_user' => $lastUser, + 'featured_changelog' => $featuredChangelog, 'featured_news' => $featuredNews, ]); diff --git a/views/mio/changelog/macros.twig b/views/mio/changelog/macros.twig index db79381a..c8c5a166 100644 --- a/views/mio/changelog/macros.twig +++ b/views/mio/changelog/macros.twig @@ -9,7 +9,7 @@ {% if not hide_dates and last_date != change.change_date %} {% set last_date = change.change_date %} - + {{ last_date }} {% endif %} @@ -30,23 +30,25 @@
{{ change.action_name|default('Unknown') }}
- -
- {{ change.username }} -
-
+ {% if change.user_id is defined %} + +
+ {{ change.username }} +
+
+ {% endif %} + {% if has_text %}href="/changelog.php?c={{ change.change_id }}"{% endif %}> {{ change.change_log }}
diff --git a/views/mio/home/index.twig b/views/mio/home/index.twig new file mode 100644 index 00000000..c0d35a20 --- /dev/null +++ b/views/mio/home/index.twig @@ -0,0 +1,68 @@ +{% extends '@mio/home/master.twig' %} +{% from '@mio/macros.twig' import navigation %} +{% from '@mio/news/macros.twig' import news_preview %} +{% from '@mio/changelog/macros.twig' import changelog_listing %} + +{% set canonical_url = '/' %} + +{% block content %} +
+
+
+
Statistics
+
+ We have {{ users_count|number_format }} users and + the last person to join was {{ last_user.username }}, + ! +
+
+ +
+ Changelog +
+ {{ changelog_listing(featured_changelog) }} +
+
+
+ +
+ {% if app.hasActiveSession %} +
+
Welcome
+
+

You have 0 new messages because the PM system doesn't exist yet, have a nice day.

+
+
+ {% endif %} + +
+ Featured News +
+
+ {% for post in featured_news %} + {{ news_preview(post) }} + {% endfor %} +
+
+
+
+
+ + {{ navigation(mio_navigation, '/') }} + + {% if embed_linked_data is defined and embed_linked_data %} + + {% endif %} +{% endblock %} + diff --git a/views/mio/home/landing.twig b/views/mio/home/landing.twig deleted file mode 100644 index 817aa048..00000000 --- a/views/mio/home/landing.twig +++ /dev/null @@ -1,45 +0,0 @@ -{% extends '@mio/home/master.twig' %} -{% from '@mio/macros.twig' import navigation %} -{% from '@mio/news/macros.twig' import news_preview %} - -{% set canonical_url = '/' %} - -{% block content %} - {% if app.hasActiveSession %} -
-
Welcome
-
-

You have 0 new messages because the PM system doesn't exist yet, have a nice day.

-
-
- {% endif %} - -
- Featured News -
-
- {% for post in featured_news %} - {{ news_preview(post) }} - {% endfor %} -
-
-
- - {{ navigation(mio_navigation, '/') }} - - {% if embed_linked_data is defined and embed_linked_data %} - - {% endif %} -{% endblock %} - diff --git a/views/mio/news/macros.twig b/views/mio/news/macros.twig index 463c7e91..55cad5f6 100644 --- a/views/mio/news/macros.twig +++ b/views/mio/news/macros.twig @@ -1,17 +1,20 @@ {% macro news_preview(post) %}
- + {{ post.post_title }} +
{{ post.post_text|first_paragraph|raw }}

View full post

+
+
{{ post.username }}