Sashimi: Getting Started Tutorial 0

Posted by luca
on Monday, June 30

Here a getting started tutorial for Sashimi

. Sashimi getting started tutorial

Released Sashimi 0.1.6 0

Posted by luca
on Monday, June 23

I just released a new version of Sashimi, with tiny fixes and a new home! In fact the project is also hosted on RubyForge, now you can install the gem with:

$ (sudo) gem install sashimi
or with:
$ (sudo) gem install jodosha-sashimi --source=http://gems.github.com

If you wish, you can visit the project pages on GitHub and on RubyForge.

UPDATE The release 0.1.6 is broken, you are strongly encouraged to update your gem with the newest 0.1.7.

Sashimi: Just Received A Tasteful Update 0

Posted by luca
on Tuesday, May 20

Yesterday I announced Sashimi and now it's already time of tasteful updates.

Changes

First, thanks to all the people that appreciated my work. Second, new commands and options are avaliable for Sashimi.

Update all plugins in your repository:

$ sashimi update --all

Install a plugin to your Rails app:

$ sashimi install --rails click-to-globalize
NOTE this is an alias for the add command.

Update a plugin of a Rails app:

$ sashimi update --rails click-to-globalize
NOTE If your application is versioned with Svn or Git, Sashimi will automatically schedules for add/remove the added/removed files.

How To Update

$ (sudo) gem update jodosha-sashimi --source=http://gems.github.com

I hope you enjoy those addictional options.

Sashimi: A Rails Plugins Manager Gem 3

Posted by luca
on Monday, May 19

I have a really, really bad memory: each time I need to install a Rails plugin, I Google to find the repository, then try to download the code. Often, I remember the url, but the server is down. Damn!

All this annoying issues kill the Rails rapidity on application prototyping. But, what if all the plugins which I need are available offline on my notebook? I can forget about all that urls, and I should stop to worry about the server status.

To solve this problems, I wrote Sashimi, it's a gem that manages you favourite Rails plugins in a local repository.

How It Works?

First you need to install it with:

$ (sudo) gem install jodosha-sashimi --source=http://gems.github.com

Now you can install a plugin on your local repository:
$ sashimi install git://github.com/jodosha/click-to-globalize.git

Ta-daaaa!! Now Click to Globalize is available offline:
$ sashimi list

click-to-globalize

If you need to add it to your Rails app, just move to your app root, then type:
$ sashimi add click-to-globalize

Conclusion

I found Sashimi really useful, I hope you too.

For the complete reference, please check out at the official gem page.

Sashimi 0

Posted by luca
on Monday, May 19

Sashimi

Sashimi is a Rails plugins manager.
It allows to install your favourite plugins in a local repository and add them to your Rails apps.
The main goal of this gem is to allow the plugins offline installation.

Installation

$ (sudo) gem install sashimi
or:
$ (sudo) gem install jodosha-sashimi --source=http://gems.github.com

Usage

Install a plugin from a subversion URL:

$ sashimi install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder

Install a plugin from a git URL:

$ sashimi install git://github.com/jodosha/click-to-globalize.git

Uninstall a plugin:

$ sashimi uninstall continuous_builder

Update a plugin:

$ sashimi update click-to-globalize

Update all installed plugins:

$ sashimi update --all

Update a plugin of a Rails app:

$ sashimi update --rails click-to-globalize
NOTE: If your application is versioned with Svn or Git, Sashimi will automatically schedules for add/remove the added/removed files.

List all installed plugins:

$ sashimi list

Add installed plugin(s) to a Rails app:

$ sashimi add click-to-globalize
or
$ sashimi install --rails click-to-globalize

Known And Common Issues

  • When add a plugin to an app, make sure your current directory is the rails root.
  • Only Subversion and Git repositories are currently supported.

Contribute

Check out the code and test it:

$ git clone git://github.com/jodosha/sashimi.git
$ rake
Create a ticket to: http://sushistar.lighthouseapp.com
Create a patch and add as attachement to the ticket.

Credits

Partially inspired to RaPT.

Copyright

Copyright © 2008 Luca Guidi - http://lucaguidi.com, released under the MIT license

Acts As Resource: Rails 2.1 ready and moved to GitHub 0

Posted by luca
on Wednesday, May 14

Acts As Resource is ready for the imminent Rails 2.1!

I also moved it to GitHub, the new repo is http://github.com/jodosha/acts-as-resource/tree/master, the SVN one is deprecated.

If you enjoyed this post, feel free to recommend me on Working With Rails.

Click to Globalize: rewritten and moved to GitHub 4

Posted by luca
on Monday, May 12

Click to Globalize has been rewritten, in order to use all instance methods of the JavaScript class, instead of class methods.

I also fixed some tiny issues:

  • The form_authentication_token method is called only if the application is protected against the CSRF attacks (protect_against_forgery? returns true)
  • It uses as parameter key what request_forgery_protection_token returns, instead of the hard-coded authenticity_token
  • The JavaScript class uses Prototype's dom:loaded custom event.

