Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d8ebba114f | |||
| b9d7375dba | |||
| 676811206d | |||
| ff1baf0036 | |||
| 3d12aeb8b2 | |||
| 5a8750a975 | |||
| 0cb303f09f | |||
| edc7d0b50b | |||
| 2c268a9f8c | |||
| d61a09d421 |
@@ -17,7 +17,7 @@ Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a gi
|
||||
* May be written in a variety of [markups](#markups).
|
||||
* Can be edited with your favourite system editor or IDE (changes will be visible after committing) or with the built-in web interface.
|
||||
* Can be displayed in all versions, reverted, etc.
|
||||
* Gollum strives to be compatible with GitHub wikis (see `--hyphened-tag-lookup`)
|
||||
* Gollum strives to be compatible with GitHub wikis (see `--lenient-tag-lookup`)
|
||||
* Gollum supports advanced functionality like:
|
||||
* [UML diagrams](https://github.com/gollum/gollum/wiki#plantuml-diagrams)
|
||||
* [BibTeX and Citation support](https://github.com/gollum/gollum/wiki/BibTeX-and-Citations)
|
||||
|
||||
+2
-23
@@ -172,6 +172,7 @@ MSG
|
||||
end
|
||||
opts.on('--version', 'Display the current version of Gollum.') do
|
||||
puts 'Gollum ' + Gollum::VERSION
|
||||
exit 0
|
||||
end
|
||||
opts.on('--versions', 'Display the current version of Gollum and auxiliary gems.') do
|
||||
require 'gollum-lib'
|
||||
@@ -286,29 +287,7 @@ else
|
||||
else
|
||||
require 'rack'
|
||||
|
||||
class MapGollum
|
||||
def initialize(base_path)
|
||||
@mg = Rack::Builder.new do
|
||||
|
||||
map "/#{base_path}" do
|
||||
run Precious::App
|
||||
end
|
||||
map '/' do
|
||||
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
|
||||
end
|
||||
map '/*' do
|
||||
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@mg.call(env)
|
||||
end
|
||||
end
|
||||
|
||||
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
|
||||
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
|
||||
Rack::Server.new(:app => Precious::MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,6 @@ require 'optparse'
|
||||
require 'pathname'
|
||||
require 'rubygems'
|
||||
|
||||
REPO = ARGV[0] || Dir.pwd
|
||||
|
||||
wiki_options = {}
|
||||
options = {}
|
||||
|
||||
@@ -83,12 +81,15 @@ begin
|
||||
const = setting.to_s.upcase
|
||||
Object.const_set(const, value) unless Object.const_defined?(const)
|
||||
end
|
||||
wiki_options[:page_file_dir] = setting(:page_file_dir) ? setting(:page_file_dir) : wiki_options[:page_file_dir] # Allow settings :page_file_dir through PAGE_FILE_DIR constant.
|
||||
rescue OptionParser::InvalidOption
|
||||
puts "gollum-migrate-tags: #{$!.message}"
|
||||
puts "gollum-migrate-tags: try 'gollum-migrate-tags --help' for more information"
|
||||
exit
|
||||
end
|
||||
|
||||
REPO = ARGV[0] || Dir.pwd
|
||||
|
||||
require 'gollum-lib'
|
||||
|
||||
if cfg = options[:config]
|
||||
@@ -261,7 +262,7 @@ wiki.pages.each do |page|
|
||||
log(:info,"Page #{page.path}")
|
||||
new_data = page.formatted_data
|
||||
if setting(:no_dry_run)
|
||||
path = ::File.join([wiki.path, wiki.page_file_dir, page.path].compact)
|
||||
path = ::File.join(wiki.path, page.path)
|
||||
f = File.new(path, 'w')
|
||||
f.write(new_data)
|
||||
f.close
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = '>= 1.9'
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '5.0.0'
|
||||
s.date = '2020-03-30'
|
||||
s.version = '5.0.1'
|
||||
s.date = '2020-04-04'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.summary = 'A simple, Git-powered wiki.'
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
|
||||
require File.expand_path('../gollum/uri_encode_component', __FILE__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '5.0.0'
|
||||
VERSION = '5.0.1'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
||||
|
||||
+30
-5
@@ -40,6 +40,30 @@ Gollum::set_git_max_filesize(190 * 10**6)
|
||||
# See the wiki.rb file for more details on wiki options
|
||||
|
||||
module Precious
|
||||
|
||||
# For use with the --base-path option.
|
||||
class MapGollum
|
||||
def initialize(base_path)
|
||||
@mg = Rack::Builder.new do
|
||||
|
||||
map "/#{base_path}" do
|
||||
run Precious::App
|
||||
end
|
||||
map '/' do
|
||||
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
|
||||
end
|
||||
map '/*' do
|
||||
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@mg.call(env)
|
||||
end
|
||||
end
|
||||
|
||||
class App < Sinatra::Base
|
||||
register Mustache::Sinatra
|
||||
register Sinatra::Namespace
|
||||
@@ -188,7 +212,8 @@ module Precious
|
||||
@etag = page.sha
|
||||
mustache :edit
|
||||
else
|
||||
redirect_to("/create/#{encodeURIComponent(@name)}")
|
||||
path = ::File.join('gollum/create', @path, @name)
|
||||
redirect to(clean_url(encodeURIComponent(path)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -413,8 +438,8 @@ module Precious
|
||||
@page = wikip.page
|
||||
@page_num = [params[:page_num].to_i, 1].max
|
||||
@max_count = settings.wiki_options.fetch(:pagination_count, 10)
|
||||
@wiki = @page.wiki
|
||||
unless @page.nil?
|
||||
@wiki = @page.wiki
|
||||
@versions = @page.versions(
|
||||
per_page: @max_count,
|
||||
page_num: @page_num,
|
||||
@@ -435,12 +460,12 @@ module Precious
|
||||
end
|
||||
|
||||
post '/compare/*' do
|
||||
@file = encodeURIComponent(params[:splat].first)
|
||||
@file = clean_url(encodeURIComponent(params[:splat].first))
|
||||
@versions = params[:versions] || []
|
||||
if @versions.size < 2
|
||||
redirect_to("/history/#{@file}")
|
||||
redirect to("gollum/history/#{@file}")
|
||||
else
|
||||
redirect_to("/compare/%s/%s...%s" % [
|
||||
redirect to("gollum/compare/%s/%s...%s" % [
|
||||
@file,
|
||||
@versions.last,
|
||||
@versions.first]
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
{{#mathjax_config}}
|
||||
<script type="text/javascript" src="{{base_url}}/{{mathjax_config}}"></script>
|
||||
{{/mathjax_config}}
|
||||
<script defer src="{{base_path}}/gollum/assets/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script defer src="{{base_url}}/gollum/assets/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
{{/mathjax}}
|
||||
{{#js}}<script type="text/javascript" src="{{custom_path}}/custom.js"></script>{{/js}}
|
||||
|
||||
|
||||
+83
-9
@@ -478,15 +478,6 @@ EOF
|
||||
assert last_response.ok?
|
||||
assert last_response.body.include?('Samewise Gamgee</h1>')
|
||||
end
|
||||
|
||||
test "previews content on the first page of an empty wiki" do
|
||||
@path = cloned_testpath("examples/empty.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {})
|
||||
post "/gollum/preview", :content => 'abc', :format => 'markdown'
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test 'throws an error when comparing two identical revisions for a page' do
|
||||
get '/gollum/compare/A.md/fc66539528eb96f21b2bbdbf557788fe8a1196ac...fc66539528eb96f21b2bbdbf557788fe8a1196ac'
|
||||
@@ -656,6 +647,14 @@ EOF
|
||||
assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body
|
||||
end
|
||||
|
||||
test 'history/NO-EXIST redirects to Home' do
|
||||
get '/gollum/history/NO-EXIST'
|
||||
follow_redirect!
|
||||
assert_equal last_request.fullpath, '/'
|
||||
# redirect again from / to /Home
|
||||
assert_equal last_response.status, 302
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
@@ -898,3 +897,78 @@ context "Frontend with page-file-dir" do
|
||||
Precious::App
|
||||
end
|
||||
end
|
||||
|
||||
context "Frontend with empty repo" do
|
||||
include Rack::Test::Methods
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/empty.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {allow_editing: true})
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
|
||||
test 'previews content on the first page of an empty wiki' do
|
||||
post '/gollum/preview', :content => 'abc', :format => 'markdown'
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test 'wiki redirects to create page with newly initialized repo' do
|
||||
get '/Home'
|
||||
follow_redirect!
|
||||
assert_equal '/gollum/create/Home', last_request.fullpath
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'Frontend with base path' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
@base_path = 'wiki'
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {base_path: @base_path, mathjax: true})
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
test 'page with base path' do
|
||||
get '/wiki/Home'
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test 'base path mathjax assets' do
|
||||
get '/wiki/Home'
|
||||
assert last_response.ok?
|
||||
assert last_response.body.include?('<script defer src="/wiki/gollum/assets/mathjax/MathJax.js')
|
||||
end
|
||||
|
||||
test 'compare view' do
|
||||
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => ['f25eccd98e9b667f9e22946f3e2f945378b8a72d', '5bc1aaec6149e854078f1d0f8b71933bbc6c2e43']
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/5bc1aaec6149e854078f1d0f8b71933bbc6c2e43...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
|
||||
|
||||
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => ['f25eccd98e9b667f9e22946f3e2f945378b8a72d']
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::MapGollum.new(@base_path)
|
||||
end
|
||||
end
|
||||
+33
-18
@@ -23,7 +23,26 @@ waa
|
||||
[[Subsub/Zaa.md]]
|
||||
EOF
|
||||
|
||||
script_path = File.expand_path(File.join(File.dirname(__FILE__), '../', 'bin', 'gollum-migrate-tags'))
|
||||
def load_script(**args)
|
||||
settings = {
|
||||
:run_silent => true,
|
||||
:no_dry_run => true,
|
||||
:prefer_relative => true,
|
||||
:hyphenate => false,
|
||||
:page_file_dir => nil,
|
||||
}.merge(args)
|
||||
|
||||
settings.each do |const, val|
|
||||
const_name = const.to_s.upcase
|
||||
Object.const_set(const_name, val) unless Object.const_defined?(const_name) && Object.const_get(const_name) == val
|
||||
end
|
||||
|
||||
script_path = File.expand_path(File.join(File.dirname(__FILE__), '../', 'bin', 'gollum-migrate-tags'))
|
||||
|
||||
Dir.chdir(@path) do
|
||||
load script_path
|
||||
end
|
||||
end
|
||||
|
||||
unless ENV['TRAVIS']
|
||||
|
||||
@@ -35,33 +54,29 @@ unless ENV['TRAVIS']
|
||||
end
|
||||
|
||||
test 'repair broken links' do
|
||||
PREFER_RELATIVE = true
|
||||
RUN_SILENT = true
|
||||
NO_DRY_RUN = true
|
||||
HYPHENATE = false
|
||||
|
||||
Dir.chdir(@path) do
|
||||
load script_path
|
||||
end
|
||||
load_script
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
assert_equal result, f.read
|
||||
end
|
||||
|
||||
test 'change spaced filenames to hyphenated filenames' do
|
||||
RUN_SILENT = true
|
||||
NO_DRY_RUN = true
|
||||
PREFER_RELATIVE = true
|
||||
HYPHENATE = true
|
||||
|
||||
Dir.chdir(@path) do
|
||||
load script_path
|
||||
end
|
||||
test 'change spaced filenames to hyphenated filenames' do
|
||||
load_script(hyphenate: true)
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
|
||||
output = f.read
|
||||
assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
|
||||
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
|
||||
end
|
||||
|
||||
test 'migration with page file dir' do
|
||||
load_script(page_file_dir: 'Subdir')
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
output = f.read
|
||||
assert_equal true, output.include?('[[Subsub/Zaa.md]]')
|
||||
assert_equal true, output.include?('[[Samwi]]')
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
|
||||
Reference in New Issue
Block a user