Posted by Eric Stewart
Sun, 12 Mar 2006 08:03:00 GMT
I never realized the amaroK developers had any affinity toward Ruby.
As a part time user of Linux, usually Kubuntu these days, I occasionally use amaroK for playing music to work by. As Linux music player + library applications go, it’s one of the nicest you can find with some features that you don’t find in many other players.
amaroK, like an increasing amount of modern software, supports scripting to allow users to extend the software’s capabilities. They do this by taking advantage of amaroK’s DCOP interface.
This makes it possible to write scripts in almost any programming language, like Ruby, Python or bash scripting. The recommended programming language is Ruby, which is easy to learn and very well suited for amaroK scripting. The amaroK team will be happy to assist you if you have questions regarding Ruby programming.
Not surprisingly, they even recommend Ruby as a nice way to script the application, though they support other languages.
As development goes on, in fact, they are converting compiled portions of code to scripts that can be customized or replaced. This solution came to light after requests by users to support additional sources of song lyrics and deal with the brittle way they interfaced with such sites.
Sooooo, what to do? Scripts to the rescue! What I did is, ripped the hardcoded Lyrc code out. Ported the C++ code to Ruby. Then added a couple of DCOP calls and script notifications for the communication Script <—> amaroK. Added a slice of XML, and you get your spicy new Scriptable Lyrics Feature, mmh.
There was a bit of reaction in the post referenced above to the dependency on Ruby for the newly converted portion of default functionality. If KDE had a default scripting language (similar to the OS X/Applescript relationship) I’d understand those complaints a little more. But then again, OS X installs Python and Ruby by default along with Applescript and nobody really complains.
Is a dependency on a language runtime very different from a dependency on a given library?
Update: As Cornelius Schumacher points out, other KDE projects beginning to do similar things.
<!- technorati tags start ->
Technorati Tags: kde, linux, scripting, ruby
<!
- technorati tags end ->
Posted in Software Development, Ruby, Technology | Tags extensibility, kde, linux, ruby, scripting | 2 comments
Posted by Eric Stewart
Thu, 09 Mar 2006 23:39:30 GMT
Almost two years have passed since I rode in my last bike tour, and the time has come for me to get back in shape and work for a good cause. I rode in the Tour de Cure twice, raising money for diabetes research. Now it’s time to do something a little closer to my heart and ride in the LiveStrong Challenge.
About 30 years ago, when I was a young child, my mother fought cancer and beat it. It was a tough fight, but she survived and lived to see me graduate high school. But the treatment in those days had taken its toll on her and she is no longer with us. I continue to be inspired by the fight she fought and what she went through.
In honor of my mother’s battle with cancer, and for all of those millions of people in the same fight, I’m participating in the LIVESTRONG Challenge in Austin in October. I’m going to ride my bike 40 miles and raise at least $500 for the Lance Armstrong Foundation.
The Lance Armstrong Foundation was founded in 1997 by cancer survivor and champion cyclist, Lance Armstrong, to provide practical information and tools for people living with cancer. Their mission is to inspire and empower people affected by cancer through advocacy, public health and research programs.
If you would like to help out with a wonderful cause or just root for someone who hasn’t ridden much in a few years, please donate to help cancer survivors and support me in my fundraising efforts for the LiveStrong Challange.
<!- technorati tags start ->
Technorati Tags: bike, cancer
<!
- technorati tags end ->
Posted in Austin, Misc. | Tags biking, cancer | no comments
Posted by Eric Stewart
Sat, 04 Mar 2006 20:22:00 GMT
Richard White has released the latest version of his Ajax Scaffold Generator for Rails. Since I have been heads down on a mostly non-Ajax application until recently I had missed this.
If you appreciate the value of scaffolding in helping you get going in a Rails project and you want to use ajax in your application, this is a very handy way start. It also is a nice way of just generating some code you can play with if you are new to Ajax and want to quickly be able to experiment. And it doesn’t look bad. What is generated looks nice, seems to work well, and might not be too far from production ready depending on your application.
I did perform an accidental experiment. I had previously generated scaffolding for a model/controller in my test project and and re-generated scaffolding using this new ajax generator. All worked well, but I ended up with tests that were testing the original non-ajax scaffold methods. The action methods are just about the same, but they now are designed to only be called via ajax calls. My original functional tests for the controller broke. Enter redirect_or_render.
With Courtenay’s helpful method, it’s pretty easy to get this tests passing again and have these controller actions now support ajax or non-ajax calls. For example, consider the ajax generator created scaffold method create on my sample controller for objects called Tasks:
def create
@task = Task.new(params[:task])
if @task.save
@headers['task-id'] = @task.id
@headers['Content-Type'] = 'text/html; charset=utf-8'
render :partial => 'task', :layout => false, :locals => { :hidden => true }
else
render :partial => 'form_errors', :layout => false, :status => 500
end
end
This method expects to be called via xhr request and only needs to return a snippet of code. If we apply redirect_or_render the action becomes something like:
def create
@task = Task.new(params[:task])
if @task.save
@headers['task-id'] = @task.id
@headers['Content-Type'] = 'text/html; charset=utf-8'
redirect_or_render(
{ :action => 'list' },
{ :partial => 'task', :layout => false, :locals => { :hidden => true } }
)
else
redirect_or_render(
{ :action => 'new' },
{ :partial => 'form_errors', :layout => false, :status => 500 }
)
end
end
Now the create action can be called directly as well via a normal request and still function as expected. Note that there is still a bit of work to be done in this case, since we’d really like to have the action render the new action template again so we can show validation errors on the Task. So for these cases, maybe a render_or_xhr_render method would be useful.
<!- technorati tags start ->
Technorati Tags: accessibility, ajax, rails, ruby
<!
- technorati tags end ->
Posted in Software Development, Ruby, Ruby On Rails | Tags ajax, generator, plugin, rails, scaffold | 1 comment