I also migrated the plugin GitHub. The new repo is http://github.com/jodosha/click-to-globalize/tree/master, so the oldest one is deprecated.
Have a nice globalization!

If you enjoyed this post, feel free to recommend me on Working With Rails.

Click To Globalize 0

Posted by luca
on Saturday, January 26

Click To Globalize

Click To Globalize is an extension for Globalize plugin, it allows to edit in place globalized labels. With this plugin you don't have to create a globalization back-end, but just edit your interface in place!!

If you have a previous globalization experience, you probably noticed that the main problem of dedicated back-ends is the lack of the context where the string will be placed in. It isn't a trivial issue: you'll never know if the meaning of your string is harmonious with other labels and how your string will be rendered, until the page load.

Now you can forget this issues, you can directly globalize in place!!

Getting Started

  1. Install Globalize, if you don't already done.
  2. Install Click To Globalize:
    $ ./scripts/plugin install git://github.com/jodosha/click-to-globalize.git
  3. Run the setup task:
    $ rake click:setup
  4. Add at the end of your layout the following code:
    <%= click_to_globalize -%>
  5. Put in your view:
    <%= 'hello_world'.t %>
  6. Start the server and click to globalize.

Prerequisites

  • Globalize plugin: www.globalize-rails.org.
  • Prototype >= 1.5.1.1, this version is provided by Click To Globalize installation.
  • RedCloth gem (optional) for textile formatting.
  • BlueCloth gem (optional) for markdown formatting.

Install

  1. Install Globalize, if you don't already done.
  2. Install Click To Globalize:
    Rails 2.1.x
    $ ./script/plugin install git://github.com/jodosha/click-to-globalize.git
    Rails 2.0.x
    $ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk
    Rails 1.2.x
    $ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2.x
  3. Run the setup task:
    $ rake click:setup
  4. Run the tests (optional):
    $ rake click:test
  5. Choose your languages, they will be used to create a picker menu.
    class ApplicationController < ActionController::Base
      self.languages = { :english => 'en-US', :italian => 'it-IT' }
    end
  6. If you like to use wiki-formatting styles, you could use textile (RedCloth) or markdown (BlueCloth).
    class ApplicationController < ActionController::Base
      self.formatting :textile
    end
  7. Personalize the access to the globalization features, overriding #globalize:
    class ApplicationController < ActionController::Base
      def self.globalize?
        current_user.admin?
      end
    end

    NOTICE: #globalize? is method to turn on/off all the Click To Globalize features.
  8. Add at the end of your layout the following code:
    <%= click_to_globalize -%>

Uninstall

$ ./script/plugin remove click_to_globalize

Features

  • In-place editing for each globalized string.
  • Easy and painless plug-in/plug-out process.
  • Unobtrusive Javascript.
  • Auto transformation from input text to textarea for long strings.

Common Issues

  • The install process upgrades your Prototype version to 1.5.1.1 only if needed, but it's advisable to backup your scripts.
  • Since the Globalize plugin creates folders like for-1.2, be sure to rename the folder to globalize.
  • Due to unobtrusive nature of the plugin, each page is parsed by javascript to find the right element and bind to it an Ajax.InPlaceEditor.
    Be sure your (X)HTML is wellformed.
    NOTICE: If you use the Rails 1.2.3 scaffold system, Click To Globalize doesn't works. Cleanup the code before to use.
  • If you use a wiki-formatting style it could be advisable to use #h to avoid security problems (i.e. XSS).
    <%= textilize(h('some_text'.t)) %>

Contribute

  • Check out the code and test it:
    $ git clone git://github.com/jodosha/click-to-globalize.git
    $ rake click
  • Create tickets at the project Trac.
  • Create a patches and add as attachement to the tickets.

Repository

http://github.com/jodosha/click-to-globalize/tree/master

Credits

Javascript tests are based on Prototype test libs.

Vote

If you find it useful feel free to add to your favs on agilewebdevelopment.com.

Copyright

Copyright © 2007 - 2008 Luca Guidi - 23 Labs, released under the MIT license.

Tutorials

  • Getting Started --high resolution
    Click To Globalize: Getting Started [High Resolution]
  • Getting Started
  • Restrict The Access
  • Text Area Transformation
  • Formatting
  • How to Prevent XSS

Click To Globalize: High Resolution Video Tutorial 3

Posted by luca
on Saturday, January 26

Click To Globalize: Getting Started [High Resolution]

The video tutorial for Click to Globalize is now available in high resolution: Click To Globalize: Getting Started.

Click To Globalize: Rails 2.0 Ready 6

Posted by luca
on Friday, December 14

I have finished to work on Click To Globalize, to made it Rails 2.0 compatible.

What's Changed?

