Allow the sidebar side to be specified

This commit is contained in:
Arran Cudbard-Bell
2013-02-11 17:57:45 -05:00
parent 2e2e6457c7
commit 21c4b0dd95
7 changed files with 44 additions and 20 deletions
+1 -5
View File
@@ -544,11 +544,7 @@ Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gi
## CUSTOM CSS ## CUSTOM CSS
The `--css` flag will inject `custom.css` from the root of your git repository into each page. `custom.css` must be commited to git or you will get a 302 redirect to the create page. Here's an example of floating the sidebar to the left. The `--css` flag will inject `custom.css` from the root of your git repository into each page. `custom.css` must be commited to git or you will get a 302 redirect to the create page.
```css
#wiki-rightbar { float: left !important; }
```
## CONTRIBUTE ## CONTRIBUTE
+5 -1
View File
@@ -388,11 +388,15 @@ module Precious
if page = wiki.paged(name, path, exact = true) if page = wiki.paged(name, path, exact = true)
@page = page @page = page
@name = name @name = name
@editable = true
@content = page.formatted_data @content = page.formatted_data
# Extensions and layout data
@editable = true
@toc_content = wiki.universal_toc ? @page.toc_data : nil @toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax @mathjax = wiki.mathjax
@h1_title = wiki.h1_title @h1_title = wiki.h1_title
@bar_side = wiki.bar_side
mustache :page mustache :page
elsif file = wiki.file(fullpath) elsif file = wiki.file(fullpath)
content_type file.mime_type content_type file.mime_type
@@ -74,6 +74,12 @@ a:hover, a:visited {
} }
/* @section body */ /* @section body */
.has-leftbar #wiki-body {
float: right;
clear: right;
}
#wiki-body { #wiki-body {
display: block; display: block;
float: left; float: left;
@@ -83,7 +89,7 @@ a:hover, a:visited {
width: 100%; width: 100%;
} }
.has-rightbar #wiki-body { .has-sidebar #wiki-body {
width: 68%; width: 68%;
} }
@@ -105,12 +111,19 @@ a:hover, a:visited {
border: none; border: none;
} }
/* @section rightbar */ /* @section sidebar */
#wiki-rightbar { .has-leftbar #wiki-sidebar {
float: left;
}
.has-rightbar #wiki-sidebar {
float: right;
}
#wiki-sidebar {
background-color: #f7f7f7; background-color: #f7f7f7;
border: 1px solid #ddd; border: 1px solid #ddd;
font-size: 13px; font-size: 13px;
float: right;
padding: 7px; padding: 7px;
width: 25%; width: 25%;
color: #555; color: #555;
@@ -120,15 +133,15 @@ a:hover, a:visited {
-webkit-border-radius: 0.5em; -webkit-border-radius: 0.5em;
} }
#wiki-rightbar p { #wiki-sidebar p {
margin: 13px 0 0; margin: 13px 0 0;
} }
#wiki-rightbar > p:first-child { #wiki-sidebar > p:first-child {
margin-top: 10px; margin-top: 10px;
} }
#wiki-rightbar p.parent { #wiki-sidebar p.parent {
border-bottom: 1px solid #bbb; border-bottom: 1px solid #bbb;
font-weight: bold; font-weight: bold;
margin: 0 0 0.5em 0; margin: 0 0 0.5em 0;
@@ -137,7 +150,7 @@ a:hover, a:visited {
} }
/* Back arrow */ /* Back arrow */
#wiki-rightbar p.parent:before { #wiki-sidebar p.parent:before {
color: #666; color: #666;
content: "← "; content: "← ";
} }
@@ -149,7 +162,7 @@ a:hover, a:visited {
margin: 2em 0 5em; margin: 2em 0 5em;
} }
.has-rightbar #wiki-footer { .has-sidebar #wiki-footer {
width: 70%; width: 70%;
} }
@@ -3,7 +3,7 @@
<h1>Create New Page</h1> <h1>Create New Page</h1>
</div> </div>
<div id="wiki-content" class="create edit"> <div id="wiki-content" class="create edit">
<div class="has-rightbar"> <div class="has-sidebar">
{{>editor}} {{>editor}}
</div> </div>
</div> </div>
+2 -2
View File
@@ -31,14 +31,14 @@ Mousetrap.bind(['e'], function( e ) {
</ul> </ul>
</div> </div>
<div id="wiki-content"> <div id="wiki-content">
<div class="{{#has_header}}has-header{{/has_header}}{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-rightbar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}"> <div class="{{#has_header}}has-header{{/has_header}}{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-sidebar has-{{bar_side}}bar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}">
{{#has_toc}} {{#has_toc}}
<div id="wiki-toc-main"> <div id="wiki-toc-main">
{{{toc_content}}} {{{toc_content}}}
</div> </div>
{{/has_toc}} {{/has_toc}}
{{#has_sidebar}} {{#has_sidebar}}
<div id="wiki-rightbar" class="gollum-{{sidebar_format}}-content"> <div id="wiki-sidebar" class="gollum-{{sidebar_format}}-content">
<div id="sidebar-content" class="markdown-body"> <div id="sidebar-content" class="markdown-body">
{{{sidebar_content}}} {{{sidebar_content}}}
</div> </div>
+4
View File
@@ -65,6 +65,10 @@ module Precious
has_footer && @footer.format.to_s has_footer && @footer.format.to_s
end end
def bar_side
@bar_side.to_s
end
def has_sidebar def has_sidebar
@sidebar = (@page.sidebar || false) if @sidebar.nil? @sidebar = (@page.sidebar || false) if @sidebar.nil?
!!@sidebar !!@sidebar
+7
View File
@@ -148,6 +148,9 @@ module Gollum
# Gets the custom index page for / and subdirs (e.g. foo/) # Gets the custom index page for / and subdirs (e.g. foo/)
attr_reader :index_page attr_reader :index_page
# Gets side on which the sidebar should be shown
attr_reader :bar_side
# Public: Initialize a new Gollum Repo. # Public: Initialize a new Gollum Repo.
# #
# path - The String path to the Git repository that holds the Gollum # path - The String path to the Git repository that holds the Gollum
@@ -176,6 +179,9 @@ module Gollum
# page title. # page title.
# :index_page - The default page to retrieve or create if the # :index_page - The default page to retrieve or create if the
# a directory is accessed. # a directory is accessed.
# :bar_side - Where the sidebar should be displayed, may be:
# - :left
# - :right
# #
# Returns a fresh Gollum::Repo. # Returns a fresh Gollum::Repo.
def initialize(path, options = {}) def initialize(path, options = {})
@@ -212,6 +218,7 @@ module Gollum
@css = options.fetch :css, false @css = options.fetch :css, false
@h1_title = options.fetch :h1_title, false @h1_title = options.fetch :h1_title, false
@index_page = options.fetch :index_page, 'Home' @index_page = options.fetch :index_page, 'Home'
@bar_side = options.fetch :sidebar, :right
@user_icons = ['gravatar', 'identicon'].include?( options[:user_icons] ) ? @user_icons = ['gravatar', 'identicon'].include?( options[:user_icons] ) ?
options[:user_icons] : 'none' options[:user_icons] : 'none'
end end