How to add PHP Highlighting in file browser
|
|
Okay.. the funny thing is.. i just updated my weblog and used the same code_highlighter javascript in my theme. Since i only blog about CakePHP and PHP in general i had to create a rule file for PHP to use with the highlighter. So it was only a matter of integration for me to get this functionality in Warehouse. Lucky me ;) To add this in Warehouse you need the following:
add a new line with:
add a new line with:
copy, wget or upload it to
Now test it by browsing an php file. It highlights not everything i have added (since some css classes are missing), but for basic highlighting this works quiet well. Hope you like it! |
|
|
Thanks, but we’ll be replacing that in 1.1 likely. I really want linkable line numbers. We’re looking at CodeRay or UltraViolet. UltraViolet parses everything that Textmate does, but requires a special c lib. But, the really cool thing is it’ll be able to distinguish between Ruby and Rails, or PHP and Symphony, for example. Oh, and the javascript one has obscure bugs. Trying to highlight |
|
|
UltraViolet looks pretty nifty, just wish I could get it installed properly on my machine. Can’t seem to get Textpow going cause I’ve got Ruby with the Oniguruma bindings compiled in instead of needing the gem for it. Damn me and my requirements for complicated regular expressions :P |
|
|
Isn’t Oniguruma included in ruby 1.9? You may be SOL until Dec 25th… Actually, I suspect it may be awhile before rails runs on ruby 1.9. Perhaps there are some quick hacks you can do to Textpow to recognize your setup? I’ll probably end up freezing those gems in warehouse. |
|
|
Thats what I am trying now. Looking a writing a small compatibility class which overlays Oniguruma::ORegexp on Regexp. I’ve also tried building the gem on a vanilla FreeBSD with devel/oniguruma4 port and that gets the gem compiling but giving some warnings (thats only if I hack the list of include paths manually in the generated Makefile). Dug up this on RubyTalkGoogle. Having looked at the oniguruma gem source there is no reason why I couldn’t run them side by side except that the Oniguruma patches use v2.5.8 which is not supported by the gem and the damned extconf.rb seems to find wrong header file when installing the gem. With any luck I’ll find some method of getting it working for me. |
|
|
Hey, Am I missing the point or is there a way to freeze the c library too? I’ve had it all running smoothely but when I freezed the textpow, ultraviolet and onimuruga gems into a rails app it wouldn’t find oregexp anymore: /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’: no such file to load—oregexp (MissingSourceFile) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’ from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require’ from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in’ from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require’ from /home/caffeine/rails_projects/weblog_rest/config/../vendor/plugins/oniguruma-1.1.0/lib/oniguruma.rb:1 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’ from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’ from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require’ ... 28 levels… from /usr/bin/mongrel_rails:18:in `load’ from /usr/bin/mongrel_rails:18 from -e:2:in `load’ from -e:2 |
|
|
check in the oniguruma/lib and oniguruma/ext directories for a oregexp.so file If it is in ext, then you might need to add the ext directory to the load path as well as lib |
|
|
Hey Geoff, Thanks for your reply. When I browsed the oniguruma folder created by “gem unpack onimguruma” I couldn’t find any shared object at all. Which makes sense because its actually not in the gem but gets thrown into the gem folder upon a succesful run of “gem install onigurum” su basically I just copied the gem from /usr/lib/ruby/gems/1.8/gems/oniguruma-x.x to my vendor/plugins dir and its working now. So thanks for pointing me in the right direction! |
|
|
glad that sorted it, keep in mind though that if you deploy your application to a different architecture than the .so was compiled on you might have some issues |
|
|
That’s a good point you are raising there, and seeing how tricky the setup is I might try it again once its more mature and usable if not cached. |
|
|
Most gems with native extensions keep the source in the ext/ directory and there should be an extconf.rb file in there. The typical build process to make the extension is
and then the .so should be compiled and be in the ext/ directory. So you could probably add a rake or capistrano task which compiles all your gems or something like that. |