epitron / redmine_ultraviolet

Advanced syntax highlighting for Redmine source code repositories (using Ultraviolet, which is based on Textmate syntax files).
Other
60 stars 20 forks source link

Wiki support #10

Closed tlunter closed 13 years ago

tlunter commented 13 years ago

At this point in time, it seems that the wiki does not support UltraViolet (still using CodeRay?). I was wondering if there was a quick fix to get it to work on the wiki, or if it was going to be made to work with the wiki at some point in time. We use RedMine at our university's tech support group for closed projects that we are working on. Unfortunately we aren't very well versed in Ruby, and are a much more python breed. Any help would be appreciated.

epitron commented 13 years ago

There is, actually. :)

Check out this fork: https://github.com/erikkallen/redmine_ultraviolet

tlunter commented 13 years ago

Hmm, we're using version 1.2 of Redmine and when we use your fork it seems to give us an internal redmine error, but the log is blank. Is it an issue of the version not being supported yet? Or could it be we also apply the wiki extensions plugin?

erikkallen commented 13 years ago

Are you sure you are looking at the right log? did you check both production.log and development.log? And did you install ultraviolet, and nokogiri (dependency for ultraviolet) and depending on your ruby version (1.9.2 or 1.8.7) you need different gems spox-ultraviolet for 1.9.2

J-Jay commented 13 years ago

I also installed the redmine_ultraviolet fork pluggin and I have the following issue :

NoMethodError in Wiki#show

Showing vendor/plugins/redmine_ultraviolet/app/views/wiki/_content.rhtml where line #1 raised: undefined method `theme_name=' for UltravioletSyntaxPatch:Module

