mirror of
https://github.com/danpros/htmly.git
synced 2026-04-17 19:26:08 +05:30
Add TOC settings
This commit is contained in:
parent
8da38da937
commit
844e707452
4 changed files with 93 additions and 11 deletions
|
|
@ -135,6 +135,12 @@ cache.timestamp = "false"
|
|||
; The site.url depends on where you are visiting from. Same installation
|
||||
multi.site = "false"
|
||||
|
||||
; TOC label
|
||||
toc.label = "Table of Contents"
|
||||
|
||||
; TOC inital state
|
||||
toc.state = "close"
|
||||
|
||||
; Set the theme here
|
||||
views.root = "themes/twentysixteen"
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","tagcloud.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","multi.site","views.root","views.layout"]
|
||||
["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","tagcloud.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","multi.site","toc.label","toc.state","views.root","views.layout"]
|
||||
|
|
@ -58,6 +58,34 @@
|
|||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h4>TOC (Table of Contents)</h4>
|
||||
<hr>
|
||||
<div class="form-group row">
|
||||
<label for="toc.label" class="col-sm-2 col-form-label">TOC label</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="-config-toc.label" class="form-control" id="toc.label" value="<?php echo valueMaker(config('toc.label'));?>" placeholder="Table of Contents">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">TOC initial state</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-10">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="-config-toc.state" id="toc.state1" value="open" <?php if (config('toc.state') === 'open'):?>checked<?php endif;?>>
|
||||
<label class="form-check-label" for="toc.state1">
|
||||
Open
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="-config-toc.state" id="toc.state2" value="close" <?php if (config('toc.state') === 'close'):?>checked<?php endif;?>>
|
||||
<label class="form-check-label" for="toc.state2">
|
||||
Close
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h4><?php echo i18n('Comments');?></h4>
|
||||
<hr>
|
||||
<p><?php echo i18n('To_using_Disqus_or_Facebook_comment_you_need_to_provide_Disqus_shortname_or_Facebook_App_ID');?></p>
|
||||
|
|
|
|||
|
|
@ -519,7 +519,15 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
// Get the contents and convert it to HTML
|
||||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
$toc = explode('<!--toc-->', $post->body);
|
||||
if (isset($toc['1'])) {
|
||||
if (isset($toc['1'])) {
|
||||
$state = config('toc.state');
|
||||
if ($state !== 'open') {
|
||||
$state = 'close';
|
||||
}
|
||||
$label = config('toc.label');
|
||||
if (empty($label)) {
|
||||
$label = 'Table of Contents';
|
||||
}
|
||||
$load = <<<EOF
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -533,7 +541,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
});
|
||||
</script>
|
||||
EOF;
|
||||
$post->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.post-'.$post->date.'" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents</span></summary><div class="inner"><div class="toc" id="toc.post-'.$post->date.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
$post->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.post-'.$post->date.'" style="display:none;" ><details '. $state .'><summary title="TOC"><span class="details">'. $label .'</span></summary><div class="inner"><div class="toc" id="toc.post-'.$post->date.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
}
|
||||
|
||||
// Convert image tags to figures
|
||||
|
|
@ -601,7 +609,15 @@ function get_pages($pages, $page = 1, $perpage = 0)
|
|||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
|
||||
$toc = explode('<!--toc-->', $post->body);
|
||||
if (isset($toc['1'])) {
|
||||
if (isset($toc['1'])) {
|
||||
$state = config('toc.state');
|
||||
if ($state !== 'open') {
|
||||
$state = 'close';
|
||||
}
|
||||
$label = config('toc.label');
|
||||
if (empty($label)) {
|
||||
$label = 'Table of Contents';
|
||||
}
|
||||
$load = <<<EOF
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -615,7 +631,7 @@ function get_pages($pages, $page = 1, $perpage = 0)
|
|||
});
|
||||
</script>
|
||||
EOF;
|
||||
$post->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-'.$post->slug.'" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents</span></summary><div class="inner"><div class="toc" id="toc.page-'.$post->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
$post->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-'.$post->slug.'" style="display:none;" ><details '. $state .'><summary title="TOC"><span class="details">'. $label .'</span></summary><div class="inner"><div class="toc" id="toc.page-'.$post->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
}
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
|
|
@ -690,6 +706,14 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
|
|||
|
||||
$toc = explode('<!--toc-->', $post->body);
|
||||
if (isset($toc['1'])) {
|
||||
$state = config('toc.state');
|
||||
if ($state !== 'open') {
|
||||
$state = 'close';
|
||||
}
|
||||
$label = config('toc.label');
|
||||
if (empty($label)) {
|
||||
$label = 'Table of Contents';
|
||||
}
|
||||
$load = <<<EOF
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -703,7 +727,7 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
|
|||
});
|
||||
</script>
|
||||
EOF;
|
||||
$post->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.subpage-'.$post->slug.'" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents</span></summary><div class="inner"><div class="toc" id="toc.subpage-'.$post->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
$post->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.subpage-'.$post->slug.'" style="display:none;" ><details '. $state .'><summary title="TOC"><span class="details">'. $label .'</span></summary><div class="inner"><div class="toc" id="toc.subpage-'.$post->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
}
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
|
|
@ -984,7 +1008,15 @@ function read_category_info($category)
|
|||
$desc->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
|
||||
$toc = explode('<!--toc-->', $desc->body);
|
||||
if (isset($toc['1'])) {
|
||||
if (isset($toc['1'])) {
|
||||
$state = config('toc.state');
|
||||
if ($state !== 'open') {
|
||||
$state = 'close';
|
||||
}
|
||||
$label = config('toc.label');
|
||||
if (empty($label)) {
|
||||
$label = 'Table of Contents';
|
||||
}
|
||||
$load = <<<EOF
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -998,7 +1030,7 @@ function read_category_info($category)
|
|||
});
|
||||
</script>
|
||||
EOF;
|
||||
$desc->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.taxonomy-'.$desc->slug.'" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents</span></summary><div class="inner"><div class="toc" id="toc.taxonomy-'.$desc->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
$desc->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.taxonomy-'.$desc->slug.'" style="display:none;" ><details '. $state .'><summary title="TOC"><span class="details">'. $label .'</span></summary><div class="inner"><div class="toc" id="toc.taxonomy-'.$desc->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
}
|
||||
|
||||
$desc->description = get_content_tag("d", $content, get_description($desc->body));
|
||||
|
|
@ -1230,6 +1262,14 @@ function get_author($name)
|
|||
|
||||
$toc = explode('<!--toc-->', $author->about);
|
||||
if (isset($toc['1'])) {
|
||||
$state = config('toc.state');
|
||||
if ($state !== 'open') {
|
||||
$state = 'close';
|
||||
}
|
||||
$label = config('toc.label');
|
||||
if (empty($label)) {
|
||||
$label = 'Table of Contents';
|
||||
}
|
||||
$load = <<<EOF
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -1243,7 +1283,7 @@ function get_author($name)
|
|||
});
|
||||
</script>
|
||||
EOF;
|
||||
$author->about = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.profile-'.$author->slug.'" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents</span></summary><div class="inner"><div class="toc" id="toc.profile-'.$author->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
$author->about = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.profile-'.$author->slug.'" style="display:none;" ><details '. $state .'><summary title="TOC"><span class="details">'. $label .'</span></summary><div class="inner"><div class="toc" id="toc.profile-'.$author->slug.'"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
}
|
||||
|
||||
$author->body = $author->about;
|
||||
|
|
@ -1296,7 +1336,15 @@ function get_frontpage()
|
|||
// Get the contents and convert it to HTML
|
||||
$front->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
$toc = explode('<!--toc-->', $front->body);
|
||||
if (isset($toc['1'])) {
|
||||
if (isset($toc['1'])) {
|
||||
$state = config('toc.state');
|
||||
if ($state !== 'open') {
|
||||
$state = 'close';
|
||||
}
|
||||
$label = config('toc.label');
|
||||
if (empty($label)) {
|
||||
$label = 'Table of Contents';
|
||||
}
|
||||
$load = <<<EOF
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -1310,7 +1358,7 @@ function get_frontpage()
|
|||
});
|
||||
</script>
|
||||
EOF;
|
||||
$front->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-front" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents</span></summary><div class="inner"><div class="toc" id="toc.page-front"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
$front->body = $toc['0'] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-front" style="display:none;" ><details '. $state .'><summary title="TOC"><span class="details">'. $label .'</span></summary><div class="inner"><div class="toc" id="toc.page-front"></div></div></details></div><script src="'. site_url().'system/resources/js/toc.js"></script>' . $toc['1'];
|
||||
}
|
||||
} else {
|
||||
$front->title = 'Welcome';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue