incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [05/50] git commit: [#6534] ticket:416 Export only pages in supported formats
Date Fri, 04 Oct 2013 23:23:11 GMT
 [#6534] ticket:416 Export only pages in supported formats

 Repo might contain images and other stuff,
 we should export only files which contain wiki pages.


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

Branch: refs/heads/tv/6670
Commit: d874e32ca7f6d99bfd562fb67bdb5cb9f6021509
Parents: 59e7ba2
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Sep 10 16:52:17 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:19 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py | 32 +++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d874e32c/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 052364f..b652744 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -46,6 +46,26 @@ class GitHubWikiImporter(ToolImporter):
     tool_label = 'Wiki'
     tool_description = 'Import your wiki from GitHub'
     tool_option = {"history_github_wiki": "Import wiki revision history"}
+    # List of supported formats https://github.com/gollum/gollum/wiki#page-files
+    supported_formats = [
+            'asciidoc',
+            'creole',
+            'markdown',
+            'mdown',
+            'mkdn',
+            'mkd',
+            'md',
+            'org',
+            'pod',
+            'rdoc',
+            'rest.txt',
+            'rst.txt',
+            'rest',
+            'rst',
+            'textile',
+            'mediawiki',
+            'wiki'
+    ]
 
     def import_tool(self, project, user, project_name=None, mount_point=None, mount_label=None,
user_name=None,
                     tool_option=None, **kw):
@@ -69,7 +89,11 @@ class GitHubWikiImporter(ToolImporter):
 
     def get_blobs_without_history(self, commit):
         for page in commit.tree.blobs:
-            wiki_page = WM.Page.upsert(page.name.split('.')[0])
+            name, ext = page.name.split('.', 1)
+            if ext not in self.supported_formats:
+                log.info('Not a wiki page %s. Skipping.' % page.name)
+                continue
+            wiki_page = WM.Page.upsert(name)
             wiki_page.text = h.render_any_markup(page.name, h.really_unicode(page.data_stream.read()))
             wiki_page.timestamp = wiki_page.mod_date = datetime.utcfromtimestamp(commit.committed_date)
             wiki_page.viewable_by = ['all']
@@ -77,7 +101,11 @@ class GitHubWikiImporter(ToolImporter):
 
     def get_blobs_with_history(self, commit):
         for page_name in commit.stats.files.keys():
-            wiki_page = WM.Page.upsert(page_name.split('.')[0])
+            name, ext = page_name.split('.', 1)
+            if ext not in self.supported_formats:
+                log.info('Not a wiki page %s. Skipping.' % page_name)
+                continue
+            wiki_page = WM.Page.upsert(name)
             if page_name in commit.tree:
                 wiki_page.text = h.render_any_markup(
                     page_name,


Mime
View raw message