X-Git-Url: https://git.cweiske.de/grauphel.git/blobdiff_plain/6c8ad60e9888fa5625dad2460ca073f93ac1ae0d..35e58ea1056480418d36b08a98f288d583805b23:/controller/guicontroller.php diff --git a/controller/guicontroller.php b/controller/guicontroller.php index 6f0a15c..6fffcb2 100644 --- a/controller/guicontroller.php +++ b/controller/guicontroller.php @@ -17,6 +17,7 @@ use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http\TemplateResponse; use \OCA\Grauphel\Lib\Client; use \OCA\Grauphel\Lib\TokenStorage; +use \OCA\Grauphel\Lib\Response\ErrorResponse; /** * Owncloud frontend @@ -72,6 +73,74 @@ class GuiController extends Controller return $res; } + /** + * Show contents of a note + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function note($guid) + { + $res = new TemplateResponse('grauphel', 'gui-note'); + + $note = $this->getNotes()->load($guid, false); + if ($note === null) { + return new ErrorResponse('Note does not exist'); + } + + $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 = '
There was an error converting the note to HTML:
' + . '' . htmlspecialchars($e->getMessage()) . '' + . '
Please open a bug report at' + . ' ' + . 'github.com/cweiske/grauphel/issues' + . ' and attach the XML version of the note.' + . '