caramelize 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/main.yml +48 -0
- data/.rubocop.yml +29 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +37 -25
- data/README.md +2 -3
- data/Rakefile +3 -1
- data/bin/caramelize +6 -5
- data/caramelize.gemspec +14 -19
- data/lib/caramelize/caramel.rb +32 -32
- data/lib/caramelize/content_transferer.rb +55 -32
- data/lib/caramelize/database_connector.rb +8 -8
- data/lib/caramelize/filter_processor.rb +2 -0
- data/lib/caramelize/filters/add_newline_to_page_end.rb +22 -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 +18 -15
- data/lib/caramelize/input_wiki/wiki.rb +11 -5
- data/lib/caramelize/input_wiki/wikkawiki.rb +23 -14
- data/lib/caramelize/output_wiki/gollum.rb +10 -10
- data/lib/caramelize/page.rb +14 -10
- 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 +9 -4
- data/spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb +29 -0
- data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +46 -0
- data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +19 -12
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +19 -14
- data/spec/lib/caramelize/filters/wikka2markdown_spec.rb +265 -0
- data/spec/lib/caramelize/input_wiki/wiki_spec.rb +24 -23
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +36 -34
- 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 +19 -121
- data/.travis.yml +0 -5
- data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +0 -198
- 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: d1f1a5ad803a7cb1d2b0492ef8608748f1d929dc87964ca5d57b41ca97e02866
|
4
|
+
data.tar.gz: ab3996a5e628285a09651362295f4939855f22a8a1c3fbfc08e7f234a95bfd22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6c3ddbf3c8283671a1f63e7bd235b8da9ceb39604ec738700d311526f89e174fab2bd6256e740ddebacf0fe20363a7a81963b8b642bd9c1a77dbf2ba11cbdd
|
7
|
+
data.tar.gz: '09de5bfa96bfa3156cbb1e047e9d9678997def63108afc467b5b80aace63ba0a736cca803061f2b2d3ad96b8bbd1a515871c2f5a5c481380850e7a6fb83d2295'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
# - name: Set up Redis
|
13
|
+
# uses: zhulik/redis-action@1.1.0
|
14
|
+
- name: Install Ruby and gems
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
bundler-cache: true
|
18
|
+
ruby-version: 3.1.3
|
19
|
+
|
20
|
+
- name: Configure sysctl limits
|
21
|
+
run: |
|
22
|
+
sudo swapoff -a
|
23
|
+
sudo sysctl -w vm.swappiness=1
|
24
|
+
sudo sysctl -w fs.file-max=262144
|
25
|
+
sudo sysctl -w vm.max_map_count=262144
|
26
|
+
- name: Setup DB, Run tests
|
27
|
+
run: |
|
28
|
+
bundle exec rspec
|
29
|
+
|
30
|
+
lint:
|
31
|
+
runs-on: ubuntu-latest
|
32
|
+
steps:
|
33
|
+
- name: Checkout code
|
34
|
+
uses: actions/checkout@v3
|
35
|
+
- name: Install Ruby and gems
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
bundler-cache: true
|
39
|
+
ruby-version: 3.1.3
|
40
|
+
# - name: Security audit dependencies
|
41
|
+
# uses: andrewmcodes/bundler-audit-action@main
|
42
|
+
# - name: Security audit application code
|
43
|
+
# uses: devmasx/brakeman-linter-action@v1.0.0
|
44
|
+
# env:
|
45
|
+
# GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
46
|
+
- name: Lint Ruby files
|
47
|
+
run: bundle exec rubocop --parallel
|
48
|
+
|
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
@@ -1,4 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in testgem.gemspec
|
4
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'bundler', '~> 2'
|
9
|
+
gem 'byebug'
|
10
|
+
gem 'guard'
|
11
|
+
gem 'guard-rspec'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'rubocop'
|
15
|
+
gem 'rubocop-rake'
|
16
|
+
gem 'rubocop-rspec'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
caramelize (1.
|
4
|
+
caramelize (1.2.1)
|
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
|
-
mysql2 (0.5.
|
65
|
+
mysql2 (0.5.6)
|
66
66
|
nenv (0.3.0)
|
67
|
-
nokogiri (1.
|
67
|
+
nokogiri (1.16.2)
|
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,27 +83,27 @@ 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
|
-
rspec (3.
|
90
|
-
rspec-core (~> 3.
|
91
|
-
rspec-expectations (~> 3.
|
92
|
-
rspec-mocks (~> 3.
|
93
|
-
rspec-core (3.
|
94
|
-
rspec-support (~> 3.
|
95
|
-
rspec-expectations (3.
|
89
|
+
rspec (3.13.0)
|
90
|
+
rspec-core (~> 3.13.0)
|
91
|
+
rspec-expectations (~> 3.13.0)
|
92
|
+
rspec-mocks (~> 3.13.0)
|
93
|
+
rspec-core (3.13.0)
|
94
|
+
rspec-support (~> 3.13.0)
|
95
|
+
rspec-expectations (3.13.0)
|
96
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
-
rspec-support (~> 3.
|
98
|
-
rspec-mocks (3.
|
97
|
+
rspec-support (~> 3.13.0)
|
98
|
+
rspec-mocks (3.13.0)
|
99
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
-
rspec-support (~> 3.
|
101
|
-
rspec-support (3.
|
102
|
-
rubocop (1.
|
100
|
+
rspec-support (~> 3.13.0)
|
101
|
+
rspec-support (3.13.0)
|
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,28 @@
|
|
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.
|
27
|
-
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "rspec"
|
29
|
-
spec.add_development_dependency "byebug"
|
30
|
-
spec.add_development_dependency "rubocop"
|
31
|
-
spec.add_development_dependency "guard"
|
32
|
-
spec.add_development_dependency "guard-rspec"
|
27
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
33
28
|
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
|
|
@@ -7,72 +9,70 @@ require 'caramelize/input_wiki/redmine_wiki'
|
|
7
9
|
# not supported by default in this software
|
8
10
|
|
9
11
|
# Note, if you want to activate this, you need to uncomment the line below.
|
10
|
-
|
11
|
-
|
12
|
+
# rubocop:todo Metrics/MethodLength
|
13
|
+
def customized_wiki # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
12
14
|
# This example is a reimplementation of the WikkaWiki-Connector.
|
13
15
|
# To connect to WikkaWiki, I suggest to use the predefined Connector below.
|
14
|
-
options = { host:
|
15
|
-
username:
|
16
|
-
database:
|
16
|
+
options = { host: 'localhost',
|
17
|
+
username: 'user',
|
18
|
+
database: 'database_name',
|
17
19
|
password: 'Picard-Delta-5',
|
18
|
-
markup: :wikka}
|
20
|
+
markup: :wikka }
|
19
21
|
wiki = Caramelize::InputWiki::Wiki.new(options)
|
20
22
|
wiki.instance_eval do
|
21
|
-
|
22
|
-
|
23
|
+
# rubocop:todo Metrics/MethodLength
|
24
|
+
def read_pages # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
25
|
+
sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
|
23
26
|
results = database.query(sql)
|
24
27
|
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"]}
|
28
|
+
titles << row['tag']
|
29
|
+
author = @authors[row['user']]
|
30
|
+
properties = { id: row['id'],
|
31
|
+
title: row['tag'],
|
32
|
+
body: row['body'],
|
33
|
+
markup: 'wikka',
|
34
|
+
latest: row['latest'] == 'Y',
|
35
|
+
time: row['time'],
|
36
|
+
message: row['note'],
|
37
|
+
author: }
|
36
38
|
page = Page.new(properties)
|
37
39
|
revisions << page
|
38
40
|
end
|
39
41
|
titles.uniq!
|
40
42
|
revisions
|
41
43
|
end
|
44
|
+
# rubocop:enable Metrics/MethodLength
|
42
45
|
end
|
43
46
|
|
44
47
|
wiki
|
45
48
|
end
|
46
|
-
|
49
|
+
# rubocop:enable Metrics/MethodLength
|
47
50
|
|
48
51
|
# if you want to use one of the preset Wiki-Connectors uncomment the connector
|
49
52
|
# and edit the database logins accordingly.
|
50
53
|
def predefined_wiki
|
51
|
-
|
52
54
|
# For connection to a WikkaWiki-Database use this Connector
|
53
|
-
#options = { host: "localhost",
|
55
|
+
# options = { host: "localhost",
|
54
56
|
# username: "root",
|
55
57
|
# password: "root",
|
56
58
|
# database: "wikka" }
|
57
|
-
#return Caramelize::InputWiki::WikkaWiki.new(options)
|
58
|
-
|
59
|
+
# return Caramelize::InputWiki::WikkaWiki.new(options)
|
59
60
|
|
60
61
|
# For connection to a Redmine-Database use this Connector
|
61
62
|
# Additional options:
|
62
63
|
# :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
|
-
|
64
|
+
options = { host: 'localhost',
|
65
|
+
username: 'root',
|
66
|
+
password: 'root',
|
67
|
+
database: 'redmine_development' }
|
68
|
+
Caramelize::InputWiki::RedmineWiki.new(options)
|
68
69
|
end
|
69
70
|
|
70
|
-
|
71
71
|
def input_wiki
|
72
72
|
# comment and uncomment to easily switch between predefined and
|
73
73
|
# costumized Wiki-connectors.
|
74
74
|
|
75
|
-
#return customized_wiki
|
75
|
+
# return customized_wiki
|
76
76
|
|
77
|
-
|
77
|
+
predefined_wiki
|
78
78
|
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'
|
@@ -9,40 +10,40 @@ module Caramelize
|
|
9
10
|
require 'caramelize/input_wiki/redmine_wiki'
|
10
11
|
require 'caramelize/input_wiki/wikkawiki'
|
11
12
|
|
12
|
-
class ContentTransferer
|
13
|
+
class ContentTransferer # rubocop:todo Metrics/ClassLength
|
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,50 @@ 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
|
+
# rubocop:todo Metrics/MethodLength
|
98
|
+
def migrate_markup_of_latest_revisions # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
99
|
+
puts 'Convert latest revisions:' if verbose?
|
96
100
|
input_wiki.latest_revisions.each do |revision|
|
101
|
+
if input_wiki.excluded_pages.include?(revision.title)
|
102
|
+
puts "Exclude Page: #{revision.title}" if verbose?
|
103
|
+
next
|
104
|
+
end
|
105
|
+
|
106
|
+
if verbose?
|
107
|
+
puts "Filter source: #{revision.title} #{revision.time}"
|
108
|
+
else
|
109
|
+
migrate_markup_progress_bar.increment
|
110
|
+
end
|
111
|
+
|
97
112
|
migrate_markup_of_revision(revision)
|
98
113
|
end
|
99
114
|
end
|
115
|
+
# rubocop:enable Metrics/MethodLength
|
100
116
|
|
101
|
-
|
117
|
+
# rubocop:todo Metrics/MethodLength
|
118
|
+
def commit_history # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
102
119
|
output_wiki.commit_history(revisions, options) do |page, index|
|
120
|
+
if input_wiki.excluded_pages.include?(page.title)
|
121
|
+
puts "Exclude Page: #{page.title}" if verbose?
|
122
|
+
next
|
123
|
+
end
|
124
|
+
|
103
125
|
if verbose?
|
104
126
|
puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
|
105
127
|
else
|
@@ -107,29 +129,30 @@ module Caramelize
|
|
107
129
|
end
|
108
130
|
end
|
109
131
|
end
|
132
|
+
# rubocop:enable Metrics/MethodLength
|
110
133
|
|
111
134
|
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
135
|
body_new = filter_processor.run(revision.body)
|
119
136
|
|
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}"
|
137
|
+
return if body_new == revision.body
|
126
138
|
|
127
|
-
|
128
|
-
|
129
|
-
|
139
|
+
message = "Markup of '#{revision.title}' converted to #{target_markup}"
|
140
|
+
|
141
|
+
# commit as latest page revision
|
142
|
+
output_wiki.commit_revision(build_revision_metadata(revision, body_new, message), options[:markup])
|
143
|
+
end
|
144
|
+
|
145
|
+
def build_revision_metadata(revision, body_new, message)
|
146
|
+
revision.body = body_new
|
147
|
+
revision.author = { name: DEFAULT_AUTHOR_NAME, email: DEFAULT_AUTHOR_EMAIL }
|
148
|
+
revision.time = Time.now
|
149
|
+
revision.message = message
|
150
|
+
|
151
|
+
revision
|
130
152
|
end
|
131
153
|
|
132
154
|
def rename_home_page
|
155
|
+
puts "Rename page #{options[:home_page_title]} to #{DEFAULT_GOLLUM_HOME_TITLE}" if verbose?
|
133
156
|
output_wiki.rename_page(options[:home_page_title], DEFAULT_GOLLUM_HOME_TITLE)
|
134
157
|
end
|
135
158
|
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
|