From 8b6b0699e5c0d6f297556f020b4ef3b29970bf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Budzy=C5=84ski?= Date: Fri, 31 Jan 2014 02:43:03 +0100 Subject: [PATCH] fixes crash when selected "history" in preview of page being created - history button is hidden in newly created page preview as it makes no sense - redirect to '/' if page does not exist yet --- lib/gollum/app.rb | 9 +++++++-- lib/gollum/templates/page.mustache | 3 +++ lib/gollum/views/page.rb | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 40631fce..a15c39f5 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -341,8 +341,12 @@ module Precious get '/history/*' do @page = wiki_page(params[:splat].first).page @page_num = [params[:page].to_i, 1].max - @versions = @page.versions :page => @page_num - mustache :history + unless @page.nil? + @versions = @page.versions :page => @page_num + mustache :history + else + redirect to("/") + end end post '/compare/*' do @@ -454,6 +458,7 @@ module Precious # Extensions and layout data @editable = true + @page_exists = !page.versions.empty? @toc_content = wiki.universal_toc ? @page.toc_data : nil @mathjax = wiki.mathjax @h1_title = wiki.h1_title diff --git a/lib/gollum/templates/page.mustache b/lib/gollum/templates/page.mustache index a88643fb..d7b7a53a 100644 --- a/lib/gollum/templates/page.mustache +++ b/lib/gollum/templates/page.mustache @@ -30,8 +30,11 @@ Mousetrap.bind(['e'], function( e ) {
  • Edit
  • {{/editable}} + {{#page_exists}} +
  • History
  • + {{/page_exists}}
    diff --git a/lib/gollum/views/page.rb b/lib/gollum/views/page.rb index 7d33e258..90d7a5a1 100644 --- a/lib/gollum/views/page.rb +++ b/lib/gollum/views/page.rb @@ -43,6 +43,10 @@ module Precious @editable end + def page_exists + @page_exists + end + def allow_uploads @allow_uploads end