finishing touches for the baseline (nowhere near done tho)

This commit is contained in:
flash 2018-05-26 22:33:05 +02:00
parent 4e2ff47137
commit b7507cf495
16 changed files with 162 additions and 71 deletions

View file

@ -1,4 +1,4 @@
@mio-forum-listing-mobile: 500px;
@mio-forum-listing-mobile: 700px;
.forum__listing {
&__forums {
@ -69,6 +69,14 @@
}
}
&__stats,
&__activity {
display: flex;
flex-shrink: 0;
flex-grow: 0;
border-left: 1px solid #9475b2;
}
&__stats {
text-align: center;
justify-content: center;
@ -76,7 +84,10 @@
flex-direction: column;
@media (max-width: @mio-forum-listing-mobile) {
display: none;
min-width: initial;
border-left-width: 0;
align-self: flex-end;
align-items: flex-end;
}
}
@ -90,18 +101,34 @@
color: #555;
}
@media (max-width: @mio-forum-listing-mobile) {
&__topics,
&__posts {
font-size: 1em;
margin: 0 4px;
}
}
&__activity {
min-width: 270px;
min-height: 50px;
align-items: center;
@media (max-width: @mio-forum-listing-mobile) {
display: none;
min-width: 150px;
&--empty {
display: none;
}
}
&__title {
line-height: 1.4em;
margin-bottom: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 200px;
&__link {
color: inherit;
@ -148,14 +175,14 @@
flex-grow: 1;
flex-shrink: 1;
}
}
&__stats,
&__activity {
display: flex;
flex-shrink: 0;
flex-grow: 0;
border-left: 1px solid #9475b2;
@media (max-width: @mio-forum-listing-mobile) {
&__title,
&__info,
&__none {
width: 90px;
}
}
}
}
}

View file

@ -1,3 +1,5 @@
@mio-forum-post-mobile: 700px;
.forum__post {
display: flex;
border: 1px solid #9475b2;
@ -5,6 +7,10 @@
background-color: #fbeeff;
margin: 2px 0;
@media (max-width: @mio-forum-post-mobile) {
flex-direction: column;
}
&__content {
display: flex;
flex-direction: column;
@ -16,6 +22,12 @@
&__text {
margin: 2px;
line-height: 1.2em;
@media (max-width: @mio-forum-post-mobile) {
margin: 4px;
font-size: 1.2em;
line-height: 1.3em;
}
}
&__info {
@ -42,15 +54,32 @@
text-align: center;
flex-grow: 0;
flex-shrink: 0;
min-width: 150px;
min-width: 170px;
display: flex;
flex-direction: column;
align-items: center;
@media (max-width: @mio-forum-post-mobile) {
border-right-width: 0;
border: 1px solid #9475b2;
flex-direction: row;
border-bottom-width: 2px;
}
&__joined {
flex-grow: 1;
flex-shrink: 1;
margin: 5px;
max-width: 170px;
// somewhat temporary?
// more stuff will be added eventually which this will be mixed in with
display: flex;
flex-direction: column-reverse;
@media (max-width: @mio-forum-post-mobile) {
display: none;
}
}
&__link {
@ -59,21 +88,34 @@
text-decoration: none;
flex-grow: 0;
flex-shrink: 0;
@media (max-width: @mio-forum-post-mobile) {
display: flex;
align-items: center;
margin: 5px;
flex-grow: 1;
}
}
&__avatar {
width: 120px;
height: 120px;
box-shadow: 0 1px 2px #9475b2;
@media (max-width: @mio-forum-post-mobile) {
width: 40px;
height: 40px;
margin-right: 5px;
}
}
&__username {
font-size: 1.5em;
line-height: 1.7em;
}
&:hover {
text-decoration: underline;
}
&:not(&--deleted) &__username:hover {
text-decoration: underline;
}
}
}

View file

@ -1,3 +1,5 @@
@mio-forum-topics-mobile: 700px;
.forum__topics {
&__listing {
margin: 1px;
@ -35,6 +37,14 @@
overflow: hidden;
}
&__stats,
&__activity {
display: flex;
flex-shrink: 0;
flex-grow: 0;
border-left: 1px solid #9475b2;
}
&__info,
&__activity {
&__datetime,
@ -83,6 +93,11 @@
font-size: 0.8em;
color: #555;
}
@media (max-width: @mio-forum-topics-mobile) {
font-size: 1em;
margin: 0 4px;
}
}
&__stats {
@ -91,6 +106,13 @@
min-width: 70px;
flex-direction: column;
justify-content: center;
@media (max-width: @mio-forum-topics-mobile) {
min-width: initial;
border-left-width: 0;
align-self: flex-end;
align-items: flex-end;
}
}
&__activity {
@ -98,6 +120,11 @@
padding-left: 3px;
align-items: center;
@media (max-width: @mio-forum-topics-mobile) {
min-width: initial;
width: 120px;
}
&__info {
flex-grow: 1;
flex-shrink: 1;
@ -112,13 +139,5 @@
margin-right: 2px;
}
}
&__stats,
&__activity {
display: flex;
flex-shrink: 0;
flex-grow: 0;
border-left: 1px solid #9475b2;
}
}
}

View file

@ -26,7 +26,7 @@
@media (max-width: @mio-news-mobile) {
height: 30px;
width: 30px;
min-width: 30px;
font-size: 1.5em;
line-height: 1.5em;
}

View file

@ -26,8 +26,8 @@ function migrate_up(PDO $conn): void
`username` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NULL DEFAULT NULL,
`email` VARCHAR(255) NOT NULL,
`register_ip` BLOB NOT NULL,
`last_ip` BLOB NOT NULL,
`register_ip` VARBINARY(16) NOT NULL,
`last_ip` VARBINARY(16) NOT NULL,
`user_country` CHAR(2) NOT NULL DEFAULT 'XX',
`user_chat_key` VARCHAR(32) NULL DEFAULT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
@ -82,7 +82,7 @@ function migrate_up(PDO $conn): void
`session_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` INT(10) UNSIGNED NOT NULL,
`session_key` VARCHAR(255) NOT NULL,
`session_ip` BLOB NOT NULL,
`session_ip` VARBINARY(16) NOT NULL,
`user_agent` VARCHAR(255) NULL DEFAULT NULL,
`expires_on` TIMESTAMP NULL DEFAULT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
@ -102,7 +102,7 @@ function migrate_up(PDO $conn): void
CREATE TABLE `msz_login_attempts` (
`attempt_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`was_successful` TINYINT(1) NOT NULL,
`attempt_ip` BLOB NOT NULL,
`attempt_ip` VARBINARY(16) NOT NULL,
`attempt_country` CHAR(2) NOT NULL DEFAULT 'XX',
`user_id` INT(10) UNSIGNED NULL DEFAULT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,

View file

@ -57,7 +57,7 @@ function migrate_up(PDO $conn): void
`topic_id` INT(10) UNSIGNED NOT NULL,
`forum_id` INT(10) UNSIGNED NOT NULL,
`user_id` INT(10) UNSIGNED NULL DEFAULT NULL,
`post_ip` BLOB NOT NULL,
`post_ip` VARBINARY(16) NOT NULL,
`post_text` TEXT NOT NULL,
`post_parse` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',
`post_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

View file

@ -75,8 +75,7 @@ if (PHP_SAPI !== 'cli') {
if ($manage_mode) {
if ($app->getUserId() !== 1) {
http_response_code(403);
echo $app->getTemplating()->render('errors.403');
echo render_error(403);
exit;
}

View file

@ -16,8 +16,7 @@ $templating = $app->getTemplating();
$forum = forum_fetch($forumId);
if (empty($forum) || ($forum['forum_type'] == MSZ_FORUM_TYPE_LINK && empty($forum['forum_link']))) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}

View file

@ -8,8 +8,7 @@ $db = Database::connection();
$templating = $app->getTemplating();
if (!$app->hasActiveSession()) {
http_response_code(403);
echo $templating->render('errors.403');
echo render_error(403);
return;
}
@ -25,8 +24,7 @@ if ($postRequest) {
}
if (empty($postId) && empty($topicId) && empty($forumId)) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}
@ -69,24 +67,26 @@ if (!empty($forumId)) {
}
if (empty($forum)) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}
if ($forum['forum_type'] != MSZ_FORUM_TYPE_DISCUSSION) {
http_response_code(400);
echo $templating->render('errors.400');
echo render_error(400);
return;
}
if ($forum['forum_archived'] || !empty($topic['topic_locked'])) {
http_response_code(403);
echo $templating->render('errors.403');
echo render_error(403);
return;
}
if ($postRequest) {
if (!tmp_csrf_verify($_POST['csrf'] ?? '')) {
echo 'Could not verify request.';
return;
}
$topicTitle = $_POST['post']['title'] ?? '';
$topicTitleValidate = forum_validate_title($topicTitle);
$postText = $_POST['post']['text'] ?? '';

View file

@ -20,16 +20,14 @@ if ($topicId < 1 && $postId > 0) {
$topic = forum_topic_fetch($topicId);
if (!$topic) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}
$posts = forum_post_listing($topic['topic_id'], $postsOffset, $postsRange);
if (!$posts) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}

View file

