Add supporting modifications to frontend and css

This commit is contained in:
Arran Cudbard-Bell
2011-06-03 23:23:43 -07:00
committed by Arran Cudbard-Bell
parent 8e89ec504f
commit 38c943d564
4 changed files with 85 additions and 13 deletions
+24 -2
View File
@@ -6,6 +6,8 @@ require 'mustache/sinatra'
require 'gollum/frontend/views/layout' require 'gollum/frontend/views/layout'
require 'gollum/frontend/views/editable' require 'gollum/frontend/views/editable'
require 'extensions/toc'
module Precious module Precious
class App < Sinatra::Base class App < Sinatra::Base
register Mustache::Sinatra register Mustache::Sinatra
@@ -111,7 +113,17 @@ module Precious
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options) wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@name = "Preview" @name = "Preview"
@page = wiki.preview_page(@name, params[:content], params[:format]) @page = wiki.preview_page(@name, params[:content], params[:format])
@content = @page.formatted_data @content = @page.formatted_data do
|doc|
# Insert anchors for table of contents
toc = Gollum::Extensions::Toc_gen.new doc
if (toc_content = toc.generate)
toc.insert_anchors
@toc_content = toc_content.to_xhtml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XHTML)
else
@toc_content = nil
end
end
@editable = false @editable = false
mustache :page mustache :page
end end
@@ -195,8 +207,18 @@ module Precious
if page = wiki.page(name) if page = wiki.page(name)
@page = page @page = page
@name = name @name = name
@content = page.formatted_data
@editable = true @editable = true
@content = page.formatted_data do
|doc|
# Insert anchors for table of contents
toc = Gollum::Extensions::Toc_gen.new doc
if (toc_content = toc.generate)
toc.insert_anchors
@toc_content = toc_content.to_xhtml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XHTML)
else
@toc_content = nil
end
end
mustache :page mustache :page
elsif file = wiki.file(name) elsif file = wiki.file(name)
content_type file.mime_type content_type file.mime_type
@@ -71,6 +71,7 @@ a:hover, a:visited {
#wiki-body { #wiki-body {
display: block; display: block;
float: left; float: left;
clear: left;
margin-right: 3%; margin-right: 3%;
margin-bottom: 40px; margin-bottom: 40px;
width: 100%; width: 100%;
@@ -80,6 +81,42 @@ a:hover, a:visited {
width: 68%; width: 68%;
} }
/* @section toc */
#wiki-toc-main {
background-color: #F7F7F7;
border: 1px solid #DDD;
font-size: 13px;
padding: 7px;
float:left;
margin-bottom: 20px;
border-radius: 0.5em;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
}
#wiki-toc-main > h2 {
font-size: 24px;
border-bottom: 1px solid #CCC;
color: black;
margin-top: 5px;
margin-bottom: 20px;
}
#wiki-toc-main ul {
-webkit-margin-before: 0px;
-webkit-padding-start: 0px;
margin-left: 1em;
margin-right: 1em;
padding-left: 0;
}
#wiki-toc-main ul li {
line-height: 1.75em;
list-style-position: inside;
list-style-type: round;
}
/* @section rightbar */ /* @section rightbar */
#wiki-rightbar { #wiki-rightbar {
background-color: #f7f7f7; background-color: #f7f7f7;
@@ -141,6 +178,7 @@ a:hover, a:visited {
#wiki-header #header-content { #wiki-header #header-content {
margin-bottom: 1.5em; margin-bottom: 1.5em;
} }
#wiki-footer #footer-content { #wiki-footer #footer-content {
margin-top: 1.5em; margin-top: 1.5em;
} }
+14 -8
View File
@@ -18,7 +18,20 @@
</ul> </ul>
</div> </div>
<div id="wiki-content"> <div id="wiki-content">
<div class="wrap {{#has_footer}} has-footer {{/has_footer}} {{#has_sidebar}} has-rightbar{{/has_sidebar}}"> <div class="wrap{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-rightbar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}">
{{#has_toc}}
<div id="wiki-toc-main" class="gollum-{{sidebar_format}}-content">
<h2>Table of contents</h2>
{{{toc_content}}}
</div>
{{/has_toc}}
{{#has_sidebar}}
<div id="wiki-rightbar" class="gollum-{{sidebar_format}}-content">
<div id="sidebar-content" class="markdown-body">
{{{sidebar_content}}}
</div>
</div>
{{/has_sidebar}}
<div id="wiki-body" class="gollum-{{format}}-content"> <div id="wiki-body" class="gollum-{{format}}-content">
{{#has_header}} {{#has_header}}
<div id="wiki-header" class="gollum-{{header_format}}-content"> <div id="wiki-header" class="gollum-{{header_format}}-content">
@@ -31,13 +44,6 @@
{{{content}}} {{{content}}}
</div> </div>
</div> </div>
{{#has_sidebar}}
<div id="wiki-rightbar" class="gollum-{{sidebar_format}}-content">
<div id="sidebar-content" class="markdown-body">
{{{sidebar_content}}}
</div>
</div>
{{/has_sidebar}}
{{#has_footer}} {{#has_footer}}
<div id="wiki-footer" class="gollum-{{footer_format}}-content"> <div id="wiki-footer" class="gollum-{{footer_format}}-content">
<div id="footer-content" class="markdown-body"> <div id="footer-content" class="markdown-body">
+6
View File
@@ -65,6 +65,12 @@ module Precious
def sidebar_format def sidebar_format
has_sidebar && @sidebar.format.to_s has_sidebar && @sidebar.format.to_s
end end
def has_toc
!@toc_content.nil?
end
def toc_content
@toc_content
end
end end
end end
end end