comment of document, documentcontent and folder can be rendered as markdown

This commit is contained in:
Uwe Steinmann 2023-04-04 17:46:08 +02:00
parent d4fbae1a4c
commit 9092eeb0a3
6 changed files with 32 additions and 3 deletions

View File

@ -2,6 +2,8 @@
Changes in version 5.1.31 Changes in version 5.1.31
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- rest api returns error msg and not just http status - rest api returns error msg and not just http status
- comment of document, documentcontent and folder can be rendered as
markdown
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 5.1.30 Changes in version 5.1.30

View File

@ -290,6 +290,8 @@ class Settings { /* {{{ */
var $_maxItemsPerPage = 0; var $_maxItemsPerPage = 0;
// number of documents/folders fetched when scrolling to bottom of ViewFolder page // number of documents/folders fetched when scrolling to bottom of ViewFolder page
var $_incItemsPerPage = 0; var $_incItemsPerPage = 0;
// parse comments of folders and documents as markdown
var $_markdownComments = false;
// Show form to submit missing translations at end of page // Show form to submit missing translations at end of page
var $_showMissingTranslations = false; var $_showMissingTranslations = false;
// Extra Path to additional software, will be added to include path // Extra Path to additional software, will be added to include path
@ -498,6 +500,7 @@ class Settings { /* {{{ */
$this->_maxItemsPerPage = intval($tab["maxItemsPerPage"]); $this->_maxItemsPerPage = intval($tab["maxItemsPerPage"]);
if(isset($tab["incItemsPerPage"])) if(isset($tab["incItemsPerPage"]))
$this->_incItemsPerPage = intval($tab["incItemsPerPage"]); $this->_incItemsPerPage = intval($tab["incItemsPerPage"]);
$this->_markdownComments = Settings::boolVal($tab["markdownComments"]);
// XML Path: /configuration/site/edition // XML Path: /configuration/site/edition
$node = $xml->xpath('/configuration/site/edition'); $node = $xml->xpath('/configuration/site/edition');
@ -882,6 +885,7 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "convertToPdf", $this->_convertToPdf); $this->setXMLAttributValue($node, "convertToPdf", $this->_convertToPdf);
$this->setXMLAttributValue($node, "maxItemsPerPage", $this->_maxItemsPerPage); $this->setXMLAttributValue($node, "maxItemsPerPage", $this->_maxItemsPerPage);
$this->setXMLAttributValue($node, "incItemsPerPage", $this->_incItemsPerPage); $this->setXMLAttributValue($node, "incItemsPerPage", $this->_incItemsPerPage);
$this->setXMLAttributValue($node, "markdownComments", $this->_markdownComments);
// XML Path: /configuration/site/edition // XML Path: /configuration/site/edition
$node = $this->getXMLNode($xml, '/configuration/site', 'edition'); $node = $this->getXMLNode($xml, '/configuration/site', 'edition');

View File

@ -115,6 +115,7 @@ if ($action == "saveSettings")
setBoolValue('convertToPdf'); setBoolValue('convertToPdf');
setIntValue('maxItemsPerPage'); setIntValue('maxItemsPerPage');
setIntValue('incItemsPerPage'); setIntValue('incItemsPerPage');
setBoolValue('markdownComments');
// SETTINGS - SITE - EDITION // SETTINGS - SITE - EDITION
setBoolValue('strictFormCheck'); setBoolValue('strictFormCheck');

View File

@ -330,6 +330,7 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
<?php $this->showConfigCheckbox('settings_convertToPdf', 'convertToPdf'); ?> <?php $this->showConfigCheckbox('settings_convertToPdf', 'convertToPdf'); ?>
<?php $this->showConfigText('settings_maxItemsPerPage', 'maxItemsPerPage'); ?> <?php $this->showConfigText('settings_maxItemsPerPage', 'maxItemsPerPage'); ?>
<?php $this->showConfigText('settings_incItemsPerPage', 'incItemsPerPage'); ?> <?php $this->showConfigText('settings_incItemsPerPage', 'incItemsPerPage'); ?>
<?php $this->showConfigCheckbox('settings_markdownComments', 'markdownComments'); ?>
<!-- <!--
-- SETTINGS - SITE - EDITION -- SETTINGS - SITE - EDITION

View File

@ -383,6 +383,7 @@ $(document).ready( function() {
function documentInfos() { /* {{{ */ function documentInfos() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$settings = $this->params['settings'];
$document = $this->params['document']; $document = $this->params['document'];
$txt = $this->callHook('documentInfos', $document); $txt = $this->callHook('documentInfos', $document);
@ -418,10 +419,16 @@ $(document).ready( function() {
</tr> </tr>
<?php <?php
if($document->getComment()) { if($document->getComment()) {
if($settings->_markdownComments) {
$Parsedown = new Parsedown();
$comment = $Parsedown->text($document->getComment());
} else {
$comment = htmlspecialchars($document->getComment());
}
?> ?>
<tr> <tr>
<td><?php printMLText("comment");?>:</td> <td><?php printMLText("comment");?>:</td>
<td><?php print htmlspecialchars($document->getComment());?></td> <td><div class="document-comment"><?php print $comment;?></div></td>
</tr> </tr>
<?php <?php
} }
@ -764,7 +771,14 @@ $(document).ready( function() {
echo $txt; echo $txt;
} else { } else {
if($latestContent->getComment()) if($latestContent->getComment())
print "<p style=\"font-style: italic;\">".htmlspecialchars($latestContent->getComment())."</p>"; if($settings->_markdownComments) {
$Parsedown = new Parsedown();
$comment = $Parsedown->text($latestContent->getComment());
print "<div class=\"content-comment\">".$comment."</div>";
} else {
$comment = htmlspecialchars($latestContent->getComment());
print "<p style=\"font-style: italic;\">".$comment."</p>";
}
} }
print "<ul class=\"actions unstyled\">\n"; print "<ul class=\"actions unstyled\">\n";
$this->printVersionAttributes($folder, $latestContent); $this->printVersionAttributes($folder, $latestContent);

View File

@ -248,6 +248,7 @@ $('body').on('click', '.order-btn', function(ev) {
function folderInfos() { /* {{{ */ function folderInfos() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$settings = $this->params['settings'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
$txt = $this->callHook('folderInfos', $folder); $txt = $this->callHook('folderInfos', $folder);
@ -275,9 +276,15 @@ $('body').on('click', '.order-btn', function(ev) {
echo "<td>".getLongReadableDate($folder->getDate())."</td>"; echo "<td>".getLongReadableDate($folder->getDate())."</td>";
echo "</tr>"; echo "</tr>";
if($folder->getComment()) { if($folder->getComment()) {
if($settings->_markdownComments) {
$Parsedown = new Parsedown();
$comment = $Parsedown->text($folder->getComment());
} else {
$comment = htmlspecialchars($folder->getComment());
}
echo "<tr>"; echo "<tr>";
echo "<td>".getMLText("comment").":</td>\n"; echo "<td>".getMLText("comment").":</td>\n";
echo "<td>".htmlspecialchars($folder->getComment())."</td>\n"; echo "<td><div class=\"folder-comment\">".$content."</div></td>\n";
echo "</tr>"; echo "</tr>";
} }