Southen/trac-readme-plugin

Blocks non-readme file output

Opened this issue · 0 comments

I'm running Trac 1.2.2. Just started tinkering with it yesterday. I found your plugin because I'm migrating my code out of GitHub and wanted the "README.md" functionality in Trac. I was thrilled when I installed it and started having my markdown rendered in the directory listing. But I quickly found files in the git repository no longer showed with the code viewer. I am a complete Trac code virgin but I found by making the the "if template !=..." the first instruction in the "filter_stream()" method I restored the code viewer for other mime types.

PATCH:

--- a/readme_renderer/__init__.py
+++ b/readme_renderer/__init__.py
@@ -31,10 +31,10 @@ class ReadmeRendererPlugin(Component):
         return tag.pre(content.encode('utf-8'))
 
     def filter_stream(self, req, method, template, stream, data):
-        add_script(req, 'readme/marked.js')
-        add_script(req, 'readme/readme.js')
         if template != 'browser.html' or not data.get('dir'):
             return stream
+        add_script(req, 'readme/marked.js')
+        add_script(req, 'readme/readme.js')
 
         add_stylesheet(req, 'common/css/code.css')

Apparently calling add_script() breaks something in the rendering.

Thanks for making the plugin!