Skip to content

Commit 37b3059

Browse files
authored
Merge pull request #29 from Dahie/add-mediawiki
Add mediawiki
2 parents ace5bbb + 0e24191 commit 37b3059

28 files changed

+437
-128
lines changed

.github/workflows/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88

9-
109
steps:
1110
- uses: actions/checkout@v3
12-
# - name: Set up Redis
13-
# uses: zhulik/redis-action@1.1.0
11+
- uses: r-lib/actions/setup-pandoc@v2
12+
with:
13+
pandoc-version: '3.1.11'
1414
- name: Install Ruby and gems
1515
uses: ruby/setup-ruby@v1
1616
with:

.rubocop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
inherit_from: .rubocop_todo.yml
2+
13
require:
24
- rubocop-rake
35
- rubocop-rspec
6+
- rubocop-performance
47

58
AllCops:
69
NewCops: enable

.rubocop_todo.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2024-03-03 10:06:52 UTC using RuboCop version 1.60.2.
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: 2
16+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
17+
Metrics/AbcSize:
18+
Max: 79
19+
20+
# Offense count: 1
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: 2
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'

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ gem 'guard-rspec'
1212
gem 'rake'
1313
gem 'rspec'
1414
gem 'rubocop'
15+
gem 'rubocop-performance'
1516
gem 'rubocop-rake'
1617
gem 'rubocop-rspec'

Gemfile.lock

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
PATH
22
remote: .
33
specs:
4-
caramelize (1.2.1)
4+
caramelize (1.3.0)
55
commander
66
gollum-lib
77
mysql2
8+
paru
89
ruby-progressbar
910

1011
GEM
@@ -50,7 +51,7 @@ GEM
5051
highline (3.0.1)
5152
json (2.7.1)
5253
language_server-protocol (3.17.0.3)
53-
listen (3.8.0)
54+
listen (3.9.0)
5455
rb-fsevent (~> 0.10, >= 0.10.3)
5556
rb-inotify (~> 0.9, >= 0.9.10)
5657
loofah (2.22.0)
@@ -60,7 +61,7 @@ GEM
6061
method_source (1.0.0)
6162
mime-types (3.5.2)
6263
mime-types-data (~> 3.2015)
63-
mime-types-data (3.2023.1205)
64+
mime-types-data (3.2024.0206)
6465
mini_portile2 (2.8.5)
6566
mysql2 (0.5.6)
6667
nenv (0.3.0)
@@ -74,6 +75,7 @@ GEM
7475
parser (3.3.0.5)
7576
ast (~> 2.4.1)
7677
racc
78+
paru (1.2.0)
7779
pry (0.14.2)
7880
coderay (~> 1.1)
7981
method_source (~> 1.0)
@@ -98,8 +100,8 @@ GEM
98100
rspec-mocks (3.13.0)
99101
diff-lcs (>= 1.2.0, < 2.0)
100102
rspec-support (~> 3.13.0)
101-
rspec-support (3.13.0)
102-
rubocop (1.60.2)
103+
rspec-support (3.13.1)
104+
rubocop (1.61.0)
103105
json (~> 2.3)
104106
language_server-protocol (>= 3.17.0)
105107
parallel (~> 1.10)
@@ -110,22 +112,25 @@ GEM
110112
rubocop-ast (>= 1.30.0, < 2.0)
111113
ruby-progressbar (~> 1.7)
112114
unicode-display_width (>= 2.4.0, < 3.0)
113-
rubocop-ast (1.30.0)
114-
parser (>= 3.2.1.0)
115+
rubocop-ast (1.31.1)
116+
parser (>= 3.3.0.4)
115117
rubocop-capybara (2.20.0)
116118
rubocop (~> 1.41)
117119
rubocop-factory_bot (2.25.1)
118120
rubocop (~> 1.41)
121+
rubocop-performance (1.18.0)
122+
rubocop (>= 1.7.0, < 2.0)
123+
rubocop-ast (>= 0.4.0)
119124
rubocop-rake (0.6.0)
120125
rubocop (~> 1.0)
121-
rubocop-rspec (2.26.1)
126+
rubocop-rspec (2.27.0)
122127
rubocop (~> 1.40)
123128
rubocop-capybara (~> 2.17)
124129
rubocop-factory_bot (~> 2.22)
125130
ruby-progressbar (1.13.0)
126-
rugged (1.7.1)
131+
rugged (1.7.2)
127132
shellany (0.0.1)
128-
thor (1.3.0)
133+
thor (1.3.1)
129134
twitter-text (1.14.7)
130135
unf (~> 0.1.0)
131136
unf (0.1.4)
@@ -145,6 +150,7 @@ DEPENDENCIES
145150
rake
146151
rspec
147152
rubocop
153+
rubocop-performance
148154
rubocop-rake
149155
rubocop-rspec
150156

README.md

+54-21
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,80 @@
22

33
[![Maintainability](https://api.codeclimate.com/v1/badges/7fe3ef34e09ba8133424/maintainability)](https://codeclimate.com/github/Dahie/caramelize/maintainability)
44

5-
Caramelize is a compact and flexible wiki content migration tool. It is intended for easi transfer of content from 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.
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/).
68

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.
89

910
## Usage
1011

1112
### Installation
1213

13-
$ gem install caramelize
14+
```sh
15+
$ gem install caramelize
16+
```
1417

1518
Install the latest release of caramelize using RubyGems.
19+
Requires pandoc to be installed.
1620

1721
### Use
1822

19-
$ caramelize create
23+
```sh
24+
$ caramelize create
25+
```
2026

2127
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.
2228

23-
$ caramelize run
29+
```sh
30+
$ caramelize run
31+
```
2432

2533
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.
2634

27-
$ caramelize doctor
35+
```sh
36+
$ caramelize doctor
37+
```
2838

2939
Can be used to assess the quality of your wiki conversion. It'll help you see
3040
how many wiki links may be broken and how many pages were orphaned.
3141

32-
$ caramelize help
42+
```sh
43+
$ caramelize help
44+
```
3345

3446
Returns help information.
3547

36-
$ caramelize version
48+
```sh
49+
$ caramelize version
50+
```
3751

3852
Returns version and release information.
3953

4054
### Options
4155

42-
$ caramelize create --config my_caramel_configuration.rb
56+
```sh
57+
$ caramelize create --config my_caramel_configuration.rb
58+
```
4359

4460
Creates an example configuration by the given name.
4561

46-
$ caramelize run --config my_caramel_configuration.rb
62+
```sh
63+
$ caramelize run --config my_caramel_configuration.rb
64+
```
4765

4866
Executes the given configuration.
4967

50-
$ caramelize --verbose [command]
68+
```sh
69+
$ caramelize --verbose [command]
70+
```
5171

5272
Displays more verbose output to the command line.
5373

5474
## Content migration
5575

5676
### Wiki support
5777

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.
5979
More custom wikis can be supported by creating a suitable configuration file.
6080

6181
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/).
@@ -76,7 +96,7 @@ Since wiki software may have special features, that are not common among other w
7696

7797
### Configuration recipes
7898

79-
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.
80100
You also find the predefined definitions for importing from WikkaWiki and Redmine and and example for a custom import.
81101

82102
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.
@@ -123,41 +143,54 @@ end
123143

124144
In the end the `wiki` instance needs the `titles` and `revisions` filled.
125145

126-
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 alot of freedom in writing your configuration, but also a lot of power to break things for yourself. Be advised.**
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.**
127147

128148
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).
129149

130150
### Building
131151

132152
This is how you can build caramelize, in case you'd like to develop it further. To get startered you'll need Bundler.
133153

134-
$ gem install bundler
154+
```sh
155+
$ gem install bundler
156+
```
135157

136158
Clone or fork this repository and start building.
137159

138-
$ git clone git@github.com:Dahie/caramelize.git
139-
$ gem build caramelize.gemspec
160+
```sh
161+
$ git clone git@github.com:Dahie/caramelize.git
162+
$ gem build caramelize.gemspec
163+
```
140164

141165
Now to build and package the gem do
142166

143-
$ rake build
167+
```sh
168+
$ rake build
169+
```
144170

145171
or
146172

147-
$ rake install
173+
```sh
174+
$ rake install
175+
```
148176

149177
to install the new gem right to your system.
150178

179+
Tests run with
180+
181+
```sh
182+
$ rspec
183+
```
184+
151185
## Contributing to caramelize
152186

153-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
187+
* Check out the latest main to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
154188
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
155189
* Fork the project
156190
* Start a feature/bugfix branch
157191
* Commit and push until you are happy with your contribution
158192
* 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.
159193

160-
161194
## Copyright
162195

163196
Copyright (c) 2011-2024 Daniel Senff. See LICENSE.md for further details.

caramelize.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
2222
spec.add_dependency('commander')
2323
spec.add_dependency('gollum-lib')
2424
spec.add_dependency('mysql2')
25+
spec.add_dependency('paru')
2526
spec.add_dependency('ruby-progressbar')
2627

2728
spec.metadata['rubygems_mfa_required'] = 'true'

lib/caramelize.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
require 'caramelize/version'
44
require 'caramelize/page'
5-
require 'caramelize/content_transferer'
6-
require 'caramelize/filter_processor'
75
require 'caramelize/database_connector'
6+
require 'caramelize/filters/add_newline_to_page_end'
7+
require 'caramelize/filter_processor'
8+
require 'caramelize/input_wiki/wiki'
9+
require 'caramelize/input_wiki/media_wiki'
10+
require 'caramelize/input_wiki/redmine_wiki'
11+
require 'caramelize/input_wiki/wikka_wiki'
12+
require 'caramelize/content_transferer'
813
require 'caramelize/health_check'
914
require 'caramelize/health_checks/home_page_check'
1015
require 'caramelize/health_checks/orphaned_pages_check'
1116
require 'caramelize/health_checks/page'
1217
require 'caramelize/output_wiki/gollum'
1318
require 'caramelize/services/page_builder'
14-
require 'caramelize/input_wiki/wiki'
15-
require 'caramelize/input_wiki/redmine_wiki'
16-
require 'caramelize/input_wiki/wikkawiki'
1719

1820
Encoding.default_external = Encoding::UTF_8
1921
Encoding.default_internal = Encoding::UTF_8

0 commit comments

Comments
 (0)