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
This commit is contained in:
+7
-2
@@ -341,8 +341,12 @@ module Precious
|
|||||||
get '/history/*' do
|
get '/history/*' do
|
||||||
@page = wiki_page(params[:splat].first).page
|
@page = wiki_page(params[:splat].first).page
|
||||||
@page_num = [params[:page].to_i, 1].max
|
@page_num = [params[:page].to_i, 1].max
|
||||||
@versions = @page.versions :page => @page_num
|
unless @page.nil?
|
||||||
mustache :history
|
@versions = @page.versions :page => @page_num
|
||||||
|
mustache :history
|
||||||
|
else
|
||||||
|
redirect to("/")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/compare/*' do
|
post '/compare/*' do
|
||||||
@@ -454,6 +458,7 @@ module Precious
|
|||||||
|
|
||||||
# Extensions and layout data
|
# Extensions and layout data
|
||||||
@editable = true
|
@editable = true
|
||||||
|
@page_exists = !page.versions.empty?
|
||||||
@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
|
||||||
|
|||||||
@@ -30,8 +30,11 @@ Mousetrap.bind(['e'], function( e ) {
|
|||||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
||||||
class="action-edit-page">Edit</a></li>
|
class="action-edit-page">Edit</a></li>
|
||||||
{{/editable}}
|
{{/editable}}
|
||||||
|
{{#page_exists}}
|
||||||
|
<li class="minibutton jaws">
|
||||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||||
class="action-page-history">History</a></li>
|
class="action-page-history">History</a></li>
|
||||||
|
{{/page_exists}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="wiki-content">
|
<div id="wiki-content">
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ module Precious
|
|||||||
@editable
|
@editable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def page_exists
|
||||||
|
@page_exists
|
||||||
|
end
|
||||||
|
|
||||||
def allow_uploads
|
def allow_uploads
|
||||||
@allow_uploads
|
@allow_uploads
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user