Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fda5bcf3f6 | |||
| 01005fdccf | |||
| 95d35d38da | |||
| 81c90e55a7 | |||
| 3f0b61081b | |||
| ecc317886a |
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
ruby: [2.6, 2.7, 3.0]
|
||||
ruby: ['2.6', '2.7', '3.0', '3.1']
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'date'
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
@@ -38,14 +37,6 @@ def bump_version
|
||||
new_version
|
||||
end
|
||||
|
||||
def date
|
||||
Date.today.to_s
|
||||
end
|
||||
|
||||
def rubyforge_project
|
||||
name
|
||||
end
|
||||
|
||||
def gemspec_file
|
||||
"#{name}.gemspec"
|
||||
end
|
||||
@@ -143,12 +134,9 @@ task :gemspec => :validate do
|
||||
spec = File.read(gemspec_file)
|
||||
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
||||
|
||||
# replace name version and date
|
||||
# replace name and version
|
||||
replace_header(head, :name)
|
||||
replace_header(head, :version)
|
||||
replace_header(head, :date)
|
||||
#comment this out if your rubyforge_project has a different name
|
||||
replace_header(head, :rubyforge_project)
|
||||
|
||||
# determine file list from git ls-files
|
||||
files = `git ls-files`.
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.specification_version = 2 if s.respond_to? :specification_version=
|
||||
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
||||
s.rubygems_version = '1.3.5'
|
||||
s.required_ruby_version = '>= 2.6'
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '5.2.3'
|
||||
s.date = '2021-04-18'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.summary = 'A simple, Git-powered wiki.'
|
||||
|
||||
+3
-2
@@ -29,9 +29,10 @@ module Gollum
|
||||
@@filters[pattern] = replacement
|
||||
end
|
||||
|
||||
def self.apply_filters(data)
|
||||
def self.apply_filters(wiki_page, data)
|
||||
@@filters.each do |pattern, replacement|
|
||||
data.gsub!(pattern, replacement.call)
|
||||
params = replacement.parameters.length == 0 ? nil : wiki_page
|
||||
data.gsub!(pattern, replacement.call(*params))
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
+3
-3
@@ -368,7 +368,7 @@ module Precious
|
||||
@name = wikip.name
|
||||
@ext = wikip.ext
|
||||
@path = wikip.path
|
||||
@template_page = load_template(@path) if settings.wiki_options[:template_page]
|
||||
@template_page = load_template(wikip, @path) if settings.wiki_options[:template_page]
|
||||
@allow_uploads = wikip.wiki.allow_uploads
|
||||
@upload_dest = find_upload_dest(wikip.fullpath)
|
||||
|
||||
@@ -660,9 +660,9 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
def load_template(path)
|
||||
def load_template(wiki_page, path)
|
||||
template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page
|
||||
template_page ? Gollum::TemplateFilter.apply_filters(template_page.text_data) : nil
|
||||
template_page ? Gollum::TemplateFilter.apply_filters(wiki_page, template_page.text_data) : nil
|
||||
end
|
||||
|
||||
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
|
||||
|
||||
@@ -344,6 +344,45 @@ EOF
|
||||
Precious::App.set(:wiki_options, { :template_page => false })
|
||||
end
|
||||
|
||||
test "create with template filter without parameter" do
|
||||
Precious::App.set(:wiki_options, { :template_page => true })
|
||||
|
||||
# arrange
|
||||
now = Time.parse('2022-04-16')
|
||||
Gollum::TemplateFilter.add_filter("{{today}}", & -> () { now.strftime("%Y-%m-%d") })
|
||||
template_content = "# Daily Log, {{today}}"
|
||||
|
||||
@wiki.write_page("daily-logs/_Template",
|
||||
:markdown,
|
||||
template_content)
|
||||
# act
|
||||
get "/gollum/create/daily-logs/test"
|
||||
# assert
|
||||
assert last_response.ok?
|
||||
assert_match("# Daily Log, 2022-04-16", last_response.body)
|
||||
|
||||
Precious::App.set(:wiki_options, { :template_page => false })
|
||||
end
|
||||
|
||||
test "create with template filter with parameter" do
|
||||
Precious::App.set(:wiki_options, { :template_page => true })
|
||||
|
||||
# arrange
|
||||
Gollum::TemplateFilter.add_filter("{{page_name}}", & -> (page) { page.name })
|
||||
template_content = "# Daily Log, {{page_name}}"
|
||||
|
||||
@wiki.write_page("daily-logs/_Template",
|
||||
:markdown,
|
||||
template_content)
|
||||
# act
|
||||
get "/gollum/create/daily-logs/2022-04-16"
|
||||
# assert
|
||||
assert last_response.ok?
|
||||
assert_match("# Daily Log, 2022-04-16", last_response.body)
|
||||
|
||||
Precious::App.set(:wiki_options, { :template_page => false })
|
||||
end
|
||||
|
||||
test "edit returns nil for non-existant page" do
|
||||
# post '/edit' fails. post '/edit/' works.
|
||||
page = 'not-real-page'
|
||||
|
||||
+47
-49
@@ -25,62 +25,60 @@ def load_script(**args)
|
||||
end
|
||||
end
|
||||
|
||||
unless ENV['CI']
|
||||
context '4.x -> 5.x tag migrator' do
|
||||
include Rack::Test::Methods
|
||||
context '4.x -> 5.x tag migrator' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr_migration.git")
|
||||
end
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr_migration.git")
|
||||
end
|
||||
|
||||
test 'repair broken links' do
|
||||
# The original contents of Subdir/Foo.md:
|
||||
#
|
||||
# waa
|
||||
# [[Samwi]]
|
||||
# [[samwise gamgee.mediaWiki]]
|
||||
# [[Samwise Gamgee.mediawiki]]
|
||||
# [[Samwise Gamgee]]
|
||||
# [[Test|Samwise Gamgee#Anchor]]
|
||||
# [[Waaa|Test]]
|
||||
# [[Zaa]]
|
||||
#
|
||||
# The contents will be updated after running the migration script.
|
||||
load_script
|
||||
test 'repair broken links' do
|
||||
# The original contents of Subdir/Foo.md:
|
||||
#
|
||||
# waa
|
||||
# [[Samwi]]
|
||||
# [[samwise gamgee.mediaWiki]]
|
||||
# [[Samwise Gamgee.mediawiki]]
|
||||
# [[Samwise Gamgee]]
|
||||
# [[Test|Samwise Gamgee#Anchor]]
|
||||
# [[Waaa|Test]]
|
||||
# [[Zaa]]
|
||||
#
|
||||
# The contents will be updated after running the migration script.
|
||||
load_script
|
||||
|
||||
file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
assert_equal <<~FILE_CONTENTS, file.read
|
||||
waa
|
||||
[[Samwi]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.md]]
|
||||
[[Test|/Samwise Gamgee.md#Anchor]]
|
||||
[[Waaa|/Bar/Test.md]]
|
||||
[[Subsub/Zaa.md]]
|
||||
FILE_CONTENTS
|
||||
end
|
||||
file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
assert_equal <<~FILE_CONTENTS, file.read
|
||||
waa
|
||||
[[Samwi]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.md]]
|
||||
[[Test|/Samwise Gamgee.md#Anchor]]
|
||||
[[Waaa|/Bar/Test.md]]
|
||||
[[Subsub/Zaa.md]]
|
||||
FILE_CONTENTS
|
||||
end
|
||||
|
||||
test 'change spaced filenames to hyphenated filenames' do
|
||||
load_script(hyphenate: true)
|
||||
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
|
||||
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')
|
||||
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
|
||||
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)
|
||||
end
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user