Commits

Stephan Diehl  committed 22cc830

some changes

* added mimetype keyword argument to 'open'.
* when mimetype == 'text/html', the html version of
the document is returned

  • Participants
  • Parent commits a7f6de7

Comments (0)

Files changed (4)

File abl/vpath/dokuwiki/plugin.py

         mirror_path.mkdir()
 
 
-    def open(self, path, options=None):
+    def open(self, path, options=None, mimetype='application/octet-stream'):
         mirror_path = self._mirror(path)
         if mirror_path.isdir():
             raise IOError("Is a directory: %s", path.path)
                 content = fd.read()
             # there is nothing cached yet, but the actual file location
             if not content:
-                content = self._server.wiki.getPage(self._path_to_namespace(path))
+                if mimetype == 'text/html':
+                    content = self._server.wiki.getPageHTML(self._path_to_namespace(path))
+                else:
+                    content = self._server.wiki.getPage(self._path_to_namespace(path))
                 # update the mirror
                 with mirror_path.open('w') as fd:
-                    fd.write(content)
+                    if isinstance(content, unicode):
+                        fd.write(content.encode('utf8'))
+                    else:
+                        fd.write(content)
         if 'r' in options:
             return mirror_path.open()
         elif 'w' in options or 'a' in options:
         # push the content to the mirror
         if 'w' in options or 'a' in options:
             with mirror_path.open('w') as fd:
-                fd.write(content)
+                if isinstance(content, unicode):
+                    fd.write(content.encode('utf8'))
+                else:
+                    fd.write(content)
         # push the content to the dokuwiki server
         self._server.wiki.putPage(self._path_to_namespace(path),
                                   content,
                                       {'sum':'deleted', 'minor':False})
         else:
             raise IOError("No such file or directory: %s" % path.path)
-        
+
 
     def removedir(self, path):
         """
             mirror_path.remove()
         else:
             raise IOError("No such file or directory: %s" % path.path)
+
+    def info(self, path, verbosity=0):
+        mirror_path = self._mirror(path)
+        if mirror_path.isfile():
+            return self._server.wiki.getPageInfo(self._path_to_namespace(path))
+        elif mirror_path.isdir():
+            return {}
+        else:
+            raise IOError("No such file or directory: %s" % path.path)
 
 setup(
     name="abl.vpath.dokuwiki",
-    version="0.1",
+    version="0.2",
     description="a dokuwiki plugin for abl.vpath module",
     author="Stephan Diehl",
     author_email="stephan.diehl@ableton.com",

File tests/basesetup.py.orig

 # testing is done on a live system. Use the following as the base
 # dokuwiki will see this as a namespace 'users:me:vpath_tests'
 testing_base = 'users/me/vpath_tests'
+
+# put in the authors name (for the test environment). That will be the same
+# author than the one in the vpath_connector
+AUTHOR = ""

File tests/test_dokuwiki_plugin.py

 from abl.vpath.dokuwiki.plugin import DokuWikiProxyStringIO
 
 try:
-    from .basesetup import vpath_connector, testing_base
+    from .basesetup import vpath_connector, testing_base, AUTHOR
 
 except ImportError:
     print "============= ATTENTION ======================"
                 fd.write('bar')
         foo_path.remove()
         self.assertEqual(foo_path.exists(), False)
+
+    def test_info(self):
+        foo_path = self.base_path / 'foo'
+        if not foo_path.exists():
+            with foo_path.open('w') as fd:
+                fd.write('bar')
+        info = foo_path.info()
+        self.assertEqual(info["author"], AUTHOR)