caramelize 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +29 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +25 -13
- data/README.md +2 -3
- data/Rakefile +3 -1
- data/bin/caramelize +6 -5
- data/caramelize.gemspec +23 -19
- data/lib/caramelize/caramel.rb +26 -30
- data/lib/caramelize/content_transferer.rb +48 -29
- data/lib/caramelize/database_connector.rb +8 -8
- data/lib/caramelize/filter_processor.rb +2 -0
- data/lib/caramelize/filters/camel_case_to_wiki_links.rb +26 -0
- data/lib/caramelize/filters/remove_table_tab_line_endings.rb +3 -2
- data/lib/caramelize/filters/swap_wiki_links.rb +5 -3
- data/lib/caramelize/filters/wikka_to_markdown.rb +26 -20
- data/lib/caramelize/health_check.rb +6 -68
- data/lib/caramelize/health_checks/home_page_check.rb +23 -0
- data/lib/caramelize/health_checks/orphaned_pages_check.rb +56 -0
- data/lib/caramelize/health_checks/page.rb +28 -0
- data/lib/caramelize/input_wiki/redmine_wiki.rb +14 -13
- data/lib/caramelize/input_wiki/wiki.rb +8 -2
- data/lib/caramelize/input_wiki/wikkawiki.rb +22 -13
- data/lib/caramelize/output_wiki/gollum.rb +10 -10
- data/lib/caramelize/page.rb +13 -9
- data/lib/caramelize/services/page_builder.rb +11 -8
- data/lib/caramelize/version.rb +3 -1
- data/lib/caramelize.rb +5 -0
- data/spec/lib/caramelize/content_transferer_spec.rb +3 -1
- data/spec/lib/caramelize/filter_processor_spec.rb +5 -2
- data/spec/lib/caramelize/filters/add_newline_on_page_end_spec.rb +27 -0
- data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +44 -0
- data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +14 -9
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +16 -13
- data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +123 -58
- data/spec/lib/caramelize/input_wiki/wiki_spec.rb +15 -14
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +31 -31
- data/spec/lib/caramelize/page_spec.rb +34 -26
- data/spec/lib/caramelize/services/page_builder_spec.rb +41 -0
- data/spec/spec_helper.rb +4 -2
- metadata +48 -27
- data/.travis.yml +0 -5
- data/spec/lib/caramelize/services/page_builder.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb93f32560a4999584cc9e883655f867ed7f02bdffc4ef9a7088a5c44e68b29b
|
4
|
+
data.tar.gz: a3ae3187dc3a45c831daa833e991692f7c7108c8967da53efcafb2a4330dbadc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0da855d0680a06673e8ad2b98734ee8fe4d04063ebd40e5b5a3b37cd1f7446fd4ea10502e349dfc1e27787b8f395b976f870595e7622e1524a2504f9676000a4
|
7
|
+
data.tar.gz: 886e63abc962ee8e830d12efc632bd832000ca70951081e9cfb185fabba1f40711db6574ef2df40b2c8c946f5ae61ef06f51877a66288eef9f9ef431c4237937
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
Exclude:
|
8
|
+
- 'vendor/**/*'
|
9
|
+
- 'spec/fixtures/**/*'
|
10
|
+
- 'tmp/**/*'
|
11
|
+
- '.git/**/*'
|
12
|
+
- 'bin/*'
|
13
|
+
- '*.cmlz'
|
14
|
+
TargetRubyVersion: 3.1
|
15
|
+
SuggestExtensions: false
|
16
|
+
|
17
|
+
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
20
|
+
StyleGuide: http://relaxed.ruby.style/#styledocumentation
|
21
|
+
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Layout/LineLength:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
RSpec/NestedGroups:
|
29
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
caramelize (1.
|
4
|
+
caramelize (1.2.0)
|
5
5
|
commander
|
6
6
|
gollum-lib
|
7
7
|
mysql2
|
@@ -13,10 +13,10 @@ GEM
|
|
13
13
|
ast (2.4.2)
|
14
14
|
byebug (11.1.3)
|
15
15
|
coderay (1.1.3)
|
16
|
-
commander (
|
17
|
-
highline (~>
|
16
|
+
commander (5.0.0)
|
17
|
+
highline (~> 3.0.0)
|
18
18
|
crass (1.0.6)
|
19
|
-
diff-lcs (1.5.
|
19
|
+
diff-lcs (1.5.1)
|
20
20
|
ffi (1.16.3)
|
21
21
|
formatador (1.1.0)
|
22
22
|
gemojione (4.3.3)
|
@@ -47,7 +47,7 @@ GEM
|
|
47
47
|
guard (~> 2.1)
|
48
48
|
guard-compat (~> 1.1)
|
49
49
|
rspec (>= 2.99.0, < 4.0)
|
50
|
-
highline (
|
50
|
+
highline (3.0.1)
|
51
51
|
json (2.7.1)
|
52
52
|
language_server-protocol (3.17.0.3)
|
53
53
|
listen (3.8.0)
|
@@ -58,20 +58,20 @@ GEM
|
|
58
58
|
nokogiri (>= 1.12.0)
|
59
59
|
lumberjack (1.2.10)
|
60
60
|
method_source (1.0.0)
|
61
|
-
mime-types (3.5.
|
61
|
+
mime-types (3.5.2)
|
62
62
|
mime-types-data (~> 3.2015)
|
63
63
|
mime-types-data (3.2023.1205)
|
64
64
|
mini_portile2 (2.8.5)
|
65
65
|
mysql2 (0.5.5)
|
66
66
|
nenv (0.3.0)
|
67
|
-
nokogiri (1.
|
67
|
+
nokogiri (1.16.0)
|
68
68
|
mini_portile2 (~> 2.8.2)
|
69
69
|
racc (~> 1.4)
|
70
70
|
notiffany (0.1.3)
|
71
71
|
nenv (~> 0.1)
|
72
72
|
shellany (~> 0.0)
|
73
|
-
parallel (1.
|
74
|
-
parser (3.
|
73
|
+
parallel (1.24.0)
|
74
|
+
parser (3.3.0.5)
|
75
75
|
ast (~> 2.4.1)
|
76
76
|
racc
|
77
77
|
pry (0.14.2)
|
@@ -83,7 +83,7 @@ GEM
|
|
83
83
|
rb-fsevent (0.11.2)
|
84
84
|
rb-inotify (0.10.1)
|
85
85
|
ffi (~> 1.0)
|
86
|
-
regexp_parser (2.
|
86
|
+
regexp_parser (2.9.0)
|
87
87
|
rexml (3.2.6)
|
88
88
|
rouge (3.30.0)
|
89
89
|
rspec (3.12.0)
|
@@ -99,11 +99,11 @@ GEM
|
|
99
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
100
100
|
rspec-support (~> 3.12.0)
|
101
101
|
rspec-support (3.12.1)
|
102
|
-
rubocop (1.
|
102
|
+
rubocop (1.60.2)
|
103
103
|
json (~> 2.3)
|
104
104
|
language_server-protocol (>= 3.17.0)
|
105
105
|
parallel (~> 1.10)
|
106
|
-
parser (>= 3.
|
106
|
+
parser (>= 3.3.0.2)
|
107
107
|
rainbow (>= 2.2.2, < 4.0)
|
108
108
|
regexp_parser (>= 1.8, < 3.0)
|
109
109
|
rexml (>= 3.2.5, < 4.0)
|
@@ -112,6 +112,16 @@ GEM
|
|
112
112
|
unicode-display_width (>= 2.4.0, < 3.0)
|
113
113
|
rubocop-ast (1.30.0)
|
114
114
|
parser (>= 3.2.1.0)
|
115
|
+
rubocop-capybara (2.20.0)
|
116
|
+
rubocop (~> 1.41)
|
117
|
+
rubocop-factory_bot (2.25.1)
|
118
|
+
rubocop (~> 1.41)
|
119
|
+
rubocop-rake (0.6.0)
|
120
|
+
rubocop (~> 1.0)
|
121
|
+
rubocop-rspec (2.26.1)
|
122
|
+
rubocop (~> 1.40)
|
123
|
+
rubocop-capybara (~> 2.17)
|
124
|
+
rubocop-factory_bot (~> 2.22)
|
115
125
|
ruby-progressbar (1.13.0)
|
116
126
|
rugged (1.7.1)
|
117
127
|
shellany (0.0.1)
|
@@ -135,6 +145,8 @@ DEPENDENCIES
|
|
135
145
|
rake
|
136
146
|
rspec
|
137
147
|
rubocop
|
148
|
+
rubocop-rake
|
149
|
+
rubocop-rspec
|
138
150
|
|
139
151
|
BUNDLED WITH
|
140
|
-
2.
|
152
|
+
2.5.5
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Caramelize
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/7fe3ef34e09ba8133424/maintainability)](https://codeclimate.com/github/Dahie/caramelize/maintainability)
|
4
4
|
|
5
5
|
Caramelize is a compact and flexible wiki content migration tool. It is intended for easily transfering content from otherwise rare supported legacy wikis. With caramelize you can create your own export configurations and migrate your data into a git-based [gollum](https://github.com/github/gollum)-wiki retaining all your history and gaining the most flexible access to your wiki content.
|
6
6
|
|
@@ -107,8 +107,7 @@ Once the object is established we need to hook in a method that defines how revi
|
|
107
107
|
latest: row["latest"] == "Y",
|
108
108
|
time: row["time"],
|
109
109
|
message: row["note"],
|
110
|
-
author: author
|
111
|
-
author_name: row["user"]})
|
110
|
+
author: author})
|
112
111
|
revisions << page
|
113
112
|
end
|
114
113
|
# titles is the list of all unique page titles contained in the wiki
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rspec/core/rake_task'
|
2
4
|
require 'bundler/gem_tasks'
|
3
5
|
|
@@ -7,4 +9,4 @@ RSpec::Core::RakeTask.new(:spec) do |task|
|
|
7
9
|
task.rspec_opts = ['--color', '--format', 'documentation']
|
8
10
|
end
|
9
11
|
|
10
|
-
task :
|
12
|
+
task default: :spec
|
data/bin/caramelize
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'caramelize'
|
4
5
|
require 'commander/import'
|
@@ -20,10 +21,10 @@ command :new do |c|
|
|
20
21
|
c.option '--config STRING', String, 'The config file (default: caramel.rb)'
|
21
22
|
c.example 'Create a fresh config file as "caramel.rb"', 'caramelize create'
|
22
23
|
c.example 'Create a fresh config file as "config.rb"', 'caramelize create --config config.rb'
|
23
|
-
c.action do |
|
24
|
-
target_file
|
24
|
+
c.action do |_args, options|
|
25
|
+
target_file || options.config || 'caramel.rb'
|
25
26
|
options.default({ config: 'caramel.rb' })
|
26
|
-
FileUtils.cp(File.dirname(__FILE__)
|
27
|
+
FileUtils.cp("#{File.dirname(__FILE__)}/../lib/caramelize/#{target_file}",
|
27
28
|
options.config)
|
28
29
|
say "Created new configuration file: #{options.config}"
|
29
30
|
end
|
@@ -37,7 +38,7 @@ command :run do |c|
|
|
37
38
|
c.option '--config STRING', String, 'The config file (default: caramel.rb)'
|
38
39
|
c.example 'Run transfer for "caramel.rb"', 'caramelize run'
|
39
40
|
c.example 'Run transfer for "config.rb"', 'caramelize run --config config.rb'
|
40
|
-
c.action do |
|
41
|
+
c.action do |_args, options|
|
41
42
|
time_start = Time.now
|
42
43
|
options.default({ config: 'caramel.rb', target: 'wiki-export' })
|
43
44
|
|
@@ -63,7 +64,7 @@ command :doctor do |c|
|
|
63
64
|
c.description = 'Run health-check'
|
64
65
|
c.option '--target STRING', String, 'The target path to Gollum git repository (default: wiki-export)'
|
65
66
|
c.example 'Run transfer for "caramel.rb"', 'caramelize doctor'
|
66
|
-
c.action do |
|
67
|
+
c.action do |_args, options|
|
67
68
|
options.default(target: 'wiki-export')
|
68
69
|
|
69
70
|
if File.exist?(options.target)
|
data/caramelize.gemspec
CHANGED
@@ -1,33 +1,37 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'caramelize/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'caramelize'
|
8
9
|
spec.version = Caramelize::VERSION
|
9
|
-
spec.license
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
12
|
-
spec.homepage =
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.authors = ['Daniel Senff']
|
12
|
+
spec.email = ['mail@danielsenff.de']
|
13
|
+
spec.homepage = 'http://github.com/Dahie/caramelize'
|
14
|
+
spec.summary = 'Flexible and modular wiki conversion tool'
|
15
|
+
spec.description = 'With Caramelize you can migrate any wiki to git-based Gollum wiki repositories.'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.
|
19
|
-
spec.
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
spec.required_ruby_version = '>= 3.1'
|
20
21
|
|
21
22
|
spec.add_dependency('commander')
|
22
23
|
spec.add_dependency('gollum-lib')
|
23
24
|
spec.add_dependency('mysql2')
|
24
25
|
spec.add_dependency('ruby-progressbar')
|
25
26
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
28
|
+
spec.add_development_dependency 'byebug'
|
29
|
+
spec.add_development_dependency 'guard'
|
30
|
+
spec.add_development_dependency 'guard-rspec'
|
31
|
+
spec.add_development_dependency 'rake'
|
32
|
+
spec.add_development_dependency 'rspec'
|
33
|
+
spec.add_development_dependency 'rubocop'
|
34
|
+
spec.add_development_dependency 'rubocop-rake'
|
35
|
+
spec.add_development_dependency 'rubocop-rspec'
|
36
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
33
37
|
end
|
data/lib/caramelize/caramel.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'caramelize/input_wiki/wikkawiki'
|
2
4
|
require 'caramelize/input_wiki/redmine_wiki'
|
3
5
|
|
@@ -8,31 +10,29 @@ require 'caramelize/input_wiki/redmine_wiki'
|
|
8
10
|
|
9
11
|
# Note, if you want to activate this, you need to uncomment the line below.
|
10
12
|
def customized_wiki
|
11
|
-
|
12
13
|
# This example is a reimplementation of the WikkaWiki-Connector.
|
13
14
|
# To connect to WikkaWiki, I suggest to use the predefined Connector below.
|
14
|
-
options = { host:
|
15
|
-
username:
|
16
|
-
database:
|
15
|
+
options = { host: 'localhost',
|
16
|
+
username: 'user',
|
17
|
+
database: 'database_name',
|
17
18
|
password: 'Picard-Delta-5',
|
18
|
-
markup: :wikka}
|
19
|
+
markup: :wikka }
|
19
20
|
wiki = Caramelize::InputWiki::Wiki.new(options)
|
20
21
|
wiki.instance_eval do
|
21
22
|
def read_pages
|
22
|
-
sql =
|
23
|
+
sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
|
23
24
|
results = database.query(sql)
|
24
25
|
results.each do |row|
|
25
|
-
titles << row[
|
26
|
-
author = @authors[row[
|
27
|
-
properties = { id: row[
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
author_name: row["user"]}
|
26
|
+
titles << row['tag']
|
27
|
+
author = @authors[row['user']]
|
28
|
+
properties = { id: row['id'],
|
29
|
+
title: row['tag'],
|
30
|
+
body: row['body'],
|
31
|
+
markup: 'wikka',
|
32
|
+
latest: row['latest'] == 'Y',
|
33
|
+
time: row['time'],
|
34
|
+
message: row['note'],
|
35
|
+
author: }
|
36
36
|
page = Page.new(properties)
|
37
37
|
revisions << page
|
38
38
|
end
|
@@ -44,35 +44,31 @@ def customized_wiki
|
|
44
44
|
wiki
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
47
|
# if you want to use one of the preset Wiki-Connectors uncomment the connector
|
49
48
|
# and edit the database logins accordingly.
|
50
49
|
def predefined_wiki
|
51
|
-
|
52
50
|
# For connection to a WikkaWiki-Database use this Connector
|
53
|
-
#options = { host: "localhost",
|
51
|
+
# options = { host: "localhost",
|
54
52
|
# username: "root",
|
55
53
|
# password: "root",
|
56
54
|
# database: "wikka" }
|
57
|
-
#return Caramelize::InputWiki::WikkaWiki.new(options)
|
58
|
-
|
55
|
+
# return Caramelize::InputWiki::WikkaWiki.new(options)
|
59
56
|
|
60
57
|
# For connection to a Redmine-Database use this Connector
|
61
58
|
# Additional options:
|
62
59
|
# :create_namespace_overview => true/false (Default: true) - Creates a new wikipage at /home as root page for Gollum wiki
|
63
|
-
options = { host:
|
64
|
-
username:
|
65
|
-
password:
|
66
|
-
database:
|
67
|
-
|
60
|
+
options = { host: 'localhost',
|
61
|
+
username: 'root',
|
62
|
+
password: 'root',
|
63
|
+
database: 'redmine_development' }
|
64
|
+
Caramelize::InputWiki::RedmineWiki.new(options)
|
68
65
|
end
|
69
66
|
|
70
|
-
|
71
67
|
def input_wiki
|
72
68
|
# comment and uncomment to easily switch between predefined and
|
73
69
|
# costumized Wiki-connectors.
|
74
70
|
|
75
|
-
#return customized_wiki
|
71
|
+
# return customized_wiki
|
76
72
|
|
77
|
-
|
73
|
+
predefined_wiki
|
78
74
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ruby-progressbar'
|
2
4
|
|
3
5
|
module Caramelize
|
4
|
-
|
5
6
|
require 'caramelize/page'
|
6
7
|
require 'caramelize/content_transferer'
|
7
8
|
require 'caramelize/database_connector'
|
@@ -12,37 +13,37 @@ module Caramelize
|
|
12
13
|
class ContentTransferer
|
13
14
|
attr_reader :input_wiki, :options
|
14
15
|
|
15
|
-
DEFAULT_GOLLUM_HOME_TITLE = 'Home'
|
16
|
+
DEFAULT_GOLLUM_HOME_TITLE = 'Home'
|
17
|
+
DEFAULT_AUTHOR_NAME = 'Caramelize'
|
18
|
+
DEFAULT_AUTHOR_EMAIL = 'caramelize@example.com'
|
16
19
|
|
17
20
|
def initialize(input_wiki, options)
|
18
21
|
@input_wiki = input_wiki
|
19
22
|
@options = options
|
20
23
|
|
21
|
-
options[:default_author] = options.fetch(:default_author,
|
24
|
+
options[:default_author] = options.fetch(:default_author, 'Caramelize')
|
22
25
|
options[:markup] = target_markup
|
23
26
|
end
|
24
27
|
|
25
28
|
def execute
|
26
29
|
input_wiki.read_authors
|
27
|
-
|
28
30
|
commit_history
|
29
|
-
|
30
|
-
if verbose?
|
31
|
-
puts "From markup: #{input_wiki.markup.to_s}"
|
32
|
-
puts "To markup: #{target_markup.to_s}"
|
33
|
-
puts "Convert latest revisions:"
|
34
|
-
end
|
31
|
+
print_meta_data if verbose?
|
35
32
|
|
36
33
|
migrate_markup_of_latest_revisions
|
37
34
|
|
38
|
-
puts 'Create Namespace Overview' if verbose?
|
39
35
|
create_overview_page_of_namespaces if options[:create_namespace_overview]
|
40
36
|
|
41
|
-
rename_home_page
|
37
|
+
rename_home_page if options[:home_page_title]
|
42
38
|
end
|
43
39
|
|
44
40
|
private
|
45
41
|
|
42
|
+
def print_meta_data
|
43
|
+
puts "From markup: #{input_wiki.markup}"
|
44
|
+
puts "To markup: #{target_markup}"
|
45
|
+
end
|
46
|
+
|
46
47
|
def target_markup
|
47
48
|
@target_markup ||=
|
48
49
|
needs_conversion_to_target_markup? ? input_wiki.markup : :markdown
|
@@ -77,29 +78,47 @@ module Caramelize
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def create_overview_page_of_namespaces
|
81
|
+
puts 'Create Namespace Overview' if verbose?
|
80
82
|
output_wiki.commit_namespace_overview(input_wiki.namespaces)
|
81
83
|
end
|
82
84
|
|
83
85
|
def migrate_markup_progress_bar
|
84
86
|
@migrate_markup_progress_bar ||=
|
85
|
-
ProgressBar.create(title:
|
87
|
+
ProgressBar.create(title: 'Markup filters',
|
86
88
|
total: latest_revisions_count)
|
87
89
|
end
|
88
90
|
|
89
91
|
def commit_history_progress_bar
|
90
92
|
@commit_history_progress_bar ||=
|
91
|
-
ProgressBar.create(title:
|
93
|
+
ProgressBar.create(title: 'Revisions',
|
92
94
|
total: revisions_count)
|
93
95
|
end
|
94
96
|
|
95
97
|
def migrate_markup_of_latest_revisions
|
98
|
+
puts 'Convert latest revisions:' if verbose?
|
96
99
|
input_wiki.latest_revisions.each do |revision|
|
100
|
+
if input_wiki.excluded_pages.include?(revision.title)
|
101
|
+
puts "Exclude Page: #{revision.title}" if verbose?
|
102
|
+
next
|
103
|
+
end
|
104
|
+
|
105
|
+
if verbose?
|
106
|
+
puts "Filter source: #{revision.title} #{revision.time}"
|
107
|
+
else
|
108
|
+
migrate_markup_progress_bar.increment
|
109
|
+
end
|
110
|
+
|
97
111
|
migrate_markup_of_revision(revision)
|
98
112
|
end
|
99
113
|
end
|
100
114
|
|
101
115
|
def commit_history
|
102
116
|
output_wiki.commit_history(revisions, options) do |page, index|
|
117
|
+
if input_wiki.excluded_pages.include?(page.title)
|
118
|
+
puts "Exclude Page: #{page.title}" if verbose?
|
119
|
+
next
|
120
|
+
end
|
121
|
+
|
103
122
|
if verbose?
|
104
123
|
puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
|
105
124
|
else
|
@@ -109,27 +128,27 @@ module Caramelize
|
|
109
128
|
end
|
110
129
|
|
111
130
|
def migrate_markup_of_revision(revision)
|
112
|
-
if verbose?
|
113
|
-
puts "Filter source: #{revision.title} #{revision.time}"
|
114
|
-
else
|
115
|
-
migrate_markup_progress_bar.increment
|
116
|
-
end
|
117
|
-
|
118
131
|
body_new = filter_processor.run(revision.body)
|
119
132
|
|
120
|
-
|
121
|
-
revision.body = body_new
|
122
|
-
revision.author_name = 'Caramelize'
|
123
|
-
revision.time = Time.now
|
124
|
-
revision.author = nil
|
125
|
-
revision.message = "Markup of '#{revision.title}' converted to #{target_markup}"
|
133
|
+
return if body_new == revision.body
|
126
134
|
|
127
|
-
|
128
|
-
|
129
|
-
|
135
|
+
message = "Markup of '#{revision.title}' converted to #{target_markup}"
|
136
|
+
|
137
|
+
# commit as latest page revision
|
138
|
+
output_wiki.commit_revision(build_revision_metadata(revision, body_new, message), options[:markup])
|
139
|
+
end
|
140
|
+
|
141
|
+
def build_revision_metadata(revision, body_new, message)
|
142
|
+
revision.body = body_new
|
143
|
+
revision.author = { name: DEFAULT_AUTHOR_NAME, email: DEFAULT_AUTHOR_EMAIL }
|
144
|
+
revision.time = Time.now
|
145
|
+
revision.message = message
|
146
|
+
|
147
|
+
revision
|
130
148
|
end
|
131
149
|
|
132
150
|
def rename_home_page
|
151
|
+
puts "Rename page #{options[:home_page_title]} to #{DEFAULT_GOLLUM_HOME_TITLE}" if verbose?
|
133
152
|
output_wiki.rename_page(options[:home_page_title], DEFAULT_GOLLUM_HOME_TITLE)
|
134
153
|
end
|
135
154
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mysql2'
|
2
4
|
|
3
5
|
module Caramelize
|
4
6
|
module DatabaseConnector
|
5
|
-
|
6
7
|
def database
|
7
|
-
socket = [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
@client = Mysql2::Client.new(@options) unless @client
|
8
|
+
@options[:socket] = ['/tmp/mysqld.sock',
|
9
|
+
'/tmp/mysql.sock',
|
10
|
+
'/var/run/mysqld/mysqld.sock',
|
11
|
+
'/opt/local/var/run/mysql5/mysqld.sock',
|
12
|
+
'/var/lib/mysql/mysql.sock'].detect { |socket| File.exist?(socket) }
|
13
|
+
@client ||= Mysql2::Client.new(@options)
|
14
14
|
@client
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Caramelize
|
4
|
+
class CamelCaseToWikiLinks
|
5
|
+
def initialize(body)
|
6
|
+
@body = body
|
7
|
+
end
|
8
|
+
|
9
|
+
# take an input stream and convert all wikka syntax to markdown syntax
|
10
|
+
def run
|
11
|
+
migrated_body = @body.dup
|
12
|
+
|
13
|
+
migrated_body.gsub!(/([^\[\|\w\S])([A-Z]\w+[A-Z]\w+)([^\]])/) { "#{::Regexp.last_match(1)}#{format_link(::Regexp.last_match(2))}#{::Regexp.last_match(3)}" }
|
14
|
+
|
15
|
+
migrated_body
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def format_link(link)
|
21
|
+
link.gsub!(' ', '_')
|
22
|
+
link.gsub!('.', '')
|
23
|
+
"[[#{link}]]"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Caramelize
|
2
4
|
class RemoveTableTabLineEndings
|
3
|
-
|
4
5
|
def initialize(body)
|
5
6
|
@body = body
|
6
7
|
end
|
@@ -8,7 +9,7 @@ module Caramelize
|
|
8
9
|
# take an input stream and convert all wikka syntax to markdown syntax
|
9
10
|
def run
|
10
11
|
migrated_body = @body.dup
|
11
|
-
migrated_body.gsub!(/\|[\t ]*\r
|
12
|
+
migrated_body.gsub!(/\|[\t ]*\r?\n/, "|\n")
|
12
13
|
migrated_body
|
13
14
|
end
|
14
15
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Caramelize
|
2
4
|
class SwapWikiLinks
|
3
5
|
def initialize(body)
|
@@ -8,8 +10,8 @@ module Caramelize
|
|
8
10
|
def run
|
9
11
|
migrated_body = @body.dup
|
10
12
|
|
11
|
-
migrated_body.gsub!(/\[\[(\S+)\|(.+?)\]\]/) { format_link(
|
12
|
-
migrated_body.gsub!(/\[\[([\w\s
|
13
|
+
migrated_body.gsub!(/\[\[(\S+)\|(.+?)\]\]/) { format_link(::Regexp.last_match(2), ::Regexp.last_match(1)) }
|
14
|
+
migrated_body.gsub!(/\[\[([\w\s\-.]*)\]\]/) { format_link(::Regexp.last_match(1), ::Regexp.last_match(1).dup) }
|
13
15
|
|
14
16
|
migrated_body
|
15
17
|
end
|
@@ -19,7 +21,7 @@ module Caramelize
|
|
19
21
|
def format_link(label, link)
|
20
22
|
link.downcase!
|
21
23
|
link.gsub!(' ', '_')
|
22
|
-
link.gsub!(
|
24
|
+
link.gsub!('.', '')
|
23
25
|
"[[#{label}|#{link}]]"
|
24
26
|
end
|
25
27
|
end
|