caramelize 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +70 -64
- data/README.md +5 -0
- data/bin/caramelize +18 -1
- data/caramelize.gemspec +3 -3
- data/lib/caramelize/content_transferer.rb +1 -1
- data/lib/caramelize/filter_processor.rb +0 -3
- data/lib/caramelize/filters/swap_wiki_links.rb +11 -11
- data/lib/caramelize/health_check.rb +85 -0
- data/lib/caramelize/input_wiki/redmine_wiki.rb +26 -11
- data/lib/caramelize/input_wiki/wiki.rb +3 -5
- data/lib/caramelize/input_wiki/wikkawiki.rb +13 -5
- data/lib/caramelize/output_wiki/gollum.rb +5 -3
- data/lib/caramelize/page.rb +10 -5
- data/lib/caramelize/services/page_builder.rb +1 -1
- data/lib/caramelize/version.rb +1 -1
- data/lib/caramelize.rb +1 -0
- data/spec/fixtures/markup/swap-links-output.textile +19 -19
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +4 -4
- data/spec/lib/caramelize/input_wiki/wiki_spec.rb +1 -1
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +2 -1
- data/spec/lib/caramelize/page_spec.rb +19 -1
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d6068cd942a85fdcb01d1ebbeb4ce0099ed42d39fd1bd6945979d25766aeecc
|
4
|
+
data.tar.gz: dfedd3d78aaa4dde06807bdd8df064f044830b5caa0e2579ada4c7e6a170ddaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c84686c76e783a8c782e5cf4fbfd27cb0e971a17dc306c04b5d35990418d8a97d1e24a20a51e83949d315b2e1915c38d21940bae9605823ed0eb9716300926
|
7
|
+
data.tar.gz: efc71348b1350752111fb4770997589489ced69d84e4b8714e38d31e0bd668df9ae3d917ff8c73abbaa0842b297acf09485ec1bbe30b02096c65baaa239826cc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
caramelize (1.
|
4
|
+
caramelize (1.1.1)
|
5
5
|
commander
|
6
6
|
gollum-lib
|
7
7
|
mysql2
|
@@ -10,37 +10,36 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
ast (2.4.
|
13
|
+
ast (2.4.2)
|
14
14
|
byebug (11.1.3)
|
15
|
-
coderay (1.1.
|
16
|
-
commander (4.
|
15
|
+
coderay (1.1.3)
|
16
|
+
commander (4.6.0)
|
17
17
|
highline (~> 2.0.0)
|
18
18
|
crass (1.0.6)
|
19
|
-
diff-lcs (1.
|
20
|
-
ffi (1.
|
21
|
-
formatador (
|
22
|
-
gemojione (4.3.
|
19
|
+
diff-lcs (1.5.0)
|
20
|
+
ffi (1.16.3)
|
21
|
+
formatador (1.1.0)
|
22
|
+
gemojione (4.3.3)
|
23
23
|
json
|
24
|
-
github-markup (
|
25
|
-
gollum-lib (
|
24
|
+
github-markup (4.0.2)
|
25
|
+
gollum-lib (6.0)
|
26
26
|
gemojione (~> 4.1)
|
27
|
-
github-markup (~>
|
28
|
-
gollum-rugged_adapter (~>
|
27
|
+
github-markup (~> 4.0)
|
28
|
+
gollum-rugged_adapter (~> 3.0)
|
29
29
|
loofah (~> 2.3)
|
30
30
|
nokogiri (~> 1.8)
|
31
|
-
octicons (~> 8.5)
|
32
31
|
rouge (~> 3.1)
|
33
32
|
twitter-text (= 1.14.7)
|
34
|
-
gollum-rugged_adapter (
|
35
|
-
mime-types (
|
36
|
-
rugged (~>
|
37
|
-
guard (2.
|
33
|
+
gollum-rugged_adapter (3.0)
|
34
|
+
mime-types (~> 3.4)
|
35
|
+
rugged (~> 1.5)
|
36
|
+
guard (2.18.1)
|
38
37
|
formatador (>= 0.2.4)
|
39
38
|
listen (>= 2.7, < 4.0)
|
40
39
|
lumberjack (>= 1.0.12, < 2.0)
|
41
40
|
nenv (~> 0.1)
|
42
41
|
notiffany (~> 0.0)
|
43
|
-
pry (>= 0.
|
42
|
+
pry (>= 0.13.0)
|
44
43
|
shellany (~> 0.0)
|
45
44
|
thor (>= 0.18.1)
|
46
45
|
guard-compat (1.2.1)
|
@@ -49,79 +48,86 @@ GEM
|
|
49
48
|
guard-compat (~> 1.1)
|
50
49
|
rspec (>= 2.99.0, < 4.0)
|
51
50
|
highline (2.0.3)
|
52
|
-
|
53
|
-
|
54
|
-
listen (3.
|
51
|
+
json (2.7.1)
|
52
|
+
language_server-protocol (3.17.0.3)
|
53
|
+
listen (3.8.0)
|
55
54
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
56
55
|
rb-inotify (~> 0.9, >= 0.9.10)
|
57
|
-
loofah (2.
|
56
|
+
loofah (2.22.0)
|
58
57
|
crass (~> 1.0.2)
|
59
|
-
nokogiri (>= 1.
|
60
|
-
lumberjack (1.2.
|
58
|
+
nokogiri (>= 1.12.0)
|
59
|
+
lumberjack (1.2.10)
|
61
60
|
method_source (1.0.0)
|
62
|
-
mime-types (3.
|
61
|
+
mime-types (3.5.1)
|
63
62
|
mime-types-data (~> 3.2015)
|
64
|
-
mime-types-data (3.
|
65
|
-
mini_portile2 (2.
|
66
|
-
mysql2 (0.5.
|
63
|
+
mime-types-data (3.2023.1205)
|
64
|
+
mini_portile2 (2.8.5)
|
65
|
+
mysql2 (0.5.5)
|
67
66
|
nenv (0.3.0)
|
68
|
-
nokogiri (1.
|
69
|
-
mini_portile2 (~> 2.
|
67
|
+
nokogiri (1.15.5)
|
68
|
+
mini_portile2 (~> 2.8.2)
|
69
|
+
racc (~> 1.4)
|
70
70
|
notiffany (0.1.3)
|
71
71
|
nenv (~> 0.1)
|
72
72
|
shellany (~> 0.0)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
pry (0.13.1)
|
73
|
+
parallel (1.23.0)
|
74
|
+
parser (3.2.2.4)
|
75
|
+
ast (~> 2.4.1)
|
76
|
+
racc
|
77
|
+
pry (0.14.2)
|
79
78
|
coderay (~> 1.1)
|
80
79
|
method_source (~> 1.0)
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
racc (1.7.3)
|
81
|
+
rainbow (3.1.1)
|
82
|
+
rake (13.1.0)
|
83
|
+
rb-fsevent (0.11.2)
|
84
84
|
rb-inotify (0.10.1)
|
85
85
|
ffi (~> 1.0)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
rspec-
|
91
|
-
rspec-
|
92
|
-
|
93
|
-
|
94
|
-
|
86
|
+
regexp_parser (2.8.3)
|
87
|
+
rexml (3.2.6)
|
88
|
+
rouge (3.30.0)
|
89
|
+
rspec (3.12.0)
|
90
|
+
rspec-core (~> 3.12.0)
|
91
|
+
rspec-expectations (~> 3.12.0)
|
92
|
+
rspec-mocks (~> 3.12.0)
|
93
|
+
rspec-core (3.12.2)
|
94
|
+
rspec-support (~> 3.12.0)
|
95
|
+
rspec-expectations (3.12.3)
|
95
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
96
|
-
rspec-support (~> 3.
|
97
|
-
rspec-mocks (3.
|
97
|
+
rspec-support (~> 3.12.0)
|
98
|
+
rspec-mocks (3.12.6)
|
98
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
99
|
-
rspec-support (~> 3.
|
100
|
-
rspec-support (3.
|
101
|
-
rubocop (
|
102
|
-
|
100
|
+
rspec-support (~> 3.12.0)
|
101
|
+
rspec-support (3.12.1)
|
102
|
+
rubocop (1.58.0)
|
103
|
+
json (~> 2.3)
|
104
|
+
language_server-protocol (>= 3.17.0)
|
103
105
|
parallel (~> 1.10)
|
104
|
-
parser (>= 2.
|
106
|
+
parser (>= 3.2.2.4)
|
105
107
|
rainbow (>= 2.2.2, < 4.0)
|
106
|
-
|
108
|
+
regexp_parser (>= 1.8, < 3.0)
|
109
|
+
rexml (>= 3.2.5, < 4.0)
|
110
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
107
111
|
ruby-progressbar (~> 1.7)
|
108
|
-
unicode-display_width (>=
|
109
|
-
|
110
|
-
|
112
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
113
|
+
rubocop-ast (1.30.0)
|
114
|
+
parser (>= 3.2.1.0)
|
115
|
+
ruby-progressbar (1.13.0)
|
116
|
+
rugged (1.7.1)
|
111
117
|
shellany (0.0.1)
|
112
|
-
thor (1.0
|
118
|
+
thor (1.3.0)
|
113
119
|
twitter-text (1.14.7)
|
114
120
|
unf (~> 0.1.0)
|
115
121
|
unf (0.1.4)
|
116
122
|
unf_ext
|
117
|
-
unf_ext (0.0.
|
118
|
-
unicode-display_width (
|
123
|
+
unf_ext (0.0.9.1)
|
124
|
+
unicode-display_width (2.5.0)
|
119
125
|
|
120
126
|
PLATFORMS
|
121
127
|
ruby
|
122
128
|
|
123
129
|
DEPENDENCIES
|
124
|
-
bundler (~>
|
130
|
+
bundler (~> 2)
|
125
131
|
byebug
|
126
132
|
caramelize!
|
127
133
|
guard
|
@@ -131,4 +137,4 @@ DEPENDENCIES
|
|
131
137
|
rubocop
|
132
138
|
|
133
139
|
BUNDLED WITH
|
134
|
-
|
140
|
+
2.4.22
|
data/README.md
CHANGED
@@ -24,6 +24,11 @@ Creates a template configuration file "caramel.rb". This includes documentation
|
|
24
24
|
|
25
25
|
Will start the wiki migration based on the configuration file. These are either found in predefined paths (./caramel.rb, ./config.rb, …), or passed as argument, as below.
|
26
26
|
|
27
|
+
$ caramelize doctor
|
28
|
+
|
29
|
+
Can be used to assess the quality of your wiki conversion. It'll help you see
|
30
|
+
how many wiki links may be broken and how many pages were orphaned.
|
31
|
+
|
27
32
|
$ caramelize help
|
28
33
|
|
29
34
|
Returns help information.
|
data/bin/caramelize
CHANGED
@@ -45,7 +45,7 @@ command :run do |c|
|
|
45
45
|
|
46
46
|
target = options.target
|
47
47
|
|
48
|
-
if File.
|
48
|
+
if File.exist?(target)
|
49
49
|
answer = agree("#{target} already exists. Overwrite with fresh repository?")
|
50
50
|
FileUtils.rm_rf(target) if answer
|
51
51
|
end
|
@@ -56,3 +56,20 @@ command :run do |c|
|
|
56
56
|
say "Time required: #{Time.now - time_start} s"
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
command :doctor do |c|
|
61
|
+
c.syntax = 'caramelize doctor [options]'
|
62
|
+
c.summary = 'Run wiki transfer'
|
63
|
+
c.description = 'Run health-check'
|
64
|
+
c.option '--target STRING', String, 'The target path to Gollum git repository (default: wiki-export)'
|
65
|
+
c.example 'Run transfer for "caramel.rb"', 'caramelize doctor'
|
66
|
+
c.action do |args, options|
|
67
|
+
options.default(target: 'wiki-export')
|
68
|
+
|
69
|
+
if File.exist?(options.target)
|
70
|
+
Caramelize::HealthCheck.new(options.target).execute
|
71
|
+
else
|
72
|
+
say("No wiki repositry found in directory #{options.target}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/caramelize.gemspec
CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency('mysql2')
|
22
21
|
spec.add_dependency('commander')
|
23
|
-
spec.add_dependency('ruby-progressbar')
|
24
22
|
spec.add_dependency('gollum-lib')
|
23
|
+
spec.add_dependency('mysql2')
|
24
|
+
spec.add_dependency('ruby-progressbar')
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "~>
|
26
|
+
spec.add_development_dependency "bundler", "~> 2"
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
spec.add_development_dependency "rspec"
|
29
29
|
spec.add_development_dependency "byebug"
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Caramelize
|
2
2
|
class SwapWikiLinks
|
3
|
-
|
4
3
|
def initialize(body)
|
5
4
|
@body = body
|
6
5
|
end
|
@@ -9,18 +8,19 @@ module Caramelize
|
|
9
8
|
def run
|
10
9
|
migrated_body = @body.dup
|
11
10
|
|
12
|
-
migrated_body.gsub!(/\[\[(\S+)\|(.+?)\]\]
|
13
|
-
migrated_body.gsub!(/\[\[([\w\s
|
14
|
-
if $1
|
15
|
-
s = $1
|
16
|
-
t = $1.dup
|
17
|
-
t.gsub!(' ', '_')
|
18
|
-
t.gsub!(/\./, '')
|
19
|
-
s = "[[#{s}|#{t}]]"
|
20
|
-
end
|
21
|
-
end
|
11
|
+
migrated_body.gsub!(/\[\[(\S+)\|(.+?)\]\]/) { format_link($2, $1) }
|
12
|
+
migrated_body.gsub!(/\[\[([\w\s\-\.]*)\]\]/) { format_link($1, $1.dup) }
|
22
13
|
|
23
14
|
migrated_body
|
24
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def format_link(label, link)
|
20
|
+
link.downcase!
|
21
|
+
link.gsub!(' ', '_')
|
22
|
+
link.gsub!(/\./, '')
|
23
|
+
"[[#{label}|#{link}]]"
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Caramelize
|
2
|
+
class HealthCheck
|
3
|
+
attr_reader :wiki_path, :options
|
4
|
+
|
5
|
+
DEFAULT_GOLLUM_HOME_TITLE = 'Home'.freeze
|
6
|
+
|
7
|
+
def initialize(wiki_path, options={})
|
8
|
+
@wiki_path = wiki_path
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
#puts page_paths.sort.inspect
|
14
|
+
|
15
|
+
check_pages
|
16
|
+
|
17
|
+
#puts intra_wiki_paths.sort.inspect
|
18
|
+
|
19
|
+
puts "\n # Pages not linked within Wiki:"
|
20
|
+
puts page_paths_without_intra_wiki_path.sort.inspect
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def files
|
26
|
+
@files ||= Dir.glob([wiki_path, '**/*.md'].join('/'))
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_names
|
30
|
+
files.map do |file|
|
31
|
+
file.gsub("#{wiki_path}/", '').split('.').first
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_pages
|
36
|
+
pages.each do |page|
|
37
|
+
puts "\n## #{page.path}"
|
38
|
+
check_page(page)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def check_page(page)
|
43
|
+
intra_wiki_links = intra_wiki_links(page.text_data)
|
44
|
+
available = 0
|
45
|
+
intra_wiki_links.each do |link|
|
46
|
+
intra_wiki_link = page.path.split('/').first == page.path ? link : [page.path.split('/').first, link].join('/')
|
47
|
+
if !page_paths.include?(intra_wiki_link)
|
48
|
+
puts "#{intra_wiki_link} expected, but missing"
|
49
|
+
else
|
50
|
+
available += 1
|
51
|
+
intra_wiki_paths << intra_wiki_link
|
52
|
+
end
|
53
|
+
end
|
54
|
+
puts "#{available}/#{intra_wiki_links.count} available"
|
55
|
+
end
|
56
|
+
|
57
|
+
def intra_wiki_links(body)
|
58
|
+
body.scan(/\[\[(.+\|)?(\S+)\]\]/).map { |match| match[1] }.uniq
|
59
|
+
end
|
60
|
+
|
61
|
+
def pages
|
62
|
+
gollum.pages
|
63
|
+
end
|
64
|
+
|
65
|
+
def page_paths
|
66
|
+
pages.map(&:path).map { |path| path.split('.').first }
|
67
|
+
end
|
68
|
+
|
69
|
+
def intra_wiki_paths
|
70
|
+
@intra_wiki_paths ||= []
|
71
|
+
end
|
72
|
+
|
73
|
+
def page_paths_without_intra_wiki_path
|
74
|
+
page_paths - intra_wiki_paths
|
75
|
+
end
|
76
|
+
|
77
|
+
def check_home_page
|
78
|
+
puts "Home.md missing" if File.exist?('wiki-export/Home.md')
|
79
|
+
end
|
80
|
+
|
81
|
+
def gollum
|
82
|
+
@gollum ||= ::Gollum::Wiki.new(wiki_path)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -23,16 +23,13 @@ module Caramelize
|
|
23
23
|
build_page(row_page)
|
24
24
|
end
|
25
25
|
titles.uniq!
|
26
|
-
@latest_revisions.each { |rev| rev[1].set_latest }
|
27
26
|
revisions.sort! { |a,b| a.time <=> b.time }
|
28
27
|
|
29
|
-
# TODO find latest revision for each limit
|
30
|
-
|
31
28
|
revisions
|
32
29
|
end
|
33
30
|
|
34
31
|
def read_authors
|
35
|
-
results = database.query(
|
32
|
+
results = database.query(authors_query)
|
36
33
|
results.each do |row|
|
37
34
|
authors[row["id"]] = OpenStruct.new(id: row["id"],
|
38
35
|
name: row["login"],
|
@@ -44,7 +41,7 @@ module Caramelize
|
|
44
41
|
private
|
45
42
|
|
46
43
|
def build_page(row_page)
|
47
|
-
results_contents = database.query(
|
44
|
+
results_contents = database.query(single_page_query(row_page['id']))
|
48
45
|
|
49
46
|
wiki = wikis.select{ |row| row['id'] == row_page['wiki_id'] }.first
|
50
47
|
|
@@ -58,11 +55,9 @@ module Caramelize
|
|
58
55
|
title = project_identifier + row_page['title']
|
59
56
|
titles << title
|
60
57
|
|
61
|
-
@latest_revisions = {}
|
62
58
|
results_contents.each do |row_content|
|
63
59
|
page = Page.new(build_properties(title, row_content))
|
64
60
|
revisions << page
|
65
|
-
@latest_revisions[title] = page
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
@@ -74,20 +69,40 @@ module Caramelize
|
|
74
69
|
end
|
75
70
|
end
|
76
71
|
|
72
|
+
def authors_query
|
73
|
+
'SELECT id, login, mail FROM users;'
|
74
|
+
end
|
75
|
+
|
76
|
+
def single_page_query(page_id)
|
77
|
+
"SELECT * FROM wiki_content_versions WHERE page_id='#{page_id}' ORDER BY updated_on;"
|
78
|
+
end
|
79
|
+
|
80
|
+
def projects_query
|
81
|
+
'SELECT id, identifier, name FROM projects;'
|
82
|
+
end
|
83
|
+
|
84
|
+
def pages_query
|
85
|
+
'SELECT id, title, wiki_id FROM wiki_pages;'
|
86
|
+
end
|
87
|
+
|
88
|
+
def wikis_query
|
89
|
+
'SELECT id, project_id FROM wikis;'
|
90
|
+
end
|
91
|
+
|
77
92
|
def pages
|
78
|
-
@pages ||= database.query(
|
93
|
+
@pages ||= database.query(pages_query)
|
79
94
|
end
|
80
95
|
|
81
96
|
def projects
|
82
|
-
@projects ||= database.query(
|
97
|
+
@projects ||= database.query(projects_query)
|
83
98
|
end
|
84
99
|
|
85
100
|
def wikis
|
86
|
-
@wikis ||= database.query(
|
101
|
+
@wikis ||= database.query(wikis_query)
|
87
102
|
end
|
88
103
|
|
89
104
|
def build_properties(title, row_content)
|
90
|
-
author = authors
|
105
|
+
author = authors.fetch(row_content["author_id"], nil)
|
91
106
|
{
|
92
107
|
id: row_content['id'],
|
93
108
|
title: title,
|
@@ -14,9 +14,8 @@ module Caramelize
|
|
14
14
|
def revisions_by_title(title)
|
15
15
|
# new array only containing pages by this name sorted by time asc
|
16
16
|
# this does not support renamed pages
|
17
|
-
|
18
|
-
|
19
|
-
.sort { |x,y| x.time <=> y.time }
|
17
|
+
revisions.select { |revision| revision.title == title }
|
18
|
+
.sort { |x,y| x.time <=> y.time }
|
20
19
|
end
|
21
20
|
|
22
21
|
# return an empty array in case this action was not overridden
|
@@ -49,13 +48,12 @@ module Caramelize
|
|
49
48
|
end
|
50
49
|
|
51
50
|
def latest_revisions
|
52
|
-
titles.map { |title| revisions_by_title(title).last }.compact
|
51
|
+
@latest_revisions ||= titles.map { |title| revisions_by_title(title).last }.compact
|
53
52
|
end
|
54
53
|
|
55
54
|
def markup
|
56
55
|
@options[:markup]
|
57
56
|
end
|
58
|
-
|
59
57
|
end
|
60
58
|
end
|
61
59
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'caramelize/input_wiki/wiki'
|
2
1
|
require 'caramelize/database_connector'
|
3
2
|
require 'caramelize/filters/wikka_to_markdown'
|
4
3
|
|
@@ -7,6 +6,9 @@ module Caramelize
|
|
7
6
|
class WikkaWiki < Wiki
|
8
7
|
include DatabaseConnector
|
9
8
|
|
9
|
+
SQL_PAGES = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'.freeze
|
10
|
+
SQL_AUTHORS = 'SELECT name, email FROM wikka_users;'.freeze
|
11
|
+
|
10
12
|
def initialize(options = {})
|
11
13
|
super(options)
|
12
14
|
@options[:markup] = :wikka
|
@@ -27,8 +29,7 @@ module Caramelize
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def read_authors
|
30
|
-
|
31
|
-
results = database.query(sql)
|
32
|
+
results = database.query(authors_query)
|
32
33
|
results.each do |row|
|
33
34
|
authors[row['name']] = OpenStruct.new(name: row['name'],
|
34
35
|
email: row['email'] )
|
@@ -37,9 +38,16 @@ module Caramelize
|
|
37
38
|
|
38
39
|
private
|
39
40
|
|
41
|
+
def pages_query
|
42
|
+
SQL_PAGES
|
43
|
+
end
|
44
|
+
|
45
|
+
def authors_query
|
46
|
+
SQL_AUTHORS
|
47
|
+
end
|
48
|
+
|
40
49
|
def pages
|
41
|
-
|
42
|
-
@pages ||= database.query(sql)
|
50
|
+
@pages ||= database.query(pages_query)
|
43
51
|
end
|
44
52
|
|
45
53
|
def build_properties(row)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'gollum-lib'
|
2
|
+
|
1
3
|
module Caramelize
|
2
4
|
module OutputWiki
|
3
5
|
class Gollum
|
@@ -17,12 +19,12 @@ module Caramelize
|
|
17
19
|
# Commit the given page into the gollum-wiki-repository.
|
18
20
|
# Make sure the target markup is correct before calling this method.
|
19
21
|
def commit_revision(page, markup)
|
20
|
-
gollum_page = gollum.page(page.
|
22
|
+
gollum_page = gollum.page(page.path)
|
21
23
|
|
22
24
|
if gollum_page
|
23
25
|
gollum.update_page(gollum_page, gollum_page.name, gollum_page.format, page.body, build_commit(page))
|
24
26
|
else
|
25
|
-
gollum.write_page(page.
|
27
|
+
gollum.write_page(page.path, markup, page.body, build_commit(page))
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -68,7 +70,7 @@ module Caramelize
|
|
68
70
|
end
|
69
71
|
|
70
72
|
def initialize_repository
|
71
|
-
return if File.
|
73
|
+
return if File.exist?(wiki_path)
|
72
74
|
Dir.mkdir(wiki_path)
|
73
75
|
#::Gollum::Git::Repo.new(wiki_path, { is_bare: true })
|
74
76
|
::Gollum::Git::Repo.init(wiki_path)
|
data/lib/caramelize/page.rb
CHANGED
@@ -4,14 +4,14 @@ module Caramelize
|
|
4
4
|
attr_accessor :title, :body, :id, :markup, :latest, :time, :message,
|
5
5
|
:author, :author_name
|
6
6
|
|
7
|
-
def initialize(page={})
|
7
|
+
def initialize(page = {})
|
8
8
|
@id = page[:id]
|
9
|
-
@title = page
|
10
|
-
@body = page
|
9
|
+
@title = page.fetch(:title, '')
|
10
|
+
@body = page.fetch(:body, '')
|
11
11
|
@syntax = page[:markup]
|
12
12
|
@latest = page[:latest] || false
|
13
|
-
@time = page
|
14
|
-
@message = page
|
13
|
+
@time = page.fetch(:time, Time.now)
|
14
|
+
@message = page.fetch(:message, '')
|
15
15
|
@author = page[:author]
|
16
16
|
@author_name = page[:author_name]
|
17
17
|
end
|
@@ -33,6 +33,11 @@ module Caramelize
|
|
33
33
|
@latest
|
34
34
|
end
|
35
35
|
|
36
|
+
def path
|
37
|
+
return @title unless @title.index('/')
|
38
|
+
@title.split('/').first + '/' + @title.split('/').last.downcase
|
39
|
+
end
|
40
|
+
|
36
41
|
def set_latest
|
37
42
|
@latest = true
|
38
43
|
end
|
@@ -7,7 +7,7 @@ module Caramelize
|
|
7
7
|
namespaces.each do |namespace|
|
8
8
|
# TODO change wiki as configurable default home
|
9
9
|
# TODO support other markup syntaxes
|
10
|
-
body << "* [[#{namespace[:name]}|#{namespace[:identifier]}/
|
10
|
+
body << "* [[#{namespace[:name]}|#{namespace[:identifier]}/wiki]] \n"
|
11
11
|
end
|
12
12
|
|
13
13
|
Page.new(title: "Home",
|
data/lib/caramelize/version.rb
CHANGED
data/lib/caramelize.rb
CHANGED
@@ -3,6 +3,7 @@ require 'caramelize/page'
|
|
3
3
|
require 'caramelize/content_transferer'
|
4
4
|
require 'caramelize/filter_processor'
|
5
5
|
require 'caramelize/database_connector'
|
6
|
+
require 'caramelize/health_check'
|
6
7
|
require 'caramelize/output_wiki/gollum'
|
7
8
|
require 'caramelize/services/page_builder'
|
8
9
|
require 'caramelize/input_wiki/wiki'
|
@@ -6,13 +6,13 @@ h2. The 1994 Formula One Season
|
|
6
6
|
*[[Race by Race|race-by-race]]*
|
7
7
|
*[[Technical Regulations|technical-regulations]]*
|
8
8
|
*[[Technical Rule Changes|technical-rules]]*
|
9
|
-
*[[HD Rear Wing Configurations|
|
9
|
+
*[[HD Rear Wing Configurations|hd-rear-wings]]*
|
10
10
|
*[[Helmet variants|helmets]]*
|
11
11
|
|
12
12
|
h2. Development
|
13
13
|
|
14
|
-
*[[Review Process F1 1994|
|
15
|
-
*[[Credits|
|
14
|
+
*[[Review Process F1 1994|review_process_f1_1994]]*
|
15
|
+
*[[Credits|credits]]*
|
16
16
|
|
17
17
|
h2. Season data
|
18
18
|
|
@@ -22,36 +22,36 @@ Early season package
|
|
22
22
|
Driver list from Brazil: "Discussion here":http://forum.ctdp.net/viewtopic.php?f=214&t=62989
|
23
23
|
|
24
24
|
|_.Nr|_.Driver |_.Team|
|
25
|
-
|0|Damon Hill |/2.[[Williams-Renault|
|
25
|
+
|0|Damon Hill |/2.[[Williams-Renault|williams]]|
|
26
26
|
|2|Ayrton Senna |
|
27
|
-
|3|Ukyo Katayama |/2.[[Tyrrell-Yamaha|
|
27
|
+
|3|Ukyo Katayama |/2.[[Tyrrell-Yamaha|tyrrell]]|
|
28
28
|
|4|Mark Blundell |
|
29
|
-
|5|Michael Schumacher|/2.[[Benetton-Ford|
|
29
|
+
|5|Michael Schumacher|/2.[[Benetton-Ford|benetton]]|
|
30
30
|
|6|Jos Verstappen |
|
31
|
-
|7|Mika Häkkinen |/2.[[McLaren-Peugeot|
|
31
|
+
|7|Mika Häkkinen |/2.[[McLaren-Peugeot|mclaren]]|
|
32
32
|
|8|Martin Brundle |
|
33
|
-
|9|Christian Fittipaldi|/2.[[Footwork-Ford|
|
33
|
+
|9|Christian Fittipaldi|/2.[[Footwork-Ford|footwork]]|
|
34
34
|
|10|Gianni Morbidelli|
|
35
|
-
|11|Pedro Lamy |/2.[[Lotus-Mugen-Honda|
|
35
|
+
|11|Pedro Lamy |/2.[[Lotus-Mugen-Honda|lotus]]|
|
36
36
|
|12|Johnny Herbert |
|
37
|
-
|14|Rubens Barrichello|/2.[[Jordan-Hart|
|
37
|
+
|14|Rubens Barrichello|/2.[[Jordan-Hart|jordan]]|
|
38
38
|
|15|Eddie Irvine |
|
39
|
-
|19|Olivier Beretta |/2.[[Larrousse-Ford|
|
39
|
+
|19|Olivier Beretta |/2.[[Larrousse-Ford|larrousse]]|
|
40
40
|
|20|Érik Comas |
|
41
|
-
|23|Pierluigi Martini|/2.[[Minardi-Ford|
|
41
|
+
|23|Pierluigi Martini|/2.[[Minardi-Ford|minardi]]|
|
42
42
|
|24|Michele Alboreto |
|
43
|
-
|25|Éric Bernard |/2.[[Ligier-Renault|
|
43
|
+
|25|Éric Bernard |/2.[[Ligier-Renault|ligier]]|
|
44
44
|
|26|Olivier Panis |
|
45
|
-
|27|Jean Alesi |/2.[[Ferrari|
|
45
|
+
|27|Jean Alesi |/2.[[Ferrari|ferrari]]|
|
46
46
|
|28|Gerhard Berger |
|
47
|
-
|29|Karl Wendlinger |/2.[[Sauber-Mercedes|
|
47
|
+
|29|Karl Wendlinger |/2.[[Sauber-Mercedes|sauber]]|
|
48
48
|
|30|Heinz-Harald Frentzen|
|
49
|
-
|31|David Brabham |/2.[[Simtek-Ford|
|
49
|
+
|31|David Brabham |/2.[[Simtek-Ford|simtek]]|
|
50
50
|
|32|Roland Ratzenberger|
|
51
|
-
|33|Paul Belmondo |/2.[[Pacific-Ilmor|
|
51
|
+
|33|Paul Belmondo |/2.[[Pacific-Ilmor|pacific]]|
|
52
52
|
|34|Bertrand Gachot |
|
53
53
|
|
54
54
|
|
55
|
-
[[Getting new people|
|
55
|
+
[[Getting new people|getting_new_people]]
|
56
56
|
|
57
|
-
[[Contact form|
|
57
|
+
[[Contact form|contact_form]]
|
@@ -17,15 +17,15 @@ describe Caramelize::SwapWikiLinks do
|
|
17
17
|
let(:body) { '[[Release 1 0]]' }
|
18
18
|
|
19
19
|
it 'replaces space with dashes' do
|
20
|
-
is_expected.to eq '[[Release 1 0|
|
20
|
+
is_expected.to eq '[[Release 1 0|release_1_0]]'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'wiki title with dashes' do
|
25
|
-
let(:body) { '[[Release
|
25
|
+
let(:body) { '[[Release-1.0]]' }
|
26
26
|
|
27
27
|
it 'removes dots' do
|
28
|
-
is_expected.to eq '[[Release
|
28
|
+
is_expected.to eq '[[Release-1.0|release-10]]'
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,7 +33,7 @@ describe Caramelize::SwapWikiLinks do
|
|
33
33
|
let(:body) { '[[Intra wiki link]]' }
|
34
34
|
|
35
35
|
it 'simples link to hyperlink' do
|
36
|
-
is_expected.to eq '[[Intra wiki link|
|
36
|
+
is_expected.to eq '[[Intra wiki link|intra_wiki_link]]'
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'replace in full file' do
|
@@ -17,7 +17,7 @@ describe Caramelize::InputWiki::Wiki do
|
|
17
17
|
|
18
18
|
context 'pages with revisions' do
|
19
19
|
it 'returns list of latest pages' do
|
20
|
-
wiki.titles = [
|
20
|
+
wiki.titles = %w[allosaurus brachiosaurus]
|
21
21
|
allow(wiki).to receive(:revisions_by_title)
|
22
22
|
.with('allosaurus').and_return([page1, page2])
|
23
23
|
allow(wiki).to receive(:revisions_by_title)
|
@@ -4,8 +4,9 @@ describe Caramelize::Page do
|
|
4
4
|
|
5
5
|
let(:message) { 'Dinosaurs really had feathers, do not forget!' }
|
6
6
|
let(:author) { OpenStruct.new(name: 'Jeff Goldblum', email: 'jeff.g@example.com') }
|
7
|
+
let(:title){ 'Feathered Dinosaurs' }
|
7
8
|
subject(:page) do
|
8
|
-
Caramelize::Page.new(
|
9
|
+
Caramelize::Page.new(title: title,
|
9
10
|
message: message,
|
10
11
|
time: Time.parse('2015-02-12'),
|
11
12
|
body: 'Dinosaurs are awesome and have feathers!',
|
@@ -31,6 +32,23 @@ describe Caramelize::Page do
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
describe '#path' do
|
36
|
+
context "title is 'Home'" do
|
37
|
+
let(:title) { 'Home' }
|
38
|
+
it { expect(page.path).to eq 'Home'}
|
39
|
+
end
|
40
|
+
|
41
|
+
context "title is 'Feathered Dinosaurs'" do
|
42
|
+
it { expect(page.path).to eq 'Feathered Dinosaurs'}
|
43
|
+
end
|
44
|
+
|
45
|
+
context "title is 'Space/Feathered Dinosaurs'" do
|
46
|
+
let(:title) { 'Space/Feathered Dinosaurs' }
|
47
|
+
it { expect(page.path).to eq 'Space/feathered dinosaurs'}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
34
52
|
describe '#commit_message' do
|
35
53
|
context 'page has message' do
|
36
54
|
it 'uses page.title' do
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caramelize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Senff
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: commander
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: gollum-lib
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: mysql2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: ruby-progressbar
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/caramelize/filters/remove_table_tab_line_endings.rb
|
191
191
|
- lib/caramelize/filters/swap_wiki_links.rb
|
192
192
|
- lib/caramelize/filters/wikka_to_markdown.rb
|
193
|
+
- lib/caramelize/health_check.rb
|
193
194
|
- lib/caramelize/input_wiki/redmine_wiki.rb
|
194
195
|
- lib/caramelize/input_wiki/wiki.rb
|
195
196
|
- lib/caramelize/input_wiki/wikkawiki.rb
|
@@ -215,7 +216,7 @@ homepage: http://github.com/Dahie/caramelize
|
|
215
216
|
licenses:
|
216
217
|
- MIT
|
217
218
|
metadata: {}
|
218
|
-
post_install_message:
|
219
|
+
post_install_message:
|
219
220
|
rdoc_options: []
|
220
221
|
require_paths:
|
221
222
|
- lib
|
@@ -230,8 +231,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
231
|
- !ruby/object:Gem::Version
|
231
232
|
version: '0'
|
232
233
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
234
|
-
signing_key:
|
234
|
+
rubygems_version: 3.4.22
|
235
|
+
signing_key:
|
235
236
|
specification_version: 4
|
236
237
|
summary: Flexible and modular wiki conversion tool
|
237
238
|
test_files:
|