From be93fa747b07d7b8c205d31ad1b546da81a4d028 Mon Sep 17 00:00:00 2001 From: kristi Date: Mon, 14 May 2012 10:23:12 -0700 Subject: [PATCH] Make TOC pretty. Also put in "[[_TOC_]]" stub for viewing sub-page directly --- .../frontend/public/gollum/css/template.css | 29 +++++++++++++++++++ lib/gollum/markup.rb | 8 ++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/gollum/frontend/public/gollum/css/template.css b/lib/gollum/frontend/public/gollum/css/template.css index f8f24566..93c71205 100644 --- a/lib/gollum/frontend/public/gollum/css/template.css +++ b/lib/gollum/frontend/public/gollum/css/template.css @@ -367,6 +367,35 @@ a.absent { margin: 0; padding: 0; } +.markdown-body .toc { + border: 1px solid #ddd; + padding: 5px 10px; + margin: 0; + border-radius: 3px; +} +.markdown-body .toc-title { + color: #888; + padding: 2px; + border-bottom: 1px solid #ddd; + margin-bottom: 3px; +} +.markdown-body .toc ul { + padding-left: 10px; + margin: 0; +} +.markdown-body .toc>ul { + margin-left: 10px; + font-size: 17px; +} +.markdown-body .toc ul ul { + font-size: 15px; +} +.markdown-body .toc ul ul ul { + font-size: 14px; +} +.markdown-body .toc ul li{ + margin: 0; +} .highlight { background: #fff; } diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index f07f070b..bcc58906 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -61,7 +61,7 @@ module Gollum doc = Nokogiri::HTML::DocumentFragment.parse(data) doc = sanitize.clean_node!(doc) if sanitize doc,toc = process_headers(doc) - @toc = @sub_page ? @parent_page.toc_data : toc + @toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc yield doc if block_given? data = doc.to_html @@ -91,9 +91,9 @@ module Gollum h.add_child(anchor) # Build TOC - toc ||= Nokogiri::XML::Node.new('ul', doc) - tail ||= toc - tail_level ||= 1 + toc ||= Nokogiri::XML::DocumentFragment.parse('
Table of Contents
') + tail ||= toc.child + tail_level ||= 0 while tail_level < level node = Nokogiri::XML::Node.new('ul', doc)