diff --git a/public_html/media/js/upload.js b/public_html/media/js/upload.js index 3583fd28..6fc35f03 100644 --- a/public_html/media/js/upload.js +++ b/public_html/media/js/upload.js @@ -122,7 +122,7 @@ $(function() { postDom.removeClass('inactive'); postDom.find(':input').attr('readonly', false); - postDom.find('.alert').text(data['errorMessage']).slideDown(); + postDom.find('.alert').html(data['errorHtml']).slideDown(); errors = true; } } diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 154d2f7f..b68f9aff 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -62,6 +62,7 @@ class Bootstrap catch (SimpleException $e) { $this->context->transport->errorMessage = rtrim($e->getMessage(), '.') . '.'; + $this->context->transport->errorHtml = TextHelper::parseMarkdown($this->context->transport->errorMessage, true); $this->context->transport->exception = $e; $this->context->transport->success = false; if (!$this->context->handleExceptions) @@ -71,6 +72,7 @@ class Bootstrap catch (Exception $e) { $this->context->transport->errorMessage = rtrim($e->getMessage(), '.') . '.'; + $this->context->transport->errorHtml = TextHelper::parseMarkdown($this->context->transport->errorMessage, true); $this->context->transport->exception = $e; $this->context->transport->success = false; $this->context->viewName = 'error-exception'; diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index a44686e1..c66465c6 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -192,7 +192,7 @@ class PostController $fileHash = md5_file($suppliedFile['tmp_name']); $duplicatedPost = R::findOne('post', 'file_hash = ?', [$fileHash]); if ($duplicatedPost !== null) - throw new SimpleException('Duplicate upload'); + throw new SimpleException('Duplicate upload: @' . $duplicatedPost->id); do { diff --git a/src/Helpers/TextHelper.php b/src/Helpers/TextHelper.php index cedff63a..44ec1dd1 100644 --- a/src/Helpers/TextHelper.php +++ b/src/Helpers/TextHelper.php @@ -142,9 +142,11 @@ class TextHelper return json_encode($obj); } - public static function parseMarkdown($text) + public static function parseMarkdown($text, $inline = false) { - #$text = strip_tags($text); - return CustomMarkdown::defaultTransform($text); + $output = CustomMarkdown::defaultTransform($text); + if ($inline) + $output = preg_replace('{?p>}', '', $output); + return $output; } } diff --git a/src/Views/error-simple.phtml b/src/Views/error-simple.phtml index ee41293a..ed1b0f77 100644 --- a/src/Views/error-simple.phtml +++ b/src/Views/error-simple.phtml @@ -1 +1 @@ -
Error: context->transport->errorMessage ?>
Go back
Error: context->transport->errorHtml ?>
Go back