return new ErrorResponse('Note does not exist');
}
- $converter = new \OCA\Grauphel\Lib\Converter\Html();
+ $converter = new \OCA\Grauphel\Converter\Html();
$converter->internalLinkHandler = array($this, 'noteLinkHandler');
+
+ try {
+ $contentHtml = $converter->convert($note->{'note-content'});
+ } catch (\OCA\Grauphel\Converter\Exception $e) {
+ $contentHtml = '<div class="error">'
+ . '<p>There was an error converting the note to HTML:</p>'
+ . '<blockquote><tt>' . htmlspecialchars($e->getMessage()) . '</tt></blockquote>'
+ . '<p>Please open a bug report at'
+ . ' <a class="lined" href="http://github.com/cweiske/grauphel/issues">'
+ . 'github.com/cweiske/grauphel/issues</a>'
+ . ' and attach the XML version of the note.'
+ . '</div>';
+ }
+
$res->setParams(
array(
'note' => $note,
- 'note-content' => $converter->convert(
- $note->{'note-content'}
- ),
+ 'note-content' => $contentHtml,
'links' => array(
'json' => $this->urlGen->linkToRoute(
'grauphel.api.note', array(
padding: 1ex;
font-family: monospace;
}
+.app-grauphel #app-content blockquote {
+ margin-left: 2ex;
+}
.app-grauphel #app-content ul {
list-style-type: disc;
.app-grauphel #app-content .success {
color: green;
}
+.app-grauphel #app-content .error a {
+ color: red !important;
+}
.app-grauphel #app-content .actions {
float: right;
--- /dev/null
+<?php
+/**
+ * Part of grauphel
+ *
+ * PHP version 5
+ *
+ * @category Tools
+ * @package Grauphel
+ * @copyright 2014 Christian Weiske
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link http://cweiske.de/grauphel.htm
+ */
+namespace OCA\Grauphel\Converter;
+
+/**
+ * Something went wrong during conversion
+ *
+ * @category Tools
+ * @package Grauphel
+ * @copyright 2014 Christian Weiske
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @version Release: @package_version@
+ * @link http://cweiske.de/grauphel.htm
+ */
+class Exception extends \Exception
+{
+}
+?>
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @link http://cweiske.de/grauphel.htm
*/
-namespace OCA\Grauphel\Lib\Converter;
+namespace OCA\Grauphel\Converter;
use \XMLReader;
/**
$store .= nl2br(htmlspecialchars($reader->value));
break;
default:
- throw new \Exception(
+ throw new Exception(
'Unsupported XML node type: ' . $reader->nodeType
);
}