diff --git a/assets/less/mio/classes/changelog.less b/assets/less/mio/classes/changelog.less new file mode 100644 index 00000000..a90f7bda --- /dev/null +++ b/assets/less/mio/classes/changelog.less @@ -0,0 +1,224 @@ +@mio-changelog-mobile: 700px; + +.changelog { + display: flex; + + @media (max-width: @mio-changelog-mobile) { + flex-wrap: wrap; + } + + &:not(:last-child) { + margin-bottom: 1px; + + @media (max-width: @mio-changelog-mobile) { + border-bottom: 1px solid #9475b2; + padding-bottom: 1px; + } + } + + &__content { + margin: 1px; + } + + &__date { + display: block; + background: #9475b2; + color: #306; + font-weight: 700; + margin-bottom: 1px; + text-decoration: none; + padding: 1px 3px; + + &:hover { + text-decoration: underline; + } + + &:not(:first-child) { + margin-top: 4px; + } + } + + &__user, + &__action { + display: inline-flex; + color: inherit; + flex: 0 0 auto; + margin-right: 1px; + justify-content: center; + align-items: center; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } + + &__user { + min-width: 100px; + justify-content: left; + padding-left: 4px; + + @media (max-width: @mio-changelog-mobile) { + flex-grow: 1; + } + } + + &__action { + min-width: 80px; + justify-content: right; + padding-right: 4px; + + @media (max-width: @mio-changelog-mobile) { + margin-right: 0; + } + + &--light { + color: #fff; + } + } + + &__log { + word-wrap: break-word; + overflow: hidden; + flex: 1 1 auto; + margin-left: 2px; + + @media (max-width: @mio-changelog-mobile) { + width: 100%; + } + + &--link { + color: inherit; + text-decoration: underline dotted; + + &:hover { + text-decoration: underline solid; + } + } + } + + &__change { + + &__line { + border: 1px solid #9475b2; + display: flex; + align-items: center; + flex: 1 0 auto; + } + + &__row, + &__column { + display: flex; + } + + &__column { + flex-direction: column; + + &--user-info { + justify-content: space-between; + flex: 0 0 auto; + } + + &--change-info { + flex: 1 1 auto; + } + } + + &__action { + display: block; + padding: 6px 2px; + border-right: 1px solid #9475b2; + writing-mode: sideways-lr; + text-orientation: sideways; + letter-spacing: 1px; + + &--light { + color: #fff; + } + } + + &__log { + padding: 4px 12px; + font-size: 1.4em; + } + + &__date { + border: 1px solid #9475b2; + color: inherit; + text-decoration: none; + margin-right: 1px; + text-align: center; + padding: 2px; + + &:hover { + text-decoration: underline; + } + } + + &__user { + border: 1px solid #9475b2; + padding: 2px; + display: flex; + align-items: center; + text-decoration: none; + color: inherit; + margin: 1px; + margin-left: 0; + + &__info { + margin: 2px 5px; + } + + &__title { + width: 120px; + word-wrap: break-word; + } + + &__avatar { + width: 60px; + height: 60px; + margin-right: 1px; + align-self: flex-start; + } + + &__name { + font-size: 1.5em; + line-height: 1.2em; + } + } + + &__text { + margin: 1px 0; + padding: 1px 3px; + border-top: 1px solid #9475b2; + font-size: 1.2em; + line-height: 1.5em; + flex: 1 1 auto; + } + + &__tags { + list-style: none; + display: flex; + flex-wrap: wrap; + } + + &__tag { + border: 1px solid #9475b2; + margin-right: 1px; + border-radius: 2px; + + &__link { + display: block; + width: 100%; + height: 100%; + color: inherit; + text-decoration: none; + padding: 0 5px; + } + + &:hover { + text-decoration: underline; + } + } + } +} diff --git a/assets/less/mio/classes/flag.less b/assets/less/mio/classes/flag.less index be414f80..67dbd036 100644 --- a/assets/less/mio/classes/flag.less +++ b/assets/less/mio/classes/flag.less @@ -1,15 +1,15 @@ @flag-width: 16px; @flag-height: 11px; -.flag-position(@x, @y, @offsetX: 0px, @offsetY: 0px) { - background-position: top -(@flag-height * @x) + @offsetX left -(@flag-width * @y) + @offsetY; +.flag-position(@x, @y) { + background-position: top -((@flag-height + 1) * @x) left -(@flag-width * @y); } .flag { display: inline-block; width: @flag-width; height: @flag-height; - background-image: url('https://static.flash.moe/images/flag-sprite-24.png'); + background-image: url('https://static.flash.moe/images/flag-sprite.png'); background-repeat: no-repeat; font-size: 0; .flag-position(23, 23); // xx @@ -118,8 +118,6 @@ &--gw {.flag-position(6, 22);} &--gy {.flag-position(6, 24);} - &--hd {.flag-position(7, 3);} - &--he {.flag-position(7, 4);} &--hk {.flag-position(7, 10);} &--hm {.flag-position(7, 12);} &--hn {.flag-position(7, 13);} @@ -127,6 +125,8 @@ &--ht {.flag-position(7, 19);} &--hu {.flag-position(7, 20);} + &--id {.flag-position(8, 3);} + &--ie {.flag-position(8, 4);} &--il {.flag-position(8, 11);} &--in {.flag-position(8, 13);} &--io {.flag-position(8, 14);} @@ -166,7 +166,7 @@ &--ma {.flag-position(12, 0);} &--mc {.flag-position(12, 2);} &--md {.flag-position(12, 3);} - &--me {.flag-position(12, 4, 1); height: 12px;} + &--me {.flag-position(12, 4); height: 12px;} &--mg {.flag-position(12, 6);} &--mh {.flag-position(12, 7);} &--mk {.flag-position(12, 10);} diff --git a/assets/less/mio/classes/profile.less b/assets/less/mio/classes/profile.less index ab758a74..a582e11e 100644 --- a/assets/less/mio/classes/profile.less +++ b/assets/less/mio/classes/profile.less @@ -91,6 +91,10 @@ &__column { min-width: 80px; + max-width: 200px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; @media (max-width: @mio-profile-mobile) { min-width: auto; diff --git a/assets/less/mio/main.less b/assets/less/mio/main.less index 54c11b21..54204c48 100644 --- a/assets/less/mio/main.less +++ b/assets/less/mio/main.less @@ -84,3 +84,6 @@ body { // Member listing @import "classes/members/user"; @import "classes/members/users"; + +// Changelog +@import "classes/changelog"; diff --git a/database/2018_07_06_031800_changelog_tables.php b/database/2018_07_06_031800_changelog_tables.php new file mode 100644 index 00000000..73c938cc --- /dev/null +++ b/database/2018_07_06_031800_changelog_tables.php @@ -0,0 +1,81 @@ +exec(" + CREATE TABLE `msz_changelog_actions` ( + `action_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `action_name` VARCHAR(50) NOT NULL, + `action_colour` INT(10) UNSIGNED NOT NULL DEFAULT '0', + `action_class` VARCHAR(20) NOT NULL, + PRIMARY KEY (`action_id`), + UNIQUE INDEX `action_class_unique` (`action_class`) + ) + "); + + $conn->exec(" + CREATE TABLE `msz_changelog_changes` ( + `change_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `user_id` INT(10) UNSIGNED NULL DEFAULT NULL, + `action_id` INT(10) UNSIGNED NULL DEFAULT NULL, + `change_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + `change_log` VARCHAR(255) NOT NULL, + `change_text` TEXT NULL, + PRIMARY KEY (`change_id`), + INDEX `changes_user_id_foreign` (`user_id`), + INDEX `changes_action_id_foreign` (`action_id`), + INDEX `changes_change_created_index` (`change_created`), + CONSTRAINT `changes_action_id_foreign` + FOREIGN KEY (`action_id`) + REFERENCES `msz_changelog_actions` (`action_id`) + ON UPDATE CASCADE + ON DELETE SET NULL, + CONSTRAINT `changes_user_id_foreign` + FOREIGN KEY (`user_id`) + REFERENCES `msz_users` (`user_id`) + ON UPDATE CASCADE + ON DELETE SET NULL + ) + "); + + $conn->exec(" + CREATE TABLE `msz_changelog_tags` ( + `tag_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `tag_name` VARCHAR(255) NOT NULL, + `tag_description` TEXT NULL, + `tag_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`tag_id`), + UNIQUE INDEX `tag_name` (`tag_name`) + ) + "); + + $conn->exec(" + CREATE TABLE `msz_changelog_change_tags` ( + `change_id` INT(10) UNSIGNED NOT NULL, + `tag_id` INT(10) UNSIGNED NOT NULL, + INDEX `tag_id_foreign_key` (`tag_id`), + INDEX `change_tag_constraint` (`change_id`, `tag_id`), + CONSTRAINT `change_id_foreign_key` + FOREIGN KEY (`change_id`) + REFERENCES `msz_changelog_changes` (`change_id`) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT `tag_id_foreign_key` + FOREIGN KEY (`tag_id`) + REFERENCES `msz_changelog_tags` (`tag_id`) + ON UPDATE CASCADE + ON DELETE CASCADE + ) + "); +} + +function migrate_down(PDO $conn): void +{ + $conn->exec('DROP TABLE `msz_changelog_change_tags`'); + $conn->exec('DROP TABLE `msz_changelog_tags`'); + $conn->exec('DROP TABLE `msz_changelog_changes`'); + $conn->exec('DROP TABLE `msz_changelog_actions`'); +} diff --git a/misuzu.php b/misuzu.php index 43920ba5..c538c9ac 100644 --- a/misuzu.php +++ b/misuzu.php @@ -4,6 +4,7 @@ namespace Misuzu; date_default_timezone_set('UTC'); require_once __DIR__ . '/vendor/autoload.php'; +require_once __DIR__ . '/src/changelog.php'; require_once __DIR__ . '/src/colour.php'; require_once __DIR__ . '/src/zalgo.php'; require_once __DIR__ . '/src/Forum/forum.php'; diff --git a/public/changelog.php b/public/changelog.php new file mode 100644 index 00000000..744315e9 --- /dev/null +++ b/public/changelog.php @@ -0,0 +1,133 @@ +getTemplating(); + +$changelogOffset = max((int)($_GET['o'] ?? 0), 0); +$changelogRange = 30; + +$changelogChange = (int)($_GET['c'] ?? 0); +$changelogDate = $_GET['d'] ?? ''; + +$tpl->vars([ + 'changelog_offset' => $changelogOffset, + 'changelog_take' => $changelogRange, +]); + +if ($changelogChange > 0) { + $getChange = $db->prepare(' + SELECT + c.`change_id`, c.`change_created`, c.`change_log`, c.`change_text`, + a.`action_name`, a.`action_colour`, a.`action_class`, + u.`user_id`, u.`username`, + DATE(`change_created`) as `change_date`, + COALESCE(u.`user_title`, r.`role_title`) as `user_title`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` + FROM `msz_changelog_changes` as c + LEFT JOIN `msz_users` as u + ON u.`user_id` = c.`user_id` + LEFT JOIN `msz_roles` as r + ON r.`role_id` = u.`display_role` + LEFT JOIN `msz_changelog_actions` as a + ON a.`action_id` = c.`action_id` + WHERE `change_id` = :change_id + '); + $getChange->bindValue('change_id', $changelogChange); + $change = $getChange->execute() ? $getChange->fetch(PDO::FETCH_ASSOC) : []; + + if (!$change) { + http_response_code(404); + } else { + $getTags = $db->prepare(' + SELECT + t.`tag_id`, t.`tag_name`, t.`tag_description` + FROM `msz_changelog_tags` as t + LEFT JOIN `msz_changelog_change_tags` as ct + ON ct.`tag_id` = t.`tag_id` + WHERE ct.`change_id` = :change_id + '); + $getTags->bindValue('change_id', $change['change_id']); + $tags = $getTags->execute() ? $getTags->fetchAll(PDO::FETCH_ASSOC) : []; + $tpl->var('tags', $tags); + } + + echo $tpl->render('changelog.change', compact('change')); + return; +} + +if (!empty($changelogDate)) { + $dateParts = explode('-', $changelogDate, 3); + + if (count($dateParts) !== 3 || !checkdate($dateParts[1], $dateParts[2], $dateParts[0])) { + echo render_error(404); + return; + } + + $getChanges = $db->prepare(' + SELECT + c.`change_id`, c.`change_log`, + a.`action_name`, a.`action_colour`, a.`action_class`, + u.`user_id`, u.`username`, + DATE(`change_created`) as `change_date`, + !ISNULL(c.`change_text`) as `change_has_text`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` + FROM `msz_changelog_changes` as c + LEFT JOIN `msz_users` as u + ON u.`user_id` = c.`user_id` + LEFT JOIN `msz_roles` as r + ON r.`role_id` = u.`display_role` + LEFT JOIN `msz_changelog_actions` as a + ON a.`action_id` = c.`action_id` + WHERE DATE(c.`change_created`) = :date + GROUP BY `change_created`, `change_id` + ORDER BY `change_created` DESC, `change_id` DESC + '); + $getChanges->bindValue('date', $changelogDate); + $changes = $getChanges->execute() ? $getChanges->fetchAll() : []; + + // settings the response code to 404, but rendering our own page anyway. + if (count($changes) < 1) { + http_response_code(404); + } + + echo $tpl->render('changelog.date', [ + 'changes' => $changes, + ]); + return; +} + +$changesCount = (int)$db->query(' + SELECT COUNT(`change_id`) + FROM `msz_changelog_changes` +')->fetchColumn(); + +$getChanges = $db->prepare(' + SELECT + c.`change_id`, c.`change_log`, + a.`action_name`, a.`action_colour`, a.`action_class`, + u.`user_id`, u.`username`, + DATE(`change_created`) as `change_date`, + !ISNULL(c.`change_text`) as `change_has_text`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` + FROM `msz_changelog_changes` as c + LEFT JOIN `msz_users` as u + ON u.`user_id` = c.`user_id` + LEFT JOIN `msz_roles` as r + ON r.`role_id` = u.`display_role` + LEFT JOIN `msz_changelog_actions` as a + ON a.`action_id` = c.`action_id` + GROUP BY `change_created`, `change_id` + ORDER BY `change_created` DESC, `change_id` DESC + LIMIT :offset, :take +'); +$getChanges->bindValue('offset', $changelogOffset); +$getChanges->bindValue('take', $changelogRange); +$changes = $getChanges->execute() ? $getChanges->fetchAll() : []; + +echo $tpl->render('changelog.index', [ + 'changes' => $changes, + 'changelog_count' => $changesCount, +]); diff --git a/public/index.php b/public/index.php index f1beeb94..a25cd100 100644 --- a/public/index.php +++ b/public/index.php @@ -3,12 +3,25 @@ use Misuzu\Database; require_once __DIR__ . '/../misuzu.php'; +$config = $app->getConfig(); +$tpl = $app->getTemplating(); + +if ($config->get('Site', 'embed_linked_data', 'bool', false)) { + $tpl->vars([ + 'embed_linked_data' => true, + 'embed_name' => $config->get('Site', 'name'), + 'embed_url' => $config->get('Site', 'url'), + 'embed_logo' => $config->get('Site', 'external_logo'), + 'embed_same_as' => explode(',', $config->get('Site', 'social_media')), + ]); +} + $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 `display_colour` + 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` @@ -21,6 +34,6 @@ $featuredNews = Database::connection() //var_dump(Database::connection()->query('SHOW SESSION STATUS LIKE "Questions"')->fetch()['Value']); -echo $app->getTemplating()->render('home.landing', [ +echo $tpl->render('home.landing', [ 'featured_news' => $featuredNews, ]); diff --git a/public/members.php b/public/members.php index a9d23425..7265457b 100644 --- a/public/members.php +++ b/public/members.php @@ -92,7 +92,7 @@ $getUsers = $db->prepare(" u.`user_id`, u.`username`, u.`user_country`, u.`created_at` as `user_joined`, u.`last_seen` as `user_last_seen`, COALESCE(u.`user_title`, r.`role_title`) as `user_title`, - COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `display_colour`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour`, ( SELECT COUNT(`topic_id`) FROM `msz_forum_topics` diff --git a/public/news.php b/public/news.php index c0f4e0fc..ccfa3ca1 100644 --- a/public/news.php +++ b/public/news.php @@ -22,7 +22,7 @@ if ($postId !== null) { p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, c.`category_id`, c.`category_name`, u.`user_id`, u.`username`, - COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `display_colour` + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` FROM `msz_news_posts` as p LEFT JOIN `msz_news_categories` as c ON p.`category_id` = c.`category_id` @@ -68,7 +68,7 @@ if ($categoryId !== null) { p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, c.`category_id`, c.`category_name`, u.`user_id`, u.`username`, - COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `display_colour` + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` FROM `msz_news_posts` as p LEFT JOIN `msz_news_categories` as c ON p.`category_id` = c.`category_id` @@ -134,7 +134,7 @@ $getPosts = $db->prepare(' p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, c.`category_id`, c.`category_name`, u.`user_id`, u.`username`, - COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `display_colour` + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour` FROM `msz_news_posts` as p LEFT JOIN `msz_news_categories` as c ON p.`category_id` = c.`category_id` diff --git a/public/profile.php b/public/profile.php index 39967fb2..47483ee6 100644 --- a/public/profile.php +++ b/public/profile.php @@ -46,17 +46,22 @@ switch ($mode) { SELECT u.*, COALESCE(u.`user_title`, r.`role_title`) as `user_title`, - COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `display_colour`, + COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `user_colour`, ( SELECT COUNT(`topic_id`) - FROM `msz_forum_topics` as t - WHERE t.`user_id` = u.`user_id` + FROM `msz_forum_topics` + WHERE `user_id` = u.`user_id` ) as `forum_topic_count`, ( SELECT COUNT(`post_id`) - FROM `msz_forum_posts` as p - WHERE p.`user_id` = u.`user_id` - ) as `forum_post_count` + FROM `msz_forum_posts` + WHERE `user_id` = u.`user_id` + ) as `forum_post_count`, + ( + SELECT COUNT(`change_id`) + FROM `msz_changelog_changes` + WHERE `user_id` = u.`user_id` + ) as `changelog_count` FROM `msz_users` as u LEFT JOIN `msz_roles` as r ON r.`role_id` = u.`display_role` diff --git a/src/Application.php b/src/Application.php index c82337f2..26ea8c05 100644 --- a/src/Application.php +++ b/src/Application.php @@ -238,10 +238,13 @@ class Application extends ApplicationBase $this->templatingInstance->addFilter('json_decode'); $this->templatingInstance->addFilter('byte_symbol'); + $this->templatingInstance->addFilter('html_link'); + $this->templatingInstance->addFilter('html_colour'); $this->templatingInstance->addFilter('country_name', 'get_country_name'); $this->templatingInstance->addFilter('flip', 'array_flip'); $this->templatingInstance->addFilter('first_paragraph'); $this->templatingInstance->addFilter('colour_get_css'); + $this->templatingInstance->addFilter('colour_get_css_contrast'); $this->templatingInstance->addFilter('colour_get_inherit'); $this->templatingInstance->addFilter('colour_get_red'); $this->templatingInstance->addFilter('colour_get_green'); diff --git a/src/changelog.php b/src/changelog.php new file mode 100644 index 00000000..75f88cbc --- /dev/null +++ b/src/changelog.php @@ -0,0 +1,43 @@ +prepare(' + INSERT INTO `msz_changelog_actions` + (`action_name`, `action_colour`, `action_class`) + VALUES + (:action_name, :action_colour, :action_class) + '); + $addAction->bindValue('action_name', $name); + $addAction->bindValue('action_colour', $colour); + $addAction->bindValue('action_class', $class); + + return $addAction->execute() ? (int)$dbc->lastInsertId() : 0; +} + +function changelog_entry_create(int $userId, int $actionId, string $log, string $text = null): int +{ + $dbc = Database::connection(); + + $createChange = $dbc->prepare(' + INSERT INTO `msz_changelog_changes` + (`user_id`, `action_id`, `change_log`, `change_text`) + VALUES + (:user_id, :action_id, :change_log, :change_text) + '); + $createChange->bindValue('user_id', $userId); + $createChange->bindValue('action_id', $actionId); + $createChange->bindValue('change_log', $log); + $createChange->bindValue('change_text', $text); + + return $createChange->execute() ? (int)$dbc->lastInsertId() : 0; +} diff --git a/src/colour.php b/src/colour.php index 4f158a77..2f5f1266 100644 --- a/src/colour.php +++ b/src/colour.php @@ -1,5 +1,9 @@ MSZ_COLOUR_READABILITY_THRESHOLD + ? $dark + : $light; +} + function colour_from_rgb(int &$colour, int $red, int $green, int $blue): bool { colour_set_red($colour, $red); diff --git a/utility.php b/utility.php index 05dbc502..0dae411a 100644 --- a/utility.php +++ b/utility.php @@ -241,3 +241,44 @@ function render_error(int $code, string $template = 'errors.%d'): string return ''; } } + +function html_link(string $url, ?string $content = null, $attributes = []): string +{ + $content = $content ?? $url; + $attributes = array_merge( + is_string($attributes) ? ['class' => $attributes] : $attributes, + ['href' => $url] + ); + + if (strpos($url, '://') !== false) { + $attributes['target'] = '_blank'; + $attributes['rel'] = 'noreferrer noopener'; + } + + $html = ' $value) { + $value = str_replace('"', '\"', $value); + $html .= " {$name}=\"{$value}\""; + } + + $html .= ">{$content}"; + + return $html; +} + +function html_colour(int $colour, array $attribs = []): string +{ + if (!$attribs) { + $attribs['color'] = '%s'; + } + + $css = ''; + $value = colour_get_css($colour); + + foreach ($attribs as $name => $format) { + $css .= $name . ':' . sprintf($format, $value) . ';'; + } + + return $css; +} diff --git a/views/manage/master.twig b/views/manage/master.twig index d943a3e6..96ef6577 100644 --- a/views/manage/master.twig +++ b/views/manage/master.twig @@ -137,7 +137,7 @@
- +
Profile diff --git a/views/manage/users/listing.twig b/views/manage/users/listing.twig index 28237551..4807f19f 100644 --- a/views/manage/users/listing.twig +++ b/views/manage/users/listing.twig @@ -4,7 +4,7 @@ {% block content %}
{% for user in manage_users %} - +
diff --git a/views/manage/users/roles.twig b/views/manage/users/roles.twig index 4102ea8c..d25dcda0 100644 --- a/views/manage/users/roles.twig +++ b/views/manage/users/roles.twig @@ -8,7 +8,7 @@
{% for role in manage_roles %} - +
{{ role.role_name }} {{ role.users }} users diff --git a/views/manage/users/roles_create.twig b/views/manage/users/roles_create.twig index 24594d03..3acc60b6 100644 --- a/views/manage/users/roles_create.twig +++ b/views/manage/users/roles_create.twig @@ -5,7 +5,7 @@

{% if edit_role is defined %} - Editing {{ edit_role.role_name }} ({{ edit_role.role_id }}) + Editing {{ edit_role.role_name }} ({{ edit_role.role_id }}) {% else %} Creating a new Role {% endif %} diff --git a/views/manage/users/view.twig b/views/manage/users/view.twig index 28e05373..c95b7ff6 100644 --- a/views/manage/users/view.twig +++ b/views/manage/users/view.twig @@ -3,7 +3,7 @@ {% block content %}

- Viewing {{ view_user.username }} ({{ view_user.user_id }}) + Viewing {{ view_user.username }} ({{ view_user.user_id }})

+ + {{ navigation(mio_navigation) }} +{% endblock %} diff --git a/views/mio/changelog/date.twig b/views/mio/changelog/date.twig new file mode 100644 index 00000000..fe50699b --- /dev/null +++ b/views/mio/changelog/date.twig @@ -0,0 +1,23 @@ +{% extends '@mio/changelog/master.twig' %} +{% from '@mio/macros.twig' import navigation, pagination %} +{% from '@mio/changelog/macros.twig' import changelog_listing %} + +{% set is_valid = changes|length > 0 %} +{% set title = 'Changelog » ' ~ (is_valid ? changes[0].change_date : 'Unknown date') %} + +{% if is_valid %} + {% set canonical_url = '/changelog.php?d=' ~ changes[0].change_date %} +{% endif %} + +{% block content %} +
+
+ {{ title }} +
+
+ {{ changelog_listing(changes, true) }} +
+
+ + {{ navigation(mio_navigation) }} +{% endblock %} diff --git a/views/mio/changelog/index.twig b/views/mio/changelog/index.twig new file mode 100644 index 00000000..c135d947 --- /dev/null +++ b/views/mio/changelog/index.twig @@ -0,0 +1,20 @@ +{% extends '@mio/changelog/master.twig' %} +{% from '@mio/macros.twig' import navigation, pagination %} +{% from '@mio/changelog/macros.twig' import changelog_listing %} + +{% set title = 'Changelog' %} +{% set canonical_url = '/changelog.php' %} + +{% block content %} +
+
+ Changelog +
+
+ {{ changelog_listing(changes) }} + {{ pagination(changelog_count, changelog_take, changelog_offset, '/changelog.php') }} +
+
+ + {{ navigation(mio_navigation) }} +{% endblock %} diff --git a/views/mio/changelog/macros.twig b/views/mio/changelog/macros.twig new file mode 100644 index 00000000..c8e1cfb7 --- /dev/null +++ b/views/mio/changelog/macros.twig @@ -0,0 +1,49 @@ +{% macro changelog_listing(changes, hide_dates) %} + {% set hide_dates = hide_dates ? true : false %} + {% set last_date = '' %} + + {% from _self import changelog_entry %} + + {% if changes|length > 0 %} + {% for change in changes %} + {% if not hide_dates and last_date != change.change_date %} + {% set last_date = change.change_date %} + + + {{ last_date }} + + {% endif %} + + {{ changelog_entry(change) }} + {% endfor %} + {% else %} +
+ There are no changes to display here. +
+ {% endif %} +{% endmacro %} + +{% macro changelog_entry(change) %} + {% set has_text = change.change_has_text|default(false) + or (change.change_text is defined and change.change_text|length > 0) + %} + + +{% endmacro %} diff --git a/views/mio/changelog/master.twig b/views/mio/changelog/master.twig new file mode 100644 index 00000000..187fe3a8 --- /dev/null +++ b/views/mio/changelog/master.twig @@ -0,0 +1 @@ +{% extends '@mio/master.twig' %} diff --git a/views/mio/forum/macros.twig b/views/mio/forum/macros.twig index 6a6c72ed..aa7cab7c 100644 --- a/views/mio/forum/macros.twig +++ b/views/mio/forum/macros.twig @@ -98,7 +98,7 @@ {% if forum.recent_post_user_id is not null %} by {{ forum.recent_post_username }}, {% endif %}
{% if topic.respondent_id is not null %}
- by + by {{ topic.respondent_name }}
@@ -266,7 +266,7 @@

+ style="{{ post.poster_colour|html_colour }}">{{ post.poster_name }}
{{ navigation(mio_navigation, '/') }} + + {% if embed_linked_data is defined and embed_linked_data %} + + {% endif %} {% endblock %} diff --git a/views/mio/macros.twig b/views/mio/macros.twig index 3ff043ad..3fcde997 100644 --- a/views/mio/macros.twig +++ b/views/mio/macros.twig @@ -1,9 +1,3 @@ -{% macro link(url, content, class) %} -{% spaceless %} -{{ content|raw }} -{% endspaceless %} -{% endmacro %} - {% macro navigation(links, current, top, fmt, align) %} {% set top = top|default(false) == true %} {% set align = align|default('centre') %} diff --git a/views/mio/master.twig b/views/mio/master.twig index c488ad00..c3d82b17 100644 --- a/views/mio/master.twig +++ b/views/mio/master.twig @@ -1,4 +1,4 @@ -{% from '@mio/macros.twig' import link, navigation %} +{% from '@mio/macros.twig' import navigation %} {% set mio_navigation = { 'Home': '/', @@ -65,17 +65,23 @@
diff --git a/views/mio/news/macros.twig b/views/mio/news/macros.twig index d435171d..463c7e91 100644 --- a/views/mio/news/macros.twig +++ b/views/mio/news/macros.twig @@ -13,7 +13,7 @@ {{ post.created_at|time_diff }} -
+
{{ post.username }}
diff --git a/views/mio/news/post.twig b/views/mio/news/post.twig index b8484807..fab1ef4c 100644 --- a/views/mio/news/post.twig +++ b/views/mio/news/post.twig @@ -17,7 +17,7 @@
-
{{ post.username }}
+
{{ post.username }}
diff --git a/views/mio/user/listing.twig b/views/mio/user/listing.twig index 04f50a4f..5eaab1cd 100644 --- a/views/mio/user/listing.twig +++ b/views/mio/user/listing.twig @@ -9,11 +9,11 @@ {% block content %}