incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [14/43] git commit: [#6622] ticket:435 Convert markdown in wiki
Date Thu, 14 Nov 2013 17:36:35 GMT
[#6622] ticket:435 Convert markdown in wiki


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

Branch: refs/heads/cj/6836
Commit: 23db53ae5e8a8fed6796ecc5529468f009985ae8
Parents: 88365c6
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Oct 14 16:52:09 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/tests/test_wiki.py    | 31 +++++++++++++++++---
 ForgeImporters/forgeimporters/github/wiki.py    | 11 +++++--
 2 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/23db53ae/ForgeImporters/forgeimporters/github/tests/test_wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_wiki.py b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
index 50c905d..ea54b10 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -28,6 +28,7 @@ from allura.tests import TestController
 from allura.tests.decorators import with_tool, without_module
 from alluratest.controller import setup_basic_test
 from forgeimporters.github.wiki import GitHubWikiImporter
+from forgeimporters.github.utils import GitHubMarkdownConverter
 
 
 # important to be distinct from 'test' which ForgeWiki uses, so that the tests can run in
parallel and not clobber each other
@@ -290,6 +291,7 @@ Our website is <http://sf.net>.
         importer.github_wiki_url = 'https://github.com/a/b/wiki'
         importer.app = Mock()
         importer.app.url = '/p/test/wiki/'
+        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'proj', 'p',
'mount')
         f = importer.convert_markup
         source = u'''Look at [[this page|Some Page]]
 
@@ -299,12 +301,33 @@ Our website is [[http://sf.net]].
 
 '[[Escaped Tag]]
 
-[External link to the wiki page](https://github.com/a/b/wiki/Page)
+```python
+codeblock
+```
 
-[External link](https://github.com/a/b/issues/1)'''
+ticket #1
 
-        # markdown should be untouched
-        assert_equal(f(source, 'test.md'), source)
+#1 header
+
+sha aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'''
+        result = u'''Look at [this page](Some Page)
+
+More info at: [MoreInfo] [Even More Info]
+
+Our website is <http://sf.net>.
+
+[[Escaped Tag]]
+
+~~~~
+codeblock
+~~~~
+
+ticket [#1]
+
+#1 header
+
+sha [aaaaaa]'''
+        assert_equal(f(source, 'test.md').strip(), result)
 
         assert_equal(f(u'h1. Hello', 't.textile').strip(), u'# Hello')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/23db53ae/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 4bf796c..1290224 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -155,6 +155,12 @@ class GitHubWikiImporter(ToolImporter):
         )
         with_history = tool_option == 'import_history'
         ThreadLocalORMSession.flush_all()
+        self.github_markdown_converter = GitHubMarkdownConverter(
+            user_name,
+            project_name,
+            project.shortname,
+            self.app.config.options.mount_point,
+        )
         try:
             M.session.artifact_orm_session._get().skip_mod_date = True
             with h.push_config(c, app=self.app):
@@ -265,9 +271,8 @@ class GitHubWikiImporter(ToolImporter):
         """
         name, ext = os.path.splitext(filename)
         if ext in self.markdown_exts:
-            text = GitHubMarkdownConverter.convert(text)
-            return text
-            #return self.convert_gollum_tags(text)
+            text = self.github_markdown_converter.convert(text)
+            return self.convert_gollum_tags(text)
 
         try:
             import html2text


Mime
View raw message