allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [33/50] git commit: [#6534] ticket:442 added mediawiki handle in import
Date Fri, 04 Oct 2013 18:07:17 GMT
[#6534] ticket:442 added mediawiki handle in import


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e6878f19
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e6878f19
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e6878f19

Branch: refs/heads/cj/6692
Commit: e6878f19537e5b4e9924a001af89a6af88c42372
Parents: d2eedf4
Author: coldmind <sokandpal@yandex.ru>
Authored: Mon Sep 23 17:33:27 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:23 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6878f19/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 629b0e9..68f206b 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -51,6 +51,8 @@ from forgeimporters.base import (
         )
 from forgeimporters.github import GitHubProjectExtractor
 from forgewiki import model as WM
+from forgewiki.converters import mediawiki2markdown
+
 
 import logging
 log = logging.getLogger(__name__)
@@ -192,7 +194,7 @@ class GitHubWikiImporter(ToolImporter):
         name = self._convert_page_name(name)
         wiki_page = WM.Page.upsert(name)
         if filename in commit.tree:
-            wiki_page.text = self.convert_markup(h.really_unicode(text), filename)
+            wiki_page.text = self.convert_markup(h.really_unicode(text), filename, ext)
             wiki_page.timestamp = wiki_page.mod_date = mod_date
             wiki_page.viewable_by = ['all']
         else:
@@ -216,7 +218,7 @@ class GitHubWikiImporter(ToolImporter):
                 self._with_history(commit)
         rmtree(wiki_path)
 
-    def convert_markup(self, text, filename):
+    def convert_markup(self, text, filename, ext):
         """Convert any supported github markup into Allura-markdown.
 
         Conversion happens in 4 phases:
@@ -233,9 +235,14 @@ class GitHubWikiImporter(ToolImporter):
         except ImportError:
             html2text = None
 
-        text = h.render_any_markup(filename, text)
+        if html2text and ext in ['md', 'mediawiki']:
+            text = mediawiki2markdown(text)
+            text = self.convert_gollum_tags(text)
+        else:    
+            text = h.render_any_markup(filename, text)
+        
         text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
-        if html2text:
+        if html2text and ext not in ['md', 'mediawiki']:
             text = html2text.html2text(text)
             text = self.convert_gollum_tags(text)
         return text


Mime
View raw message