As a small thank you to the Redcar team for such a great editor and in the spirit of giving a little bit back I’m documenting the process of creating my first plugin.
I really like the idea of the Redcar editor. Its written in Ruby, its possible to write your own plugins what’s not to like? Though I must confess I don’t use it as my day to day editor, I wonder if writing my own plugins will change that.
Let see how easy it is to write a plugin for Redcar.
What’s da big idea
The idea for my first plugin is rather ambitious considering I’ve no idea how to write a plugin. I’d like to replicate some of the functionality of Live Reload – basically refresh a browser web page whenever I save a file in Redcar. This will save me constantly hitting refresh in the browser when working with Backbone.js.
I’m hoping to trap the save event of Redcar and call out to my browser (Chrome) and tell it to refresh the page.
I first followed the install instructions:
All good no problems there (I’m running on a Mac OSX 10.7.1)
I then read the plugin guides I found here:
Setting up a plugin is really easy and well described in the guides listed above. Redcar itself is made up of a bunch of plugin’s so there are no end of great examples to follow in the source code (http://github.com/redcar/redcar)
For trapping the save event I dug into the source code and came across the method project_refresh_task_type which is called on all plugins after a save. To hook into this process my plugin simply defines the method:
This may not be the best place to hook into save, Redcar has the concept of events and that may be a better place to look but for now this is working.
Browser refresh script
RefreshBrowser is a Redcar::Task which I have created to run the browser refresh script.
I managed to find a script to refresh the browser here:
The script uses a keyword to identify which tab to refresh in the browser so I needed this to be saved and configurable somewhere. Luckily Redcar has a storage mechanism built right in.
Redcar’s storage mechanism allows you to easily store configuration data into a yaml file.
@storage ||= Plugin::Storage.new('live_reload_plugin')
Here I am using this mechanism to store the ‘keyword’ used by the RefreshBrowser task. This allows the user to edit the yaml file via the Redcar plugin preferences. It’s also possible to setup a nice edit page but for now this will do.
You can find the source for this plugin here:
Was it easy?
YES! The Redcar team have done a great job and made it incredibly easy to create your own plugins. In a couple of hours I made a useful plugin, useful to me at least. I’ve spent more time fussing over this blog post than developing the plugin.
So what you waiting for? Go give it a try!
It seemed almost impossible to penetrate the fortress that is Sharepoint with only NTLM authentication enabled. Turns out its really easy when you know how.
curl to the rescue!
You can upload files using curl directly into Sharepoint via it’s HTTP PUT interface.
curl --ntlm --user username:password --upload-file myfile.xls https://sharepointserver.com/sites/mysite/myfile.xls
Told you, easy when you know how.
Setup Apache as a Reverse Proxy in front of a standalone Torquebox server.
For this to work Apache must have the mod_proxy module loaded:
Config file: /etc/httpd/conf/httpd.conf
ProxyRequests Off # Switch off forward proxy
ProxyPreserveHost On # Pass host name onto the proxy
ProxyPass /myapp http://localhost:8080/myapp/ # Map url to remote server
ProxyPassReverse /myapp http://localhost:8080/myapp/ # Adjust header sent from remote server to match url
Here we are passing all calls to the /myapp/ url on to the Torquebox server http://localhost:8080/myapp/
In your Torquebox application folder create a file ‘config/torquebox.yml’ which contains a context which matches the Apache reverse proxy url.
To build FubuMVC you need to install ruby, rake etc. Unfortunately for me the firewall at work will not allow me to get the rake gem (I’ve downloaded gems before using the HTTP_PROXY setting before but no luck this time). Any hoose I remember reading Stephen Balkum post on packaging up Rake as an executable. I followed Stephens guide and created a portable rake package which got around my firewall problem but FubuMVC required another gem rubyzip to allow a build.
Adding another gem
Luckily using Stephen’s guide its really easy to add extra gems, you just need to have them installed before you build your exe. So we follow the first part of the process outlined in Stephen’s guide then do the following:
NOTE: In this case we need rubyzip but it could be any old gem.
- Download rubyzip and extract to contents to c:\rubywork\zip
- To install rubyzip, at a command prompt in c:\rubywork\zip, run ..\ruby\bin\ruby install.rb
- Download zlib and extract the zlib1.dll to C:\rubywork\ruby\lib\ruby\1.8\i386-mswin32
- Rename zlib1.dll to zlib.dll (rubyzip required this extra dll other gems may not)
Now continue part two of the process from Stephen’s guide to compile your very own allinoneruby.exe which includes, rake and rubyzip.
You should now have allinoneruby.exe and rake.rb file.
We can now drop these files into to the FubuMVC project under the build support folder:
We need a helper batch file in the root folder of FubuMVC called rake.bat which contains:
@.\build_support\allinoneruby.exe .\build_support\rake.rb %*
This will be called when we run the build.
Run the build already
Drop to the command prompt and cd into the FubuMVC project root and simply type build. You should get something like:
Don’t want to go through all that? You can download my version of portable rake here (I don’t think I’m breaking any licensing agreements here, this is all open source software. If I am let me know and I’ll remove the link)
DISCLAIMER: I offer no guarantees I can only confirm this works on my machine!
One final note
I’ve used this method to build some of the other open source projects out there which use rake (all the cool kids seem to be using rake) and so far I’ve not had any problems. This could be pretty frictionless way to introduce rake to a team of .net developers who don’t want the overhead of installing ruby on their machines. Just add it to a tools folder check it in to source control they’ll never know!
Assuming you have an SQL Server 2005 running reporting services you can run Report builder as a ClickOnce app using the following url:
build_log.xml *.suo *.user _ReSharper* *.resharper bin obj class build