Closed #17
This commit is contained in:
parent
fa652c2fca
commit
d85728064a
5 changed files with 10 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<p class="alert alert-error">Error: <?php echo $this->context->transport->errorMessage ?><br><a href="javascript:history.go(-1)">Go back</a></p>
|
||||
<p class="alert alert-error">Error: <?php echo $this->context->transport->errorHtml ?><br><a href="javascript:history.go(-1)">Go back</a></p>
|
||||
|
|
Loading…
Reference in a new issue