From 21c4b0dd9550681122e49520dedf65058a6e1901 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Mon, 11 Feb 2013 17:57:45 -0500 Subject: [PATCH] Allow the sidebar side to be specified --- README.md | 6 +--- lib/gollum/frontend/app.rb | 8 +++-- .../frontend/public/gollum/css/gollum.css | 33 +++++++++++++------ lib/gollum/frontend/templates/create.mustache | 2 +- lib/gollum/frontend/templates/page.mustache | 4 +-- lib/gollum/frontend/views/page.rb | 4 +++ lib/gollum/wiki.rb | 7 ++++ 7 files changed, 44 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 37a157bb..cd6bb94a 100644 --- a/README.md +++ b/README.md @@ -544,11 +544,7 @@ Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gi ## 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. - -```css -#wiki-rightbar { float: left !important; } -``` +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. ## CONTRIBUTE diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 67ef0a2b..d8c0d850 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -388,11 +388,15 @@ module Precious if page = wiki.paged(name, path, exact = true) @page = page @name = name + @content = page.formatted_data + + # Extensions and layout data @editable = true - @content = page.formatted_data @toc_content = wiki.universal_toc ? @page.toc_data : nil - @mathjax = wiki.mathjax + @mathjax = wiki.mathjax @h1_title = wiki.h1_title + @bar_side = wiki.bar_side + mustache :page elsif file = wiki.file(fullpath) content_type file.mime_type diff --git a/lib/gollum/frontend/public/gollum/css/gollum.css b/lib/gollum/frontend/public/gollum/css/gollum.css index ba59d912..b0e8ab3b 100755 --- a/lib/gollum/frontend/public/gollum/css/gollum.css +++ b/lib/gollum/frontend/public/gollum/css/gollum.css @@ -74,6 +74,12 @@ a:hover, a:visited { } /* @section body */ + +.has-leftbar #wiki-body { + float: right; + clear: right; +} + #wiki-body { display: block; float: left; @@ -83,7 +89,7 @@ a:hover, a:visited { width: 100%; } -.has-rightbar #wiki-body { +.has-sidebar #wiki-body { width: 68%; } @@ -93,7 +99,7 @@ a:hover, a:visited { border: 1px solid #DDD; font-size: 13px; padding: 0px 5px; - float:left; + float: left; margin-bottom: 20px; min-width: 33%; @@ -105,12 +111,19 @@ a:hover, a:visited { border: none; } -/* @section rightbar */ -#wiki-rightbar { +/* @section sidebar */ +.has-leftbar #wiki-sidebar { + float: left; +} + +.has-rightbar #wiki-sidebar { + float: right; +} + +#wiki-sidebar { background-color: #f7f7f7; border: 1px solid #ddd; font-size: 13px; - float: right; padding: 7px; width: 25%; color: #555; @@ -120,15 +133,15 @@ a:hover, a:visited { -webkit-border-radius: 0.5em; } -#wiki-rightbar p { +#wiki-sidebar p { margin: 13px 0 0; } -#wiki-rightbar > p:first-child { +#wiki-sidebar > p:first-child { margin-top: 10px; } -#wiki-rightbar p.parent { +#wiki-sidebar p.parent { border-bottom: 1px solid #bbb; font-weight: bold; margin: 0 0 0.5em 0; @@ -137,7 +150,7 @@ a:hover, a:visited { } /* Back arrow */ -#wiki-rightbar p.parent:before { +#wiki-sidebar p.parent:before { color: #666; content: "← "; } @@ -149,7 +162,7 @@ a:hover, a:visited { margin: 2em 0 5em; } -.has-rightbar #wiki-footer { +.has-sidebar #wiki-footer { width: 70%; } diff --git a/lib/gollum/frontend/templates/create.mustache b/lib/gollum/frontend/templates/create.mustache index ba3d981d..a6a805dd 100644 --- a/lib/gollum/frontend/templates/create.mustache +++ b/lib/gollum/frontend/templates/create.mustache @@ -3,7 +3,7 @@

Create New Page

-
+
{{>editor}}
diff --git a/lib/gollum/frontend/templates/page.mustache b/lib/gollum/frontend/templates/page.mustache index 709bfce1..db66cfd6 100644 --- a/lib/gollum/frontend/templates/page.mustache +++ b/lib/gollum/frontend/templates/page.mustache @@ -31,14 +31,14 @@ Mousetrap.bind(['e'], function( e ) {
-
+
{{#has_toc}}
{{{toc_content}}}
{{/has_toc}} {{#has_sidebar}} -
+
diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index 1cd6409e..95ded0a6 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -64,6 +64,10 @@ module Precious def footer_format has_footer && @footer.format.to_s end + + def bar_side + @bar_side.to_s + end def has_sidebar @sidebar = (@page.sidebar || false) if @sidebar.nil? diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 4f2337c9..9215680b 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -147,6 +147,9 @@ module Gollum # Gets the custom index page for / and subdirs (e.g. foo/) attr_reader :index_page + + # Gets side on which the sidebar should be shown + attr_reader :bar_side # Public: Initialize a new Gollum Repo. # @@ -176,6 +179,9 @@ module Gollum # page title. # :index_page - The default page to retrieve or create if the # a directory is accessed. + # :bar_side - Where the sidebar should be displayed, may be: + # - :left + # - :right # # Returns a fresh Gollum::Repo. def initialize(path, options = {}) @@ -212,6 +218,7 @@ module Gollum @css = options.fetch :css, false @h1_title = options.fetch :h1_title, false @index_page = options.fetch :index_page, 'Home' + @bar_side = options.fetch :sidebar, :right @user_icons = ['gravatar', 'identicon'].include?( options[:user_icons] ) ? options[:user_icons] : 'none' end