Compare commits

...

2 Commits

6 changed files with 74 additions and 17 deletions
+1
View File
@@ -1212,6 +1212,7 @@ Gem::Specification.new do |s|
lib/gollum/templates/pagination.mustache lib/gollum/templates/pagination.mustache
lib/gollum/templates/search.mustache lib/gollum/templates/search.mustache
lib/gollum/templates/searchbar.mustache lib/gollum/templates/searchbar.mustache
lib/gollum/templates/user.mustache
lib/gollum/templates/wiki_content.mustache lib/gollum/templates/wiki_content.mustache
lib/gollum/uri_encode_component.rb lib/gollum/uri_encode_component.rb
lib/gollum/views/commit.rb lib/gollum/views/commit.rb
+40 -17
View File
@@ -211,7 +211,7 @@ module Precious
end end
get '/edit/*' do get '/edit/*' do
forbid unless @allow_editing forbid unless @allow_editing && @user_authed
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
@name = wikip.fullname @name = wikip.fullname
@path = wikip.path @path = wikip.path
@@ -234,6 +234,7 @@ module Precious
wiki = wiki_new wiki = wiki_new
halt 405 unless wiki.allow_uploads halt 405 unless wiki.allow_uploads
forbid unless @user_authed
if params[:file] if params[:file]
fullname = params[:file][:filename] fullname = params[:file][:filename]
@@ -290,6 +291,7 @@ module Precious
post '/rename/*' do post '/rename/*' do
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
halt 500 if wikip.nil? halt 500 if wikip.nil?
forbid unless @user_authed
wiki = wikip.wiki wiki = wikip.wiki
page = wikip.page page = wikip.page
rename = params[:rename] rename = params[:rename]
@@ -333,6 +335,7 @@ module Precious
path = "/#{clean_url(sanitize_empty_params(params[:path]))}" path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
wiki = wiki_new wiki = wiki_new
page = wiki.page(::File.join(path, params[:page])) page = wiki.page(::File.join(path, params[:page]))
forbid unless @user_authed
return if page.nil? return if page.nil?
if etag != page.sha if etag != page.sha
@@ -353,6 +356,7 @@ module Precious
post '/delete/*' do post '/delete/*' do
forbid unless @allow_editing forbid unless @allow_editing
forbid unless @user_authed
wiki = wiki_new wiki = wiki_new
filepath = params[:splat].first filepath = params[:splat].first
unless filepath.nil? unless filepath.nil?
@@ -364,6 +368,7 @@ module Precious
get '/create/*' do get '/create/*' do
forbid unless @allow_editing forbid unless @allow_editing
forbid unless @user_authed
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
@name = wikip.name @name = wikip.name
@ext = wikip.ext @ext = wikip.ext
@@ -389,6 +394,7 @@ module Precious
path = sanitize_empty_params(params[:path]) || '' path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern format = params[:format].intern
wiki = wiki_new wiki = wiki_new
forbid unless @user_authed
path.gsub!(/^\//, '') path.gsub!(/^\//, '')
@@ -554,6 +560,7 @@ module Precious
wiki = wiki_new wiki = wiki_new
@results = wiki.tree_list @results = wiki.tree_list
if path if path
@path = Pathname.new(path).cleanpath.to_s @path = Pathname.new(path).cleanpath.to_s
check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/" check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/"
@@ -618,28 +625,44 @@ module Precious
end end
end end
def show_page_or_file(fullpath) def folder_exists(path, wiki)
wiki = wiki_new paths = wiki.tree_list
if page = wiki.page(fullpath) return paths.any? { |item| item.path.start_with?(path) }
@page = page end
@name = page.filename_stripped
@content = page.formatted_data
@upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
# Extensions and layout data def show_page(page, fullpath, wiki)
@editable = true @page = page
@toc_content = wiki.universal_toc ? @page.toc_data : nil @name = page.filename_stripped
@h1_title = wiki.h1_title @content = page.formatted_data
@bar_side = wiki.bar_side @upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
@allow_uploads = wiki.allow_uploads
@navbar = true # Extensions and layout data
mustache :page @editable = true
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@h1_title = wiki.h1_title
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads
@navbar = true
return mustache :page
end
def show_page_or_file(fullpath)
wiki = wiki_new
if fullpath[-1] != '/' ? page = wiki.page(fullpath) : false
show_page(page, fullpath, wiki)
elsif page = wiki.page("#{fullpath}/#{wiki.index_page}")
show_page(page, fullpath, wiki)
elsif page = wiki.page("#{fullpath}/#{File.basename(fullpath)}")
show_page(page, fullpath, wiki)
elsif file = wiki.file(fullpath, wiki.ref, true) elsif file = wiki.file(fullpath, wiki.ref, true)
show_file(file) show_file(file)
elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath] elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath]
redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}") redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}")
elsif folder_exists(fullpath, wiki)
redirect to("/gollum/overview/#{clean_url(encodeURIComponent(fullpath))}")
else else
if @allow_editing if @allow_editing && @user_authed
path = fullpath[-1] == '/' ? "#{fullpath}#{wiki.index_page}" : fullpath # Append default index page if no page name is supplied path = fullpath[-1] == '/' ? "#{fullpath}#{wiki.index_page}" : fullpath # Append default index page if no page name is supplied
redirect to("/gollum/create/#{clean_url(encodeURIComponent(path))}") redirect to("/gollum/create/#{clean_url(encodeURIComponent(path))}")
else else
@@ -734,3 +734,12 @@ nav.actions {
display: none; display: none;
} }
} }
/* @section user */
#user p {
text-align: right;
padding-right:0.5em;
font-size: .8em;
line-height: 2.0em;
color: #999;
}
+1
View File
@@ -60,6 +60,7 @@
<body> <body>
<div class="container-lg clearfix"> <div class="container-lg clearfix">
{{{yield}}} {{{yield}}}
{{< user}}
</div> </div>
</body> </body>
</html> </html>
+10
View File
@@ -0,0 +1,10 @@
<div id="user">
<p>
{{#user_authed}}
{{user_name}} | {{user_provider}} | <strong><a href="/__omnigollum__/logout">[Logout]</a></strong>
{{/user_authed}}
{{^user_authed}}
not logged in | <strong><a href="/__omnigollum__/login">[Login]</a></strong>
{{/user_authed}}
<p>
</div>
+13
View File
@@ -87,6 +87,19 @@ module Precious
def latest_changes def latest_changes
false false
end end
# Passthrough additional omniauth parameters for status bar
def user_authed
@user_authed
end
def user_provider
@user.provider
end
def user_name
@user.name
end
end end
end end