This commit is contained in:
Marcin Kurczewski 2013-10-19 15:19:47 +02:00
parent fa652c2fca
commit d85728064a
5 changed files with 10 additions and 6 deletions

View file

@ -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;
}
}

View file

@ -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';

View file

@ -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
{

View file

@ -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;
}
}

View file

@ -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>