From b96edd8b9ab86d84a2e67515a87de13f660d5cb1 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 26 Jun 2016 15:04:47 -0400 Subject: Added table of contents generator. Table is inserted wherever [toc] is encountered. --- Zotlabs/Module/Wiki.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Module/Wiki.php') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index de5863d2e..a11960b51 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -198,6 +198,7 @@ class Wiki extends \Zotlabs\Web\Controller { $content = $_POST['content']; $resource_id = $_POST['resource_id']; require_once('library/markdown.php'); + $content = wiki_generate_toc($content); $html = purify_html(Markdown($content)); $w = wiki_get_wiki($resource_id); $wikiURL = argv(0).'/'.argv(1).'/'.$w['urlName']; -- cgit v1.2.3 From 216f034b6dd0d26282035218126d312080a9adc3 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 26 Jun 2016 15:27:55 -0400 Subject: Also generate table of contents when loading the page --- Zotlabs/Module/Wiki.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Module/Wiki.php') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index a11960b51..9b89ed967 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -126,6 +126,7 @@ class Wiki extends \Zotlabs\Web\Controller { $content = ($p['content'] !== '' ? $p['content'] : '"# New page\n"'); // Render the Markdown-formatted page content in HTML require_once('library/markdown.php'); + $content = wiki_generate_toc($content); $renderedContent = wiki_convert_links(Markdown(json_decode($content)),argv(0).'/'.argv(1).'/'.$wikiUrlName); $hide_editor = false; $showPageControls = $wiki_editor; -- cgit v1.2.3 From 81da9f99e4ee111623a1ba302a6ab18e369756e9 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 26 Jun 2016 15:41:25 -0400 Subject: Fixed bug with rendering table of contents upon page load --- Zotlabs/Module/Wiki.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module/Wiki.php') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 9b89ed967..a5039fa23 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -126,8 +126,9 @@ class Wiki extends \Zotlabs\Web\Controller { $content = ($p['content'] !== '' ? $p['content'] : '"# New page\n"'); // Render the Markdown-formatted page content in HTML require_once('library/markdown.php'); - $content = wiki_generate_toc($content); - $renderedContent = wiki_convert_links(Markdown(json_decode($content)),argv(0).'/'.argv(1).'/'.$wikiUrlName); + $toc_content = wiki_generate_toc(json_decode($content)); + $html = purify_html(Markdown($toc_content)); + $renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName); $hide_editor = false; $showPageControls = $wiki_editor; $showNewWikiButton = $wiki_owner; -- cgit v1.2.3 From 7124c0aee5486aab74272c81ceb3e383b2e3a7f7 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Thu, 30 Jun 2016 21:50:38 -0400 Subject: Replace homemade table of content generator with existing jQuery plugin. Now toc is linked to document headings. --- Zotlabs/Module/Wiki.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module/Wiki.php') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index a5039fa23..f30884bfb 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -126,8 +126,7 @@ class Wiki extends \Zotlabs\Web\Controller { $content = ($p['content'] !== '' ? $p['content'] : '"# New page\n"'); // Render the Markdown-formatted page content in HTML require_once('library/markdown.php'); - $toc_content = wiki_generate_toc(json_decode($content)); - $html = purify_html(Markdown($toc_content)); + $html = wiki_generate_toc(purify_html(Markdown(json_decode($content)))); $renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName); $hide_editor = false; $showPageControls = $wiki_editor; @@ -200,8 +199,7 @@ class Wiki extends \Zotlabs\Web\Controller { $content = $_POST['content']; $resource_id = $_POST['resource_id']; require_once('library/markdown.php'); - $content = wiki_generate_toc($content); - $html = purify_html(Markdown($content)); + $html = wiki_generate_toc(purify_html(Markdown($content))); $w = wiki_get_wiki($resource_id); $wikiURL = argv(0).'/'.argv(1).'/'.$w['urlName']; $html = wiki_convert_links($html,$wikiURL); -- cgit v1.2.3