All and nothing: from the user point of view, the plugin has the same behaviors of the previous version. My recent activity was a refactoring, now it:

  • Works with CSRF Killer
  • Works with Prototype 1.6.0.1 and Scriptaculous 1.8.0.1
  • Works with rewritten version of Scriptaculous Ajax.InPlaceEditor
  • Works with new Prototype events handling
  • Uses new Prototype's Element#addMethods and Function#wrap to add methods and AOP
  • Uses Protoype Hash#get, instead of square brackets
  • Uses .html.erb as helper, instead of .rhtml
  • Has a more clean installation/disinstallation process
  • Has DRYed up tests
  • Hasn't prototype.js into the packaging

How To Use It?

Rails 2.0

$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk

Rails 1.2.x
$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2.x

For a detailed guide, howtos, snippets, video-tutorials and other infos, please visit the Click To Globalize page.

Click To Globalize: Repository Changes 2

Posted by luca
on Sunday, December 09

As I previously announced, I'm working on Rails 2.0 compatibility for Click To Globalize.

I decided to move the stuff for Rails 1.2.x to for-1.2.x branch and continue the porting into trunk.

How To Install

Rails 2.0

$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk

Rails 1.2.x
$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2.x

Click To Globalize: Working On Rails 2.0 Compatibility 1

Posted by luca
on Sunday, December 09

As you already know, Rails 2.0 it's shipped with updated version of Prototype and Scriptaculous.

Prototype team has committed some breaking changes (e.g. Hash class), and Scriptaculous now has a brand new, rewritten InPlaceEditon.

Those elements are fundamental for Click To Globalize and I'm working on new version for Rails 2.0.

Be patient, I'll soon release it.

Acts As Resource: Rails 2.0 Ready 0

Posted by luca
on Sunday, December 09

Acts As Resource is ready for Rails 2.0!!

This plugin combines both ActiveRecord and ActiveResource features in one class. It easily allows to deal with a remote REST service or with a local database.

If you want read more visit the plugin page or install with:

$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/acts_as_resource

Acts As Resource: Combining ActiveRecord and ActiveResource 0

Posted by luca
on Wednesday, November 28

Would you use both ActiveRecord and ActiveResource in one class?
Now with Acts As Resource you can!!

Example

class Carrot
    acts_as_resource
    self.site = 'http://localhost:3000'

    belongs_to :bunny

    validates_presence_of :color
    validates_uniqueness_of :color
    validates_length_of :color, :within => 2..23,
                        :if => lambda { |c| c.color && !c.color.empty? }
    validates_format_of :color,
                        :with => /[\w\s]+$/,
                        :if => lambda { |c| c.color && !c.color.empty? }

    before_create :please_call_me_before_create
    def self.validate
      logger.debug("VALIDATE #{color}")
    end

    def please_call_me_before_create
      logger.debug("Ohhh, so you called me..")
    end  
  end

About

You can find many informations about Acts As Resource on related page on my blog.

Vote

If you find it useful feel free to add to your favs on agilewebdevelopment.com

Acts As Resource 0

Posted by luca
on Wednesday, November 28

Acts As Resource

ActsAsResource combines ActiveRecord and ActiveResource features in one class.

Example

class Carrot
  acts_as_resource
  self.site = 'http://localhost:3000'
  
  belongs_to :bunny

  validates_presence_of :color
  validates_uniqueness_of :color
  validates_length_of :color, :within => 2..23,
                      :if => lambda { |c| c.color && !c.color.empty? }
  validates_format_of :color,
                      :with => /[\w\s]+$/,
                      :if => lambda { |c| c.color && !c.color.empty? }

  before_create :please_call_me_before_create
  def self.validate
    logger.debug("VALIDATE #{color}")
  end
  
  def please_call_me_before_create
    logger.debug("Ohhh, so you called me..")
  end  
end

Usage

For convention each operation is local unless specified with :remote flag.

carrot = Carrot.find(23)                   # => local request
carrot = Carrot.find(23, :remote => false) # => local request
carrot = Carrot.find(23, :remote => true)  # => remote request

Carrot.create(:color => 'orange')                  # => create local
Carrot.create(:color => 'orange', :remote => true) # => create remote

Prerequisites

For 2.0 railists: no problem guys!
For old 1.2.x people you should live in the edge, cause ActiveResource is needed.

Install

Rails 2.1.x

$ ./script/plugin install git://github.com/jodosha/acts-as-resource.git
Rails <= 2.0.x
$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/acts_as_resource

Uninstall

$ ./script/plugin remove acts_as_resource

Common Issues

  • Actually ActsAsResource doesn't support Single Table Inheritance.
  • Sometimes, when class relations are used, ActiveRecord generates a warning like:
    warning: toplevel constant Bunny referenced by Carrot::Bunny

Contribute

  • Check out the code and test it:
    $ git clone git://github.com/jodosha/acts-as-resource.git
        $ rake resource
  • Create a ticket on: http://dev.23labs.net/rails/trac.cgi
  • Create a patch and add as attachement to the ticket.
  • The SVN repo has been deprecated in favor of the Git one.

Repository

git://github.com/jodosha/acts-as-resource.git

Vote

If you find it useful feel free to add to your favs on agilewebdevelopment.com.

Copyright

Copyright © 2007 Luca Guidi - 23 Labs, released under the MIT license