Extracted source (around line #1): 1: <% Redmine::SyntaxHighlighting.highlighter.theme_name = Redmine::SyntaxHighlighting.highlighter.get_uv_theme_name %> 2: 3:

4: <%= textilizable content, :text, :attachments => content.page.attachments %>

Trace of template inclusion: app/views/wiki/show.rhtml

RAILS_ROOT: /Library/WebServer/redmine-1.2.0 Application Trace | Framework Trace | Full Trace /Library/WebServer/redmine-1.2.0/vendor/plugins/redmine_ultraviolet/app/views/wiki/_content.rhtml:1:in _run_rhtml_vendor47plugins47redmine_ultraviolet47app47views47wiki47_content46rhtml_locals_content_object' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:insend' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in render' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/base.rb:306:inwith_template' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in render' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:20:inrender' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:30:in benchmark' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:19:inrender' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/template.rb:205:in render_template' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/renderable_partial.rb:44:inrender_partial' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/partials.rb:184:in render_partial' /Library/WebServer/redmine-1.2.0/vendor/rails/actionpack/lib/action_view/base.rb:267:inrender' /Library/WebServer/redmine-1.2.0/app/views/wiki/show.rhtml:30:in _run_rhtml_app47views47wiki47show46rhtml' /Library/WebServer/redmine-1.2.0/app/controllers/wiki_controller.rb:84:inshow' Request

Parameters: {"project_id"=>"bacasable", "id"=>"Home"}

Show session dump Response

Headers: {"Content-Type"=>"", "Cache-Control"=>"no-cache"}

erikkallen commented 13 years ago

the issue should be fixed now I somehow forgot to push my last change :D

J-Jay commented 13 years ago

ok, thanks ! The issue is fixed.

But I have an issue with objective-c code in Wiki. The following code has not syntax highlighting :


#import 
#import "YNAbstractMediaTableViewCell.h"

@interface YNTextMediaTableViewCell : YNAbstractMediaTableViewCell  {

@private 
    UITextView *__yn_mediaTextView;
    BOOL __yn_isNewMedia;
}

@property (nonatomic, retain, readonly) UITextView *mediaTextView;

@end

JJay

edit : We can't see but where is a code block with objective-c class

erikkallen commented 13 years ago

should be fixed now turns out that redmine wiki does not allow - or + in the name of the class so I patched the regex

J-Jay commented 13 years ago

ok many thanks again it seem to be fixed but where are other issues :

  • < and > are not correctly displayed (for exemple I have #import <UIKit/UIKit.h> instead of #import <UIKit/UIKit.h>
  • many objective-c keywords are not colored (@interface, @imlementation ...). Only in Wiki, works great in Repository sources.
  • It's impossible to choose a theme by user. (in wiki and repository)

(If you prefer, I can open a ticket by issue)

JJay

epitron commented 13 years ago

Are the Objective-C highlighting problems the result of the Textmate syntax file? Ultraviolet should be escaping < and > characters. At least, it does it for other languages.

erikkallen commented 13 years ago

I fixed the escapes turns out the wiki and Ultraviolet both escape :D It's a bit of a hack but it works

As for the not colored keywords that indeed depends on the theme you're using

I removed the ability for users to change the theme because it would only work if the wiki caching would be switched off which I do not prefer but if you really want it you should be able to uncomment some lines in the code or fork this repository

J-Jay commented 13 years ago

First, Thanks guys for your works !

I made plugins update

sudo script/plugin install git://github.com/erikkallen/redmine_ultraviolet.git rake db:migrate_plugins RAILS_ENV=production

But I did not see any of your fixes.

Issues ares the same :

  • < and > are not correctly displayed (for exemple I have #import & l t ;UIKit/UIKit.h & g t ; instead of #import < UIKit/UIKit.h >) I only have this issue on Wiki, ultraviolet Objective-C highlighting works great in Repository sources tab.
  • many objective-c keywords are not colored (@interface, @imlementation ...). Once again I only have this issue on Wiki, ultraviolet Objective-C keywords highlighting works great in Repository sources tab.

JJay

Edit : I removed issue regarding theme ! (I did not see your comment about it in your comment, sorry!)

erikkallen commented 13 years ago

did you restart your app? the changes are on github I can see them

J-Jay commented 13 years ago

Yes I restarted my app.

For information redmine is running on MacOS (10.6.8) I am using redmine 1.2 and this is the boot sequence :

=> Booting WEBrick => Rails 2.3.11 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2011-07-07 10:38:47] INFO WEBrick 1.3.1 [2011-07-07 10:38:47] INFO ruby 1.8.7 (2009-06-12) [universal-darwin10.0] [2011-07-07 10:38:47] INFO WEBrick::HTTPServer#start: pid=11464 port=3000

epitron commented 13 years ago

The theme changes the generated HTML?? I thought the theme was entirely in the CSS!

erikkallen commented 13 years ago

no unfortunately each theme has it's own renderer check https://github.com/spox/ultraviolet/tree/master/render/xhtml

epitron commented 13 years ago

Brutal!

I guess it would be possible to enhance Redmine's wiki page caching, so that the UV highlighted chunks of the page are separate entries in the fragment-cache, keyed by [wikipage, revision, chunk_id, theme].

I wonder how much of a performance hit it would take if it had to render the syntax every time...

JumpLink commented 13 years ago

Hi thank you for the nice plugin and the nice fork, I have a problem: With the original repo the plugin works fine for me to show syntax with files in my redmine-repo, now I have installed the fork to show the syntax in my wiki, too. And thats work fine in my wiki. But now, i get an error with files in my redmine-repo: "Internal error

An error occurred on the page you were trying to access. If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error."

Edit: thats my log: http://pastebin.com/vNbkpm0e

epitron commented 13 years ago

The problem is:

undefined method `to_utf8_for_repositories' for #<ActionView::Base:0xb5664800>

That's not my code. :) Spox, got any ideas?

erikkallen commented 13 years ago

I did a quick grep on the chilliproject source and found the method

grep -irn "utf8_for_repositories" .
./app/helpers/repositories_helper.rb:115:  def to_utf8_for_repositories(str)

then I searched in the same file on redmine and found there was a to_utf8 since neither one of these methods seem to be in your code my guess is this is a version issue what version of redmine are you using? Because a quick look in the svn shows has been there for a while.

JumpLink commented 13 years ago

I use Redmine 1.2.1.stable with MySQL

Edit: Why the original Version works with Repos and the Fork not? Any idea to solve this Problem?

Maybe I could use an other format as UTF8 for my repo comments? What's the Standardformat?

erikkallen commented 13 years ago

Can you try changing line 18 in the file redmine_ultraviolet / app / views / common / _file.rhtml from

<%= syntax_highlight(filename, to_utf8_for_repositories(content)) %>

to

<%= syntax_highlight(filename, to_utf8(content)) %>

and see if that helps

JumpLink commented 13 years ago

it seems to work, thank you!

erikkallen commented 12 years ago

Have you installed the my fork?

https://github.com/erikkallen/redmine_ultraviolet

On Thu, Mar 29, 2012 at 5:02 AM, Neil Saunders < reply@reply.github.com

wrote:

I must be missing something. I've installed the plugin on Redmine 1.3, no problems. My repositories are using UV but code pasted on wiki pages is not

  • it still uses Coderay. What do I change to get UV highlighting on wiki pages?

Reply to this email directly or view it on GitHub:

https://github.com/epitron/redmine_ultraviolet/issues/10#issuecomment-4795917

neilfws commented 12 years ago

Have you installed the my fork?

Hi Erik, Thanks for replying - sorry, I deleted my comment.

Yes, I have installed your fork. I had a problem in that I'm using Redmine 1.3, so I had to do some editing as described here (for the original plugin):

https://github.com/epitron/redmine_ultraviolet/issues/14

Now I am seeing UV highlighting in my repositories, but not when I paste code on a wiki page. Wiki pages seem to still use Coderay - or in some cases, no highlighting happens, which is confusing!

Is there something I've missed? A config setting or some special wiki syntax? Or could another plugin be interfering with code on wiki pages?

erikkallen commented 12 years ago

Have you disabled the wiki caching setting in the redmine settings? That could explain that it shows the highlighting in some cases and not in others

-erik

On Mar 29, 2012, at 10:13 AM, Neil Saunders wrote:

Have you installed the my fork?

Hi Erik, Thanks for replying - sorry, I deleted my comment.

Yes, I have installed your fork. I had a problem in that I'm using Redmine 1.3, so I had to do some editing as described here (for the original plugin):

https://github.com/epitron/redmine_ultraviolet/issues/14

Now I am seeing UV highlighting in my repositories, but not when I paste code on a wiki page. Wiki pages seem to still use Coderay - or in some cases, no highlighting happens, which is confusing!

Is there something I've missed? A config setting or some special wiki syntax? Or could another plugin be interfering with code on wiki pages?

thanks,

Neil

Statistical Bioinformatics - Health CSIRO Mathematics, Informatics and Statistics Locked Bag 17, North Ryde, NSW 1670, Australia

http://nsaunders.wordpress.com


Reply to this email directly or view it on GitHub: https://github.com/epitron/redmine_ultraviolet/issues/10#issuecomment-4798766

neilfws commented 12 years ago

Have you disabled the wiki caching setting in the redmine settings? That could explain that it shows the highlighting in some cases and not in others

Yes, caching was off by default. And as I mentioned, in the case where there is wiki highlighting, it's coming from Coderay, not UV.

neilfws commented 12 years ago

Actually, disregard the last part of my last comment. The formatting *looked" like coderay but the class of the pre tag is slush_poppies so it must be UV. I guess font on the wiki is a bit different to in the repository.

So I have one wiki page working (highlighting ruby) and one not (highlighting R). I'll keep troubleshooting...

neilfws commented 12 years ago

OK - UV highlighting on wiki pages, both R and ruby code, is now working just fine. Not sure what the issue was in the end; perhaps because the class of my code tags was in single, not double quotes?

Thanks for your help Erik.

erikkallen commented 12 years ago

I had some issues with highlighting some languages like c++ I think I fixed it by looking at the directory where the language styles are installed for uv and rename the files to lower case with only regular characters so c++ becomes cplusplus

On Mar 29, 2012, at 10:43 AM, Neil Saunders wrote:

Actually, disregard the last part of my last comment. The formatting *looked" like coderay but the class of the pre tag is slush_poppies so it must be UV. I guess font on the wiki is a bit different to in the repository.

So I have one wiki page working (highlighting ruby) and one not (highlighting R). I'll keep troubleshooting...


Reply to this email directly or view it on GitHub: https://github.com/epitron/redmine_ultraviolet/issues/10#issuecomment-4799167

erikkallen commented 12 years ago

No problem I'm glad it worked On Mar 29, 2012, at 10:47 AM, Neil Saunders wrote:

OK - UV highlighting on wiki pages, both R and ruby code, is now working just fine. Not sure what the issue was in the end; perhaps because the class of my code tags was in single, not double quotes?

Thanks for your help Erik.


Reply to this email directly or view it on GitHub: https://github.com/epitron/redmine_ultraviolet/issues/10#issuecomment-4799228