caramelize 1.2.0 → 1.3.0
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 +3 -1
- data/.rubocop_todo.yml +55 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +28 -22
- data/README.md +88 -50
- data/caramelize.gemspec +1 -9
- data/lib/caramelize/caramel.rb +10 -1
- data/lib/caramelize/content_transferer.rb +41 -31
- data/lib/caramelize/filters/add_newline_to_page_end.rb +20 -0
- data/lib/caramelize/filters/camel_case_to_wiki_links.rb +2 -2
- data/lib/caramelize/filters/mediawiki_to_markdown.rb +21 -0
- data/lib/caramelize/filters/swap_wiki_links.rb +2 -2
- data/lib/caramelize/filters/wikka_to_markdown.rb +15 -6
- data/lib/caramelize/health_checks/home_page_check.rb +1 -1
- data/lib/caramelize/input_wiki/media_wiki.rb +114 -0
- data/lib/caramelize/input_wiki/redmine_wiki.rb +6 -8
- data/lib/caramelize/input_wiki/wiki.rb +5 -5
- data/lib/caramelize/input_wiki/{wikkawiki.rb → wikka_wiki.rb} +6 -10
- data/lib/caramelize/output_wiki/gollum.rb +1 -1
- data/lib/caramelize/page.rb +1 -1
- data/lib/caramelize/version.rb +1 -1
- data/lib/caramelize.rb +7 -5
- data/samples/media_wiki.rb +14 -0
- data/spec/lib/caramelize/filter_processor_spec.rb +5 -3
- data/spec/lib/caramelize/filters/{add_newline_on_page_end_spec.rb → add_newline_to_page_end_spec.rb} +1 -1
- data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +3 -1
- data/spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb +27 -0
- data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +5 -3
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +3 -1
- data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +41 -31
- data/spec/lib/caramelize/input_wiki/media_wiki_spec.rb +13 -0
- data/spec/lib/caramelize/input_wiki/wiki_spec.rb +13 -13
- data/spec/lib/caramelize/input_wiki/wikka_wiki_spec.rb +13 -0
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +9 -7
- metadata +17 -119
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 949bb3270455131310d65fd3e8e7f7dae80c9012aa4497efb479c8d77a0f8be8
|
4
|
+
data.tar.gz: 3ba47fd373b387b1935e9c56315784f89d00f71a35e34a33816578098e1219eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b60fb485ca76922faa32e6c91c8e69f3e639cbcd009abd47eb555bf9f9e3d4a02cfff0f6fd29452321c65231a87e0169b5cea853543489654b44cf8399c888
|
7
|
+
data.tar.gz: f6bf9599cdff4c248e2393e63e476ce9adbb2a7de9ec9fd07bc180a19e8d4bd64265649c6ada7721902bbd5906c24d4628f8e766efa4006bfa9f5fc8931636ab
|
@@ -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
|
+
steps:
|
10
|
+
- uses: actions/checkout@v3
|
11
|
+
- uses: r-lib/actions/setup-pandoc@v2
|
12
|
+
with:
|
13
|
+
pandoc-version: '3.1.11'
|
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
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
require:
|
2
4
|
- rubocop-rake
|
3
5
|
- rubocop-rspec
|
6
|
+
- rubocop-performance
|
4
7
|
|
5
8
|
AllCops:
|
6
9
|
NewCops: enable
|
@@ -14,7 +17,6 @@ AllCops:
|
|
14
17
|
TargetRubyVersion: 3.1
|
15
18
|
SuggestExtensions: false
|
16
19
|
|
17
|
-
|
18
20
|
Style/Documentation:
|
19
21
|
Enabled: false
|
20
22
|
StyleGuide: http://relaxed.ruby.style/#styledocumentation
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2024-03-04 19:34:06 UTC using RuboCop version 1.61.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
11
|
+
Lint/NestedMethodDefinition:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/caramelize/filters/textile_to_markdown.rb'
|
14
|
+
|
15
|
+
# Offense count: 5
|
16
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
17
|
+
Metrics/AbcSize:
|
18
|
+
Max: 79
|
19
|
+
|
20
|
+
# Offense count: 2
|
21
|
+
# Configuration parameters: CountComments, CountAsOne.
|
22
|
+
Metrics/ClassLength:
|
23
|
+
Max: 118
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Max: 9
|
29
|
+
|
30
|
+
# Offense count: 10
|
31
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
32
|
+
Metrics/MethodLength:
|
33
|
+
Max: 102
|
34
|
+
|
35
|
+
# Offense count: 1
|
36
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
37
|
+
Metrics/PerceivedComplexity:
|
38
|
+
Max: 9
|
39
|
+
|
40
|
+
# Offense count: 2
|
41
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
42
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
43
|
+
RSpec/FilePath:
|
44
|
+
Exclude:
|
45
|
+
- 'spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb'
|
46
|
+
- 'spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb'
|
47
|
+
|
48
|
+
# Offense count: 2
|
49
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
50
|
+
# Include: **/*_spec.rb
|
51
|
+
RSpec/SpecFilePathFormat:
|
52
|
+
Exclude:
|
53
|
+
- '**/spec/routing/**/*'
|
54
|
+
- 'spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb'
|
55
|
+
- 'spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb'
|
data/Gemfile
CHANGED
@@ -4,3 +4,14 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in testgem.gemspec
|
6
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-performance'
|
16
|
+
gem 'rubocop-rake'
|
17
|
+
gem 'rubocop-rspec'
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
caramelize (1.
|
4
|
+
caramelize (1.3.0)
|
5
5
|
commander
|
6
6
|
gollum-lib
|
7
7
|
mysql2
|
8
|
+
paru
|
8
9
|
ruby-progressbar
|
9
10
|
|
10
11
|
GEM
|
@@ -50,7 +51,7 @@ GEM
|
|
50
51
|
highline (3.0.1)
|
51
52
|
json (2.7.1)
|
52
53
|
language_server-protocol (3.17.0.3)
|
53
|
-
listen (3.
|
54
|
+
listen (3.9.0)
|
54
55
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
55
56
|
rb-inotify (~> 0.9, >= 0.9.10)
|
56
57
|
loofah (2.22.0)
|
@@ -60,11 +61,11 @@ GEM
|
|
60
61
|
method_source (1.0.0)
|
61
62
|
mime-types (3.5.2)
|
62
63
|
mime-types-data (~> 3.2015)
|
63
|
-
mime-types-data (3.
|
64
|
+
mime-types-data (3.2024.0206)
|
64
65
|
mini_portile2 (2.8.5)
|
65
|
-
mysql2 (0.5.
|
66
|
+
mysql2 (0.5.6)
|
66
67
|
nenv (0.3.0)
|
67
|
-
nokogiri (1.16.
|
68
|
+
nokogiri (1.16.2)
|
68
69
|
mini_portile2 (~> 2.8.2)
|
69
70
|
racc (~> 1.4)
|
70
71
|
notiffany (0.1.3)
|
@@ -74,6 +75,7 @@ GEM
|
|
74
75
|
parser (3.3.0.5)
|
75
76
|
ast (~> 2.4.1)
|
76
77
|
racc
|
78
|
+
paru (1.2.0)
|
77
79
|
pry (0.14.2)
|
78
80
|
coderay (~> 1.1)
|
79
81
|
method_source (~> 1.0)
|
@@ -86,20 +88,20 @@ GEM
|
|
86
88
|
regexp_parser (2.9.0)
|
87
89
|
rexml (3.2.6)
|
88
90
|
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.
|
91
|
+
rspec (3.13.0)
|
92
|
+
rspec-core (~> 3.13.0)
|
93
|
+
rspec-expectations (~> 3.13.0)
|
94
|
+
rspec-mocks (~> 3.13.0)
|
95
|
+
rspec-core (3.13.0)
|
96
|
+
rspec-support (~> 3.13.0)
|
97
|
+
rspec-expectations (3.13.0)
|
96
98
|
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
-
rspec-support (~> 3.
|
98
|
-
rspec-mocks (3.
|
99
|
+
rspec-support (~> 3.13.0)
|
100
|
+
rspec-mocks (3.13.0)
|
99
101
|
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
-
rspec-support (~> 3.
|
101
|
-
rspec-support (3.
|
102
|
-
rubocop (1.
|
102
|
+
rspec-support (~> 3.13.0)
|
103
|
+
rspec-support (3.13.1)
|
104
|
+
rubocop (1.61.0)
|
103
105
|
json (~> 2.3)
|
104
106
|
language_server-protocol (>= 3.17.0)
|
105
107
|
parallel (~> 1.10)
|
@@ -110,22 +112,25 @@ GEM
|
|
110
112
|
rubocop-ast (>= 1.30.0, < 2.0)
|
111
113
|
ruby-progressbar (~> 1.7)
|
112
114
|
unicode-display_width (>= 2.4.0, < 3.0)
|
113
|
-
rubocop-ast (1.
|
114
|
-
parser (>= 3.
|
115
|
+
rubocop-ast (1.31.1)
|
116
|
+
parser (>= 3.3.0.4)
|
115
117
|
rubocop-capybara (2.20.0)
|
116
118
|
rubocop (~> 1.41)
|
117
119
|
rubocop-factory_bot (2.25.1)
|
118
120
|
rubocop (~> 1.41)
|
121
|
+
rubocop-performance (1.18.0)
|
122
|
+
rubocop (>= 1.7.0, < 2.0)
|
123
|
+
rubocop-ast (>= 0.4.0)
|
119
124
|
rubocop-rake (0.6.0)
|
120
125
|
rubocop (~> 1.0)
|
121
|
-
rubocop-rspec (2.
|
126
|
+
rubocop-rspec (2.27.1)
|
122
127
|
rubocop (~> 1.40)
|
123
128
|
rubocop-capybara (~> 2.17)
|
124
129
|
rubocop-factory_bot (~> 2.22)
|
125
130
|
ruby-progressbar (1.13.0)
|
126
|
-
rugged (1.7.
|
131
|
+
rugged (1.7.2)
|
127
132
|
shellany (0.0.1)
|
128
|
-
thor (1.3.
|
133
|
+
thor (1.3.1)
|
129
134
|
twitter-text (1.14.7)
|
130
135
|
unf (~> 0.1.0)
|
131
136
|
unf (0.1.4)
|
@@ -145,6 +150,7 @@ DEPENDENCIES
|
|
145
150
|
rake
|
146
151
|
rspec
|
147
152
|
rubocop
|
153
|
+
rubocop-performance
|
148
154
|
rubocop-rake
|
149
155
|
rubocop-rspec
|
150
156
|
|
data/README.md
CHANGED
@@ -2,52 +2,72 @@
|
|
2
2
|
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/7fe3ef34e09ba8133424/maintainability)](https://codeclimate.com/github/Dahie/caramelize/maintainability)
|
4
4
|
|
5
|
-
Caramelize is a compact and flexible wiki
|
5
|
+
Caramelize is a compact and flexible wiki migration tool. It is intended for easy transfer of content from legacy wikis. With caramelize you can create your own export configurations and migrate your page revisions into a git repository of markdown files. This retains all your history and you gain the most flexible access to your wiki content available for use with git-based wikis like [gollum](https://github.com/github/gollum), [Otter Wiki](https://github.com/redimp/otterwiki), [Wiki.js](https://js.wiki/) or [Obsidian](https://obsidian.md/).
|
6
|
+
|
7
|
+
By default, it ships with configurations for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/).
|
6
8
|
|
7
|
-
In the future more target wikis may be added. For the moment migration is supported for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
|
8
9
|
|
9
10
|
## Usage
|
10
11
|
|
11
12
|
### Installation
|
12
13
|
|
13
|
-
|
14
|
+
```sh
|
15
|
+
$ gem install caramelize
|
16
|
+
```
|
14
17
|
|
15
18
|
Install the latest release of caramelize using RubyGems.
|
19
|
+
Requires pandoc to be installed.
|
16
20
|
|
17
21
|
### Use
|
18
22
|
|
19
|
-
|
23
|
+
```sh
|
24
|
+
$ caramelize create
|
25
|
+
```
|
20
26
|
|
21
27
|
Creates a template configuration file "caramel.rb". This includes documentation on how to use the preset Wiki-connectors and how to write addition customized connectors. More about this below.
|
22
28
|
|
23
|
-
|
29
|
+
```sh
|
30
|
+
$ caramelize run
|
31
|
+
```
|
24
32
|
|
25
33
|
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
34
|
|
27
|
-
|
35
|
+
```sh
|
36
|
+
$ caramelize doctor
|
37
|
+
```
|
28
38
|
|
29
39
|
Can be used to assess the quality of your wiki conversion. It'll help you see
|
30
40
|
how many wiki links may be broken and how many pages were orphaned.
|
31
41
|
|
32
|
-
|
42
|
+
```sh
|
43
|
+
$ caramelize help
|
44
|
+
```
|
33
45
|
|
34
46
|
Returns help information.
|
35
47
|
|
36
|
-
|
48
|
+
```sh
|
49
|
+
$ caramelize version
|
50
|
+
```
|
37
51
|
|
38
52
|
Returns version and release information.
|
39
53
|
|
40
54
|
### Options
|
41
55
|
|
42
|
-
|
56
|
+
```sh
|
57
|
+
$ caramelize create --config my_caramel_configuration.rb
|
58
|
+
```
|
43
59
|
|
44
60
|
Creates an example configuration by the given name.
|
45
61
|
|
46
|
-
|
62
|
+
```sh
|
63
|
+
$ caramelize run --config my_caramel_configuration.rb
|
64
|
+
```
|
47
65
|
|
48
66
|
Executes the given configuration.
|
49
67
|
|
50
|
-
|
68
|
+
```sh
|
69
|
+
$ caramelize --verbose [command]
|
70
|
+
```
|
51
71
|
|
52
72
|
Displays more verbose output to the command line.
|
53
73
|
|
@@ -55,10 +75,11 @@ Displays more verbose output to the command line.
|
|
55
75
|
|
56
76
|
### Wiki support
|
57
77
|
|
58
|
-
Caramelize comes with direct support for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
|
78
|
+
Caramelize comes with direct support for [MediaWiki](https://www.mediawiki.org), [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
|
59
79
|
More custom wikis can be supported by creating a suitable configuration file.
|
60
80
|
|
61
|
-
|
81
|
+
The wiki is exported to markdown files in a git-repository. This can be directly used as source for [gollum](https://github.com/github/gollum) wiki, [Otter Wiki](https://github.com/redimp/otterwiki), or if you don't care about the history even [Obsidian](https://obsidian.md/).
|
82
|
+
This gives you the flexibility of having all wiki pages exported as physical files, while keeping the history and having an easy and wide-supported way of access.
|
62
83
|
|
63
84
|
Since wiki software may have special features, that are not common among other wikis, content migration may always have a loss of style or information. Caramelize tries to support the most common features.
|
64
85
|
|
@@ -75,50 +96,54 @@ Since wiki software may have special features, that are not common among other w
|
|
75
96
|
|
76
97
|
### Configuration recipes
|
77
98
|
|
78
|
-
The `caramel.rb` configuration contains the settings on how to import the data of the existing wiki and how to convert it into the format required by caramelize to export to gollum.
|
99
|
+
The `lib/caramelize/caramel.rb` configuration contains the settings on how to import the data of the existing wiki and how to convert it into the format required by caramelize to export to gollum.
|
79
100
|
You also find the predefined definitions for importing from WikkaWiki and Redmine and and example for a custom import.
|
80
101
|
|
81
102
|
Custom import allows you to import data from wikis that are not natively supported by caramelize. Defining your own wiki import requires a bit of knowledge on Ruby and MySQL as you setup the access to your wiki database and need to define how the data is to be transformed. Depending on the database model of the wiki this can be one simple call for all revisions in the database, or it can get more complicated with multiple mysql-calls as the database becomes more complex.
|
82
103
|
|
83
104
|
For a custom wiki you need to create a `wiki` instance object, that receives the necessary database creditials.
|
84
105
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
106
|
+
```ruby
|
107
|
+
wiki = Caramelize::InputWiki::Wiki.new(host: "localhost",
|
108
|
+
username: "user",
|
109
|
+
database: "database_name",
|
110
|
+
password: 'monkey',
|
111
|
+
markup: :wikka})
|
112
|
+
```
|
90
113
|
|
91
114
|
This example ignores custom markup conversion and assumes WikkaWiki-markup.
|
92
115
|
|
93
116
|
Once the object is established we need to hook in a method that defines how revisions are read from the database and how they are processed.
|
94
117
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
# titles is the list of all unique page titles contained in the wiki
|
114
|
-
titles.uniq!
|
115
|
-
# revisions is the list of all revisions ordered by date
|
116
|
-
revisions
|
118
|
+
```ruby
|
119
|
+
wiki.instance_eval do
|
120
|
+
def read_pages
|
121
|
+
sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
|
122
|
+
revisions, titles = [], []
|
123
|
+
results = database.query(sql)
|
124
|
+
results.each do |row|
|
125
|
+
titles << row["tag"]
|
126
|
+
author = authors[row["user"]]
|
127
|
+
page = Page.new({id: row["id"],
|
128
|
+
title: row["tag"],
|
129
|
+
body: row["body"],
|
130
|
+
markup: 'wikka',
|
131
|
+
latest: row["latest"] == "Y",
|
132
|
+
time: row["time"],
|
133
|
+
message: row["note"],
|
134
|
+
author: author})
|
135
|
+
revisions << page
|
117
136
|
end
|
137
|
+
# titles is the list of all unique page titles contained in the wiki
|
138
|
+
titles.uniq!
|
139
|
+
# revisions is the list of all revisions ordered by date
|
140
|
+
revisions
|
141
|
+
end
|
142
|
+
```
|
118
143
|
|
119
144
|
In the end the `wiki` instance needs the `titles` and `revisions` filled.
|
120
145
|
|
121
|
-
Some wikis don't have all necessary metadata saved in the revision. In this case additional database queries are necessary. **The configuration recipe is pure ruby code, that is included on execution. This gives you
|
146
|
+
Some wikis don't have all necessary metadata saved in the revision. In this case additional database queries are necessary. **The configuration recipe is pure ruby code, that is included on execution. This gives you a lot of freedom in writing your configuration, but also a lot of power to break things. Be advised.**
|
122
147
|
|
123
148
|
I'm happy to give support on your recipes and I'd also like to extend caramelize with more wiki modules, if you send in your configurations (minus database credentials of course).
|
124
149
|
|
@@ -126,33 +151,46 @@ I'm happy to give support on your recipes and I'd also like to extend caramelize
|
|
126
151
|
|
127
152
|
This is how you can build caramelize, in case you'd like to develop it further. To get startered you'll need Bundler.
|
128
153
|
|
129
|
-
|
154
|
+
```sh
|
155
|
+
$ gem install bundler
|
156
|
+
```
|
130
157
|
|
131
158
|
Clone or fork this repository and start building.
|
132
159
|
|
133
|
-
|
134
|
-
|
160
|
+
```sh
|
161
|
+
$ git clone git@github.com:Dahie/caramelize.git
|
162
|
+
$ gem build caramelize.gemspec
|
163
|
+
```
|
135
164
|
|
136
165
|
Now to build and package the gem do
|
137
166
|
|
138
|
-
|
167
|
+
```sh
|
168
|
+
$ rake build
|
169
|
+
```
|
139
170
|
|
140
171
|
or
|
141
172
|
|
142
|
-
|
173
|
+
```sh
|
174
|
+
$ rake install
|
175
|
+
```
|
143
176
|
|
144
177
|
to install the new gem right to your system.
|
145
178
|
|
179
|
+
Tests run with
|
180
|
+
|
181
|
+
```sh
|
182
|
+
$ rspec
|
183
|
+
```
|
184
|
+
|
146
185
|
## Contributing to caramelize
|
147
186
|
|
148
|
-
* Check out the latest
|
187
|
+
* Check out the latest main to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
149
188
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
150
189
|
* Fork the project
|
151
190
|
* Start a feature/bugfix branch
|
152
191
|
* Commit and push until you are happy with your contribution
|
153
192
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
154
193
|
|
155
|
-
|
156
194
|
## Copyright
|
157
195
|
|
158
|
-
Copyright (c) 2011-
|
196
|
+
Copyright (c) 2011-2024 Daniel Senff. See LICENSE.md for further details.
|
data/caramelize.gemspec
CHANGED
@@ -22,16 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency('commander')
|
23
23
|
spec.add_dependency('gollum-lib')
|
24
24
|
spec.add_dependency('mysql2')
|
25
|
+
spec.add_dependency('paru')
|
25
26
|
spec.add_dependency('ruby-progressbar')
|
26
27
|
|
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
28
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
37
29
|
end
|
data/lib/caramelize/caramel.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'caramelize/input_wiki/
|
3
|
+
require 'caramelize/input_wiki/media_wiki'
|
4
4
|
require 'caramelize/input_wiki/redmine_wiki'
|
5
|
+
require 'caramelize/input_wiki/wikka_wiki'
|
5
6
|
|
6
7
|
## Example caramelize configuration file
|
7
8
|
|
@@ -53,6 +54,14 @@ def predefined_wiki
|
|
53
54
|
# password: "root",
|
54
55
|
# database: "wikka" }
|
55
56
|
# return Caramelize::InputWiki::WikkaWiki.new(options)
|
57
|
+
#
|
58
|
+
# For connection to a MediaWiki-Database use this Connector
|
59
|
+
# By default it converts to markdown
|
60
|
+
# options = { host: "localhost",
|
61
|
+
# username: "root",
|
62
|
+
# password: "root",
|
63
|
+
# database: "my_wiki" }
|
64
|
+
# return Caramelize::InputWiki::MediaWiki.new(options)
|
56
65
|
|
57
66
|
# For connection to a Redmine-Database use this Connector
|
58
67
|
# Additional options:
|
@@ -5,10 +5,10 @@ require 'ruby-progressbar'
|
|
5
5
|
module Caramelize
|
6
6
|
require 'caramelize/page'
|
7
7
|
require 'caramelize/content_transferer'
|
8
|
-
require 'caramelize/database_connector'
|
9
8
|
require 'caramelize/output_wiki/gollum'
|
9
|
+
require 'caramelize/input_wiki/media_wiki'
|
10
10
|
require 'caramelize/input_wiki/redmine_wiki'
|
11
|
-
require 'caramelize/input_wiki/
|
11
|
+
require 'caramelize/input_wiki/wikka_wiki'
|
12
12
|
|
13
13
|
class ContentTransferer
|
14
14
|
attr_reader :input_wiki, :options
|
@@ -97,52 +97,62 @@ module Caramelize
|
|
97
97
|
def migrate_markup_of_latest_revisions
|
98
98
|
puts 'Convert latest revisions:' if verbose?
|
99
99
|
input_wiki.latest_revisions.each do |revision|
|
100
|
-
|
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
|
-
|
111
|
-
migrate_markup_of_revision(revision)
|
100
|
+
convert_markup_of_revision(revision)
|
112
101
|
end
|
113
102
|
end
|
114
103
|
|
115
104
|
def commit_history
|
116
105
|
output_wiki.commit_history(revisions, options) do |page, index|
|
117
|
-
|
118
|
-
puts "Exclude Page: #{page.title}" if verbose?
|
119
|
-
next
|
120
|
-
end
|
121
|
-
|
122
|
-
if verbose?
|
123
|
-
puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
|
124
|
-
else
|
125
|
-
commit_history_progress_bar.increment
|
126
|
-
end
|
106
|
+
commit_page(page, index)
|
127
107
|
end
|
128
108
|
end
|
129
109
|
|
130
|
-
def
|
110
|
+
def commit_page(page, index)
|
111
|
+
if input_wiki.excluded_pages.include?(page.title)
|
112
|
+
puts "Exclude Page: #{page.title}" if verbose?
|
113
|
+
return
|
114
|
+
end
|
115
|
+
|
116
|
+
if verbose?
|
117
|
+
puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
|
118
|
+
else
|
119
|
+
commit_history_progress_bar.increment
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def run_filter_processor_on_revision(revision)
|
131
124
|
body_new = filter_processor.run(revision.body)
|
132
125
|
|
133
126
|
return if body_new == revision.body
|
134
127
|
|
135
|
-
message = "Markup of '#{revision.title}' converted to #{target_markup}"
|
128
|
+
revision.message = "Markup of '#{revision.title}' converted to #{target_markup}"
|
129
|
+
|
130
|
+
commit_as_latest_page(revision)
|
131
|
+
end
|
132
|
+
|
133
|
+
def convert_markup_of_revision(revision)
|
134
|
+
if input_wiki.excluded_pages.include?(revision.title)
|
135
|
+
puts "Exclude Page: #{revision.title}" if verbose?
|
136
|
+
return
|
137
|
+
end
|
138
|
+
|
139
|
+
if verbose?
|
140
|
+
puts "Filter source: #{revision.title} #{revision.time}"
|
141
|
+
else
|
142
|
+
migrate_markup_progress_bar.increment
|
143
|
+
end
|
144
|
+
|
145
|
+
run_filter_processor_on_revision(revision)
|
146
|
+
end
|
136
147
|
|
137
|
-
|
138
|
-
output_wiki.commit_revision(build_revision_metadata(revision, body_new
|
148
|
+
def commit_as_latest_page(revision)
|
149
|
+
output_wiki.commit_revision(build_revision_metadata(revision, body_new), options[:markup])
|
139
150
|
end
|
140
151
|
|
141
|
-
def build_revision_metadata(revision, body_new
|
152
|
+
def build_revision_metadata(revision, body_new)
|
142
153
|
revision.body = body_new
|
143
154
|
revision.author = { name: DEFAULT_AUTHOR_NAME, email: DEFAULT_AUTHOR_EMAIL }
|
144
|
-
revision.time = Time.now
|
145
|
-
revision.message = message
|
155
|
+
revision.time = Time.zone.now
|
146
156
|
|
147
157
|
revision
|
148
158
|
end
|