diff --git a/assets/less/mio/classes/forum/topics.less b/assets/less/mio/classes/forum/topics.less index 3ba42a1a..4354b657 100644 --- a/assets/less/mio/classes/forum/topics.less +++ b/assets/less/mio/classes/forum/topics.less @@ -1,6 +1,6 @@ .forum__topics { &__listing { - margin: 2px; + margin: 1px; } &__none { @@ -10,6 +10,7 @@ &__entry { display: flex; align-items: stretch; + min-height: 40px; &:not(:first-child) { margin-top: 1px; @@ -20,7 +21,7 @@ &__icon { flex-shrink: 0; flex-grow: 0; - align-self: flex-start; + align-self: center; } &__info { @@ -30,12 +31,17 @@ flex-grow: 1; flex-shrink: 1; padding: 0 2px; + word-wrap: break-word; + overflow: hidden; } &__info, &__activity { &__datetime, &__title { + line-height: 1.4em; + margin-bottom: 2px; + &__link { text-decoration: none; color: inherit; @@ -52,7 +58,7 @@ &__author { font-size: .9em; - line-height: 1em; + line-height: 1.2em; &__name { color: inherit; diff --git a/config/config.example.ini b/config/config.example.ini index 98deffca..1dab1279 100644 --- a/config/config.example.ini +++ b/config/config.example.ini @@ -11,28 +11,11 @@ database = database charset = utf8mb4 collation = utf8mb4_bin -[Database.sqlite_example] -driver = sqlite -database = store/database.db3 -prefix = +[Site] +name = Misuzu +description = Describe your description. +twitter = flashiinet +url = http://misuzu.localhost/ -[Database.postgres_example] -driver = pgsql -host = localhost -port = 5432 -username = username -password = password -prefix = prefix_ -database = database -charset = utf8 -schema = public - -[Database.sqlsrv_example] -driver = sqlsrv -host = localhost -port = 1433 -username = username -password = password -prefix = prefix_ -database = database -charset = utf8 +[GeoIP] +database_path=/path/to/GeoLite2-Country.mmdb diff --git a/public/forum/forum.php b/public/forum/forum.php index 23b67350..cdc95750 100644 --- a/public/forum/forum.php +++ b/public/forum/forum.php @@ -4,6 +4,8 @@ use Misuzu\Database; require_once __DIR__ . '/../../misuzu.php'; $forumId = (int)($_GET['f'] ?? 0); +$topicsOffset = max((int)($_GET['o'] ?? 0), 0); +$topicsRange = max(min((int)($_GET['r'] ?? 20), 50), 10); if ($forumId === 0) { header('Location: /forum/'); @@ -16,8 +18,13 @@ $templating = $app->getTemplating(); if ($forumId > 0) { $getForum = $db->prepare(' SELECT - `forum_id`, `forum_name`, `forum_type`, `forum_link`, `forum_parent` - FROM `msz_forum_categories` + `forum_id`, `forum_name`, `forum_type`, `forum_link`, `forum_parent`, + ( + SELECT COUNT(`topic_id`) + FROM `msz_forum_topics` + WHERE `forum_id` = f.`forum_id` + ) as `forum_topic_count` + FROM `msz_forum_categories` as f WHERE `forum_id` = :forum_id '); $getForum->bindValue('forum_id', $forumId); @@ -42,28 +49,44 @@ $topics = []; if ($forum['forum_type'] == 0) { $getTopics = $db->prepare(' SELECT - t.`topic_id`, t.`topic_title`, t.`topic_view_count`, t.`topic_status`, t.`topic_type`, + t.`topic_id`, t.`topic_title`, t.`topic_view_count`, t.`topic_status`, t.`topic_type`, t.`topic_created`, au.`user_id` as `author_id`, au.`username` as `author_name`, - COUNT(p.`post_id`) as `topic_post_count`, - MIN(p.`post_id`) as `topic_first_post_id`, - MIN(p.`post_created`) as `topic_first_post_created`, - MAX(p.`post_id`) as `topic_last_post_id`, - MAX(p.`post_created`) as `topic_last_post_created`, - MAX(p.`user_id`) as `topic_last_user_id`, - COALESCE(ar.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `author_colour` + COALESCE(ar.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `author_colour`, + lp.`post_id` as `response_id`, + lp.`post_created` as `response_created`, + lu.`user_id` as `respondent_id`, + lu.`username` as `respondent_name`, + COALESCE(lr.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `respondent_colour`, + ( + SELECT COUNT(`post_id`) + FROM `msz_forum_posts` + WHERE `topic_id` = t.`topic_id` + ) as `topic_post_count` FROM `msz_forum_topics` as t LEFT JOIN `msz_users` as au ON t.`user_id` = au.`user_id` LEFT JOIN `msz_roles` as ar ON ar.`role_id` = au.`display_role` - LEFT JOIN `msz_forum_posts` as p - ON t.`topic_id` = p.`topic_id` + LEFT JOIN `msz_forum_posts` as lp + ON lp.`post_id` = ( + SELECT `post_id` + FROM `msz_forum_posts` + WHERE `topic_id` = t.`topic_id` + ORDER BY `post_id` DESC + LIMIT 1 + ) + LEFT JOIN `msz_users` as lu + ON lu.`user_id` = lp.`user_id` + LEFT JOIN `msz_roles` as lr + ON lr.`role_id` = lu.`display_role` WHERE t.`forum_id` = :forum_id AND t.`topic_deleted` IS NULL - GROUP BY t.`topic_id` ORDER BY t.`topic_type` DESC, t.`topic_bumped` DESC + LIMIT :offset, :take '); $getTopics->bindValue('forum_id', $forum['forum_id']); + $getTopics->bindValue('offset', $topicsOffset); + $getTopics->bindValue('take', $topicsRange); $topics = $getTopics->execute() ? $getTopics->fetchAll() : $topics; } @@ -129,4 +152,6 @@ echo $app->getTemplating()->render('forum.forum', [ 'forum_info' => $forum, 'forum_breadcrumbs' => $breadcrumbs, 'forum_topics' => $topics, + 'forum_offset' => $topicsOffset, + 'forum_range' => $topicsRange, ]); diff --git a/views/mio/forum/forum.twig b/views/mio/forum/forum.twig index eb74c174..7b375deb 100644 --- a/views/mio/forum/forum.twig +++ b/views/mio/forum/forum.twig @@ -14,7 +14,7 @@ {% if forum_info.forum_type == 0 %} {% set fcbuttons = forum_category_buttons(forum_info) %} - {% set fcpagination = pagination(forum_topics|length, 20, 0, canonical_url) %} + {% set fcpagination = pagination(forum_info.forum_topic_count, forum_range, forum_offset, canonical_url) %} {{ fcbuttons }} {{ fcpagination }} diff --git a/views/mio/forum/macros.twig b/views/mio/forum/macros.twig index 63a91b0a..d04a09a4 100644 --- a/views/mio/forum/macros.twig +++ b/views/mio/forum/macros.twig @@ -119,13 +119,16 @@
{{ topic.topic_title }}
- {% if topic.author_id is not null %} -
- by - {{ topic.author_name }} - -
- {% endif %} +
+ {% if topic.author_id is not null %} + by {{ topic.author_name }}, + + {% endif %} + {{ topic.topic_created }} +
@@ -139,14 +142,14 @@
- - {{ topic.topic_first_post_created }} + + {{ topic.response_created }}
- {% if topic.topic_last_user_id is not null %} + {% if topic.respondent_id is not null %}
- by - {{ topic.author_name }} + by + {{ topic.respondent_name }}
{% endif %}