Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b952b6d56 | |||
| 90cc512bd1 | |||
| b82556c9c0 | |||
| fbe3b4bb3b | |||
| 5ffd98ad31 | |||
| cb9dd4d228 | |||
| cd823bf10c | |||
| 5560ec52c2 | |||
| 065151a77f |
@@ -413,6 +413,14 @@ By default, internal wiki links are all absolute from the root. To specify a dif
|
|||||||
|
|
||||||
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
||||||
|
|
||||||
|
Note that base_path just modifies the links. To map gollum to a non-root location, use `map` in config.ru. See [#532](https://github.com/github/gollum/issues/532).
|
||||||
|
|
||||||
|
> :base_path - String base path for all Wiki links.
|
||||||
|
>
|
||||||
|
> The String base path to prefix to internal links. For example, when set
|
||||||
|
> to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults
|
||||||
|
> to "/".
|
||||||
|
|
||||||
Get the latest version of the given human or canonical page name:
|
Get the latest version of the given human or canonical page name:
|
||||||
|
|
||||||
page = wiki.page('page-name')
|
page = wiki.page('page-name')
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.8.7"
|
s.required_ruby_version = ">= 1.8.7"
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '2.2.6'
|
s.version = '2.2.7'
|
||||||
s.date = '2012-10-14'
|
s.date = '2012-10-14'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
|||||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '2.2.6'
|
VERSION = '2.2.7'
|
||||||
|
|
||||||
def self.assets_path
|
def self.assets_path
|
||||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ module Precious
|
|||||||
end
|
end
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
redirect File.join(settings.wiki_options[:page_file_dir].to_s,settings.wiki_options[:base_path].to_s, 'Home')
|
||||||
end
|
end
|
||||||
|
|
||||||
# path is set to name if path is nil.
|
# path is set to name if path is nil.
|
||||||
@@ -145,6 +145,7 @@ module Precious
|
|||||||
page_name = CGI.unescape(params[:page])
|
page_name = CGI.unescape(params[:page])
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
page = wiki.paged(page_name, path, exact = true)
|
page = wiki.paged(page_name, path, exact = true)
|
||||||
|
return if page.nil?
|
||||||
rename = params[:rename].to_url if params[:rename]
|
rename = params[:rename].to_url if params[:rename]
|
||||||
name = rename || page.name
|
name = rename || page.name
|
||||||
committer = Gollum::Committer.new(wiki, commit_message)
|
committer = Gollum::Committer.new(wiki, commit_message)
|
||||||
@@ -190,13 +191,20 @@ module Precious
|
|||||||
path = '' if path.nil?
|
path = '' if path.nil?
|
||||||
format = params[:format].intern
|
format = params[:format].intern
|
||||||
|
|
||||||
|
page_dir = File.join(settings.wiki_options[:page_file_dir].to_s,
|
||||||
|
settings.wiki_options[:base_path].to_s)
|
||||||
|
# Home is a special case.
|
||||||
|
path = '' if name.downcase == 'home'
|
||||||
|
|
||||||
|
page_dir = File.join(page_dir, path)
|
||||||
|
|
||||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
# 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_options = settings.wiki_options.merge({ :page_file_dir => page_dir })
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
wiki.write_page(name, format, params[:content], commit_message)
|
wiki.write_page(name, format, params[:content], commit_message)
|
||||||
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
redirect to("/#{clean_url(CGI.escape(::File.join(page_dir,name)))}")
|
||||||
rescue Gollum::DuplicatePageError => e
|
rescue Gollum::DuplicatePageError => e
|
||||||
@message = "Duplicate page: #{e.message}"
|
@message = "Duplicate page: #{e.message}"
|
||||||
mustache :error
|
mustache :error
|
||||||
|
|||||||
+5
-1
@@ -184,7 +184,7 @@ context "Frontend" do
|
|||||||
name = "A"
|
name = "A"
|
||||||
post "/create", :content => 'abc', :page => name,
|
post "/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
follow_redirect!
|
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
@@ -273,6 +273,9 @@ context "Frontend" do
|
|||||||
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
||||||
get "/"
|
get "/"
|
||||||
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
||||||
|
|
||||||
|
# Reset base path
|
||||||
|
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||||
end
|
end
|
||||||
|
|
||||||
test "author details in session are used" do
|
test "author details in session are used" do
|
||||||
@@ -377,6 +380,7 @@ context "Frontend with lotr" do
|
|||||||
test "edit pages within sub-directories" do
|
test "edit pages within sub-directories" do
|
||||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
|
|
||||||
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
||||||
|
|
||||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||||
|
|||||||
Reference in New Issue
Block a user