aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-12-04 12:51:23 +0100
committerMario Vavti <mario@mariovavti.com>2016-12-04 12:51:23 +0100
commitb12d4c03cbc2627774b279f17a413860d868e854 (patch)
tree10acf01c398ad51bbf51e8f41ea4bda64963f122
parent792527d456a031696f93015fb4fc91e60dee151b (diff)
downloadvolse-hubzilla-b12d4c03cbc2627774b279f17a413860d868e854.tar.gz
volse-hubzilla-b12d4c03cbc2627774b279f17a413860d868e854.tar.bz2
volse-hubzilla-b12d4c03cbc2627774b279f17a413860d868e854.zip
fixes for toc bbcode and bbcode wiki toc
-rw-r--r--Zotlabs/Module/Wiki.php4
-rw-r--r--include/bbcode.php10
-rw-r--r--view/css/conversation.css13
-rw-r--r--view/js/main.js1
-rw-r--r--view/tpl/wiki.tpl5
5 files changed, 24 insertions, 9 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 5b3c4c1d8..da23d67a2 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -214,7 +214,7 @@ class Wiki extends \Zotlabs\Web\Controller {
$content = ($p['content'] !== '' ? $rawContent : '"# New page\n"');
// Render the Markdown-formatted page content in HTML
if($mimeType == 'text/bbcode') {
- $renderedContent = bbcode($content);
+ $renderedContent = wiki_convert_links(bbcode($content),argv(0).'/'.argv(1).'/'.$wikiUrlName);
}
else {
require_once('library/markdown.php');
@@ -314,7 +314,7 @@ class Wiki extends \Zotlabs\Web\Controller {
$mimeType = $w['mimeType'];
if($mimeType == 'text/bbcode') {
- $html = bbcode($content);
+ $html = wiki_convert_links(bbcode($content),$wikiURL);
}
else {
require_once('library/markdown.php');
diff --git a/include/bbcode.php b/include/bbcode.php
index 6794fca96..396cbcb29 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -824,12 +824,14 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text);
}
// Check for table of content without params
- if (strpos($Text,'[toc]') !== false) {
- $Text = preg_replace("/\[toc\]/ism",'<ul id="toc"></ul>',$Text);
+ while(strpos($Text,'[toc]') !== false) {
+ $toc_id = 'toc-' . random_string(10);
+ $Text = preg_replace("/\[toc\]/ism", '<strong>' . t('Contents:') . '</strong><ul id="' . $toc_id . '" class="toc" data-toc=".section-content-wrapper"></ul><script>$("#' . $toc_id . '").toc();</script>', $Text, 1);
}
// Check for table of content with params
- if (strpos($Text,'[toc') !== false) {
- $Text = preg_replace("/\[toc([^\]]+?)\]/ism",'<ul$1></ul>',$Text);
+ while(strpos($Text,'[toc') !== false) {
+ $toc_id = 'toc-' . random_string(10);
+ $Text = preg_replace("/\[toc([^\]]+?)\]/ism", '<strong>' . t('Contents:') . '</strong><ul id="' . $toc_id . '" class="toc"$1></ul><script>$("#' . $toc_id . '").toc();</script>', $Text, 1);
}
// Check for centered text
if (strpos($Text,'[/center]') !== false) {
diff --git a/view/css/conversation.css b/view/css/conversation.css
index 0b6674b15..aec457302 100644
--- a/view/css/conversation.css
+++ b/view/css/conversation.css
@@ -336,6 +336,19 @@ a.wall-item-name-link {
/* bb-code */
+/* prevent [toc] bbcode links to scroll the titles behind the navbar */
+.section-content-wrapper h1,
+.section-content-wrapper h2,
+.section-content-wrapper h3,
+.section-content-wrapper h4 {
+ padding-top: 60px;
+ margin-top: -40px;
+}
+
+.toc {
+ margin-top: 1em;
+}
+
code {
font-family: Courier, monospace;
font-size: 1em;
diff --git a/view/js/main.js b/view/js/main.js
index e78725931..3981d4266 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -1315,7 +1315,6 @@ $(document).ready(function() {
numbers : aStr['t17'],
};
- $("#toc").toc();
});
function zFormError(elm,x) {
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index cf4144357..7d698b493 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -184,7 +184,9 @@
function (data) {
if (data.success) {
$('#wiki-preview').html(data.html);
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
$("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
+ {{/if}}
$('#page-tools').hide();
} else {
window.console.log('Error previewing page.');
@@ -418,13 +420,12 @@
$(document).ready(function () {
wiki_refresh_page_list();
- $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
-
// This seems obsolete
// Show Edit tab first. Otherwise the Ace editor does not load.
//$("#wiki-nav-tabs li:eq(1) a").tab('show');
{{if !$mimeType || $mimeType == 'text/markdown'}}
+ $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
window.editor.on("input", function() {
if(window.editor.getSession().getUndoManager().isClean()) {
$('#save-page').addClass('disabled');