+ /**
+ * 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\Lib\Converter\Html();
+ $converter->internalLinkHandler = array($this, 'noteLinkHandler');
+ $res->setParams(
+ array(
+ 'note' => $note,
+ 'note-content' => $converter->convert(
+ $note->{'note-content'}
+ ),
+ )
+ );
+
+ $this->addNavigation($res);
+ return $res;
+ }
+
+ public function noteLinkHandler($noteTitle)
+ {
+ $guid = $this->getNotes()->loadGuidByTitle($noteTitle);
+ if ($guid === null) {
+ return '#';
+ }
+ return $this->urlGen->linkToRoute(
+ 'grauphel.gui.note', array('guid' => $guid)
+ );
+ }
+