@ -1,6 +1,5 @@
<?php
use Misuzu\Database;
use Misuzu\Parsers\MarkdownParser;
require_once __DIR__ . '/../misuzu.php';

View file

@ -33,8 +33,7 @@ if ($post_id !== null) {
$post = $getPost->execute() ? $getPost->fetch() : false;
if ($post === false) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}
@ -57,8 +56,7 @@ if ($category_id !== null) {
$category = $getCategory->execute() ? $getCategory->fetch() : false;
if ($category === false || $posts_offset < 0 || $posts_offset >= $category['posts_count']) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}
@ -124,8 +122,7 @@ $postsCount = (int)$db->query('
$templating->var('posts_count', $postsCount);
if ($posts_offset < 0 || $posts_offset >= $postsCount) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}
@ -152,8 +149,7 @@ $getPosts->bindValue('take', $posts_take);
$posts = $getPosts->execute() ? $getPosts->fetchAll() : [];
if (!$posts) {
http_response_code(404);
echo $templating->render('errors.404');
echo render_error(404);
return;
}

View file

@ -1,4 +1,4 @@
<?php
require_once __DIR__ . '/../misuzu.php';
echo $app->getTemplating()->render('errors.404');
echo render_error(404);

View file

@ -11,8 +11,7 @@ $query_offset = (int)($_GET['o'] ?? 0);
$query_take = 15;
if (!$app->hasActiveSession()) {
http_response_code(403);
echo $templating->render('errors.403');
echo render_error(403);
return;
}

View file

@ -230,3 +230,14 @@ function parse_bbcode(string $text): string
{
return \Misuzu\Parsers\BBCode\BBCodeParser::getOrCreateInstance()->parseText($text);
}
function render_error(int $code, string $template = 'errors.%d'): string
{
http_response_code($code);
try {
return \Misuzu\Application::getInstance()->getTemplating()->render(sprintf($template, $code));
} catch (Exception $ex) {
return '';
}
}

View file

@ -72,15 +72,15 @@
<div class="forum__listing__entry__topics" title="Clicks">{{ forum.forum_link_clicks|number_format }}</div>
</div>
{% endif %}
{% else %}
{% elseif forum.forum_type != 1 %}
<div class="forum__listing__entry__stats">
<div class="forum__listing__entry__topics" title="Topics">{{ forum.forum_topic_count|number_format }}</div>
<div class="forum__listing__entry__posts" title="Posts">{{ forum.forum_post_count|number_format }}</div>
</div>
{% endif %}
{% if forum.forum_type != 2 or forum.forum_link_clicks is not null %}
<div class="forum__listing__entry__activity">
{% if forum.forum_type == 0 or forum.forum_link_clicks is not null %}
<div class="forum__listing__entry__activity{% if forum.forum_link_clicks is not null %} forum__listing__entry__activity--empty{% endif %}">
{% if forum.forum_type != 2 %}
{% if forum.recent_topic_id is null %}
<div class="forum__listing__entry__activity__none">
@ -91,7 +91,7 @@
<div class="forum__listing__entry__activity__title">
<a class="forum__listing__entry__activity__title__link"
href="/forum/topic.php?p={{ forum.recent_post_id }}#p{{ forum.recent_post_id }}">
{{ forum.recent_topic_title|slice(0, 30) ~ (forum.recent_topic_title|length > 30 ? '...' : '') }}
{{ forum.recent_topic_title }}
</a>
</div>
<div class="forum__listing__entry__activity__info">
@ -250,8 +250,8 @@
{% set is_original_poster = is_original_poster|default(false) %}
<div class="forum__post" id="p{{ post.post_id }}">
<div class="forum__post__author">
{% if post.poster_id is not null %}
{% if post.poster_id is not null %}
<div class="forum__post__author">
<a class="forum__post__author__link" href="/profile.php?u={{ post.poster_id }}">
<div
class="avatar forum__post__author__avatar"
@ -262,14 +262,16 @@
style="color:{{ post.poster_colour|colour_get_css }}">{{ post.poster_name }}</div>
</a>
<div class="forum__post__author__joined">
joined 5 years ago {# post.poster_joined #}
joined {{ post.poster_joined }}
</div>
{% else %}
<div class="forum__post__author__joined">
deleted user
</div>
{% else %}
<div class="forum__post__author forum__post__author--deleted">
<div class="forum__post__author__link">
<div class="forum__post__author__username">Deleted User</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
<div class="forum__post__content">
<div class="forum__post__content__info">
@ -322,7 +324,7 @@
</div>
<div class="forum__posting__buttons">
<button class="input__button">Submit</button>
<button class="input__button" name="csrf" value="{{ csrf_token() }}">Submit</button>
</div>
</div>
</form>