lib/gollum/frontend/app.rb in gollum-2.4.0 vs lib/gollum/frontend/app.rb in gollum-2.4.1
- old
+ new
@@ -83,10 +83,11 @@
before do
@base_url = url('/', false).chomp('/')
# above will detect base_path when it's used with map in a config.ru
settings.wiki_options.merge!({ :base_path => @base_url })
+ @css = settings.wiki_options[:css]
end
get '/' do
redirect ::File.join(@base_url, 'Home')
end
@@ -194,16 +195,14 @@
# ensure pages are created in page_file_dir
page_dir = settings.wiki_options[:page_file_dir].to_s
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
- # write_page is not directory aware so use wiki_options to emulate dir support.
- wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
- wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
+ wiki = wiki_new
begin
- wiki.write_page(name, format, params[:content], commit_message)
+ wiki.write_page(name, format, params[:content], commit_message, path)
redirect to("/#{clean_url(::File.join(path,name))}")
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
mustache :error
end
@@ -236,11 +235,10 @@
@name = params[:page] || "Preview"
@page = wiki.preview_page(@name, params[:content], params[:format])
@content = @page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
- @css = wiki.css
@h1_title = wiki.h1_title
@editable = false
mustache :page
end
@@ -282,14 +280,10 @@
diffs = wiki.repo.diff(@versions.first, @versions.last, @page.path)
@diff = diffs.first
mustache :compare
end
- get %r{^/(javascript|css|images)} do
- halt 404
- end
-
get %r{/(.+?)/([0-9a-f]{40})} do
file_path = params[:captures][0]
version = params[:captures][1]
wikip = wiki_page(file_path, file_path, version)
name = wikip.name
@@ -360,10 +354,9 @@
@name = name
@editable = true
@content = page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
- @css = wiki.css
@h1_title = wiki.h1_title
mustache :page
elsif file = wiki.file(fullpath)
content_type file.mime_type
file.raw_data