Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fda5bcf3f6 | |||
| 01005fdccf | |||
| 95d35d38da | |||
| 81c90e55a7 | |||
| 3f0b61081b | |||
| ecc317886a |
@@ -30,7 +30,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby: [2.6, 2.7, 3.0]
|
ruby: ['2.6', '2.7', '3.0', '3.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'date'
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
#
|
#
|
||||||
@@ -38,14 +37,6 @@ def bump_version
|
|||||||
new_version
|
new_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def date
|
|
||||||
Date.today.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
def rubyforge_project
|
|
||||||
name
|
|
||||||
end
|
|
||||||
|
|
||||||
def gemspec_file
|
def gemspec_file
|
||||||
"#{name}.gemspec"
|
"#{name}.gemspec"
|
||||||
end
|
end
|
||||||
@@ -143,12 +134,9 @@ task :gemspec => :validate do
|
|||||||
spec = File.read(gemspec_file)
|
spec = File.read(gemspec_file)
|
||||||
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
||||||
|
|
||||||
# replace name version and date
|
# replace name and version
|
||||||
replace_header(head, :name)
|
replace_header(head, :name)
|
||||||
replace_header(head, :version)
|
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
|
# determine file list from git ls-files
|
||||||
files = `git ls-files`.
|
files = `git ls-files`.
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
Gem::Specification.new do |s|
|
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.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.required_ruby_version = '>= 2.6'
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '5.2.3'
|
s.version = '5.2.3'
|
||||||
s.date = '2021-04-18'
|
|
||||||
s.license = 'MIT'
|
s.license = 'MIT'
|
||||||
|
|
||||||
s.summary = 'A simple, Git-powered wiki.'
|
s.summary = 'A simple, Git-powered wiki.'
|
||||||
|
|||||||
+3
-2
@@ -29,9 +29,10 @@ module Gollum
|
|||||||
@@filters[pattern] = replacement
|
@@filters[pattern] = replacement
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.apply_filters(data)
|
def self.apply_filters(wiki_page, data)
|
||||||
@@filters.each do |pattern, replacement|
|
@@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
|
end
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-3
@@ -368,7 +368,7 @@ module Precious
|
|||||||
@name = wikip.name
|
@name = wikip.name
|
||||||
@ext = wikip.ext
|
@ext = wikip.ext
|
||||||
@path = wikip.path
|
@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
|
@allow_uploads = wikip.wiki.allow_uploads
|
||||||
@upload_dest = find_upload_dest(wikip.fullpath)
|
@upload_dest = find_upload_dest(wikip.fullpath)
|
||||||
|
|
||||||
@@ -660,9 +660,9 @@ module Precious
|
|||||||
end
|
end
|
||||||
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 = 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
|
end
|
||||||
|
|
||||||
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
|
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 })
|
Precious::App.set(:wiki_options, { :template_page => false })
|
||||||
end
|
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
|
test "edit returns nil for non-existant page" do
|
||||||
# post '/edit' fails. post '/edit/' works.
|
# post '/edit' fails. post '/edit/' works.
|
||||||
page = 'not-real-page'
|
page = 'not-real-page'
|
||||||
|
|||||||
+47
-49
@@ -25,62 +25,60 @@ def load_script(**args)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless ENV['CI']
|
context '4.x -> 5.x tag migrator' do
|
||||||
context '4.x -> 5.x tag migrator' do
|
include Rack::Test::Methods
|
||||||
include Rack::Test::Methods
|
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
@path = cloned_testpath("examples/lotr_migration.git")
|
@path = cloned_testpath("examples/lotr_migration.git")
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'repair broken links' do
|
test 'repair broken links' do
|
||||||
# The original contents of Subdir/Foo.md:
|
# The original contents of Subdir/Foo.md:
|
||||||
#
|
#
|
||||||
# waa
|
# waa
|
||||||
# [[Samwi]]
|
# [[Samwi]]
|
||||||
# [[samwise gamgee.mediaWiki]]
|
# [[samwise gamgee.mediaWiki]]
|
||||||
# [[Samwise Gamgee.mediawiki]]
|
# [[Samwise Gamgee.mediawiki]]
|
||||||
# [[Samwise Gamgee]]
|
# [[Samwise Gamgee]]
|
||||||
# [[Test|Samwise Gamgee#Anchor]]
|
# [[Test|Samwise Gamgee#Anchor]]
|
||||||
# [[Waaa|Test]]
|
# [[Waaa|Test]]
|
||||||
# [[Zaa]]
|
# [[Zaa]]
|
||||||
#
|
#
|
||||||
# The contents will be updated after running the migration script.
|
# The contents will be updated after running the migration script.
|
||||||
load_script
|
load_script
|
||||||
|
|
||||||
file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||||
assert_equal <<~FILE_CONTENTS, file.read
|
assert_equal <<~FILE_CONTENTS, file.read
|
||||||
waa
|
waa
|
||||||
[[Samwi]]
|
[[Samwi]]
|
||||||
[[/Samwise Gamgee.mediawiki]]
|
[[/Samwise Gamgee.mediawiki]]
|
||||||
[[/Samwise Gamgee.mediawiki]]
|
[[/Samwise Gamgee.mediawiki]]
|
||||||
[[/Samwise Gamgee.md]]
|
[[/Samwise Gamgee.md]]
|
||||||
[[Test|/Samwise Gamgee.md#Anchor]]
|
[[Test|/Samwise Gamgee.md#Anchor]]
|
||||||
[[Waaa|/Bar/Test.md]]
|
[[Waaa|/Bar/Test.md]]
|
||||||
[[Subsub/Zaa.md]]
|
[[Subsub/Zaa.md]]
|
||||||
FILE_CONTENTS
|
FILE_CONTENTS
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'change spaced filenames to hyphenated filenames' do
|
test 'change spaced filenames to hyphenated filenames' do
|
||||||
load_script(hyphenate: true)
|
load_script(hyphenate: true)
|
||||||
|
|
||||||
f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
|
f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
|
||||||
output = f.read
|
output = f.read
|
||||||
assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
|
assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
|
||||||
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
|
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'migration with page file dir' do
|
test 'migration with page file dir' do
|
||||||
load_script(page_file_dir: 'Subdir')
|
load_script(page_file_dir: 'Subdir')
|
||||||
|
|
||||||
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||||
output = f.read
|
output = f.read
|
||||||
assert_equal true, output.include?('[[Subsub/Zaa.md]]')
|
assert_equal true, output.include?('[[Subsub/Zaa.md]]')
|
||||||
assert_equal true, output.include?('[[Samwi]]')
|
assert_equal true, output.include?('[[Samwi]]')
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm_rf(@path)
|
FileUtils.rm_rf(@path)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user