importing_mediawiki_content_into_dokuwiki
Importing Mediawiki Content into Dokuwiki
Beware, all shell code listings here are for zsh on Debian!
You need:
- A working Dokuwiki instance
- API access to your mediawiki
- For importing users: Access to the database of your Mediawiki installation
- yamdwe: Github
- As of 2018-11-05, using a MariaDB 10.2 and yamdwe with a virtualenv, I had to install libmariadb-dev and libmariadb-dev-compat in version 2.* to compile MySQL-python
- Import pages and media using yamdwe.py
- Import users using yamdwe_users.py
cd
into your Dokuwiki installation directory- Add page titles from the page file names:
for f in $(find data/pages/ -maxdepth 1 -type f) ; do t=$(echo $f | sed -E -e 's#^.+/(.+)\.txt$#\1#' -e 's#_# #g' -e 's#\b.#\u&#g') cp "$f" "$f.backup" sed -i "1i====== $t ======\\n" $f done
- I only had pages in the root namespace,
find data/pages/ -maxdepth 1 -type f
finds all those - The first
sed
builds the page title and uses extended regex (-E
):s#^.+/(.+)\.txt$#\1#
strips .txt from the file names#_# #g
replaces underscores with spacess#\b.#\u&#g
converts the string to Title Case
- The second sed inserts (
i
)====== $t ======\\n
as the first line (1
)
- Check your pages
- Maybe fix the page file permissions and page titles (title case doesn't work well for most abbreviations…)
- Delete backups:
find data/pages -maxdepth 1 -type f -name \*.txt.backup -execdir rm \{\} \;
- yamdwe inserted a comment at the bottom of the imported mediawiki main page, delete that maybe
Example Listing
# Install Dokuwiki # Install libmariadb-dev and libmariadb-dev-compat in version 2.* > git clone https://github.com/projectgus/yamdwe.git > cd yamdwe > virtualenv -p python2.7 env > pip install -r requirements.txt > python yamdwe.py https://mediawiki.example.org/api.php path/to/dokuwiki > touch path/to/dokuwiki/conf/local.php > python yamdwe_users.py -u mediawiki --db wiki path/to/dokuwiki > for f in $(find data/pages/ -maxdepth 1 -type f) ; do t=$(echo $f | sed -E -e 's#^.+/(.+)\.txt$#\1#' -e 's#_# #g' -e 's#\b.#\u&#g'); cp "$f" "$f.backup" ; sed -i "1i======$t======\\n" $f ; done # Check your pages! > find data/pages -maxdepth 1 -type f -name \*.txt.backup -execdir rm \{\} \;
importing_mediawiki_content_into_dokuwiki.txt · Zuletzt geändert: 2020-02-10 22:11 von fanir