iG:Syntax Hilter MANUAL
iG:Syntax Hilter MANUAL is here
Here is a good article to talk about it
It caused me trouble to use url_for when developing applications on facebook with RFacebook. After tracing the source code both in RFacebook and Rails; I found I didn’t configure facebook.yml correctly and didn’t use url_for(is aliased by url_for__RFACEBOOK) correctly. Please take a look at the source code lib/rfacebook_on_rails/controller_exceptions.rb in the following and pay attention to my comment(GOOD and BAD).
[ruby]
def url_for__RFACEBOOK(options={}, *parameters) # :nodoc:
# fix problems that some Rails installations had with sending nil options
options ||= {}
# use special URL rewriting when inside the canvas
# setting the full_callback option to true will override this
# and force usage of regular Rails rewriting
if options.is_a? Hash
if options[:mock_ajax]
RAILS_DEFAULT_LOGGER.info “** RFACEBOOK DEPRECATION WARNING: don’t use :mock_ajax => true in your link_to anymore. Instead, use :full_callback => true.”
end
fullCallback = (options[:full_callback] == true) ? true : false
options.delete(:full_callback)
end
if ((in_facebook_canvas? or in_mock_ajax? or in_ajax?) and !fullCallback) #TODO: do something separate for in_facebook_frame?
if options.is_a? Hash
options[:only_path] = true if options[:only_path].nil?
end
# try to get a regular URL
path = url_for__ALIASED(options, *parameters)
# replace anything that references the callback with the
# Facebook canvas equivalent (apps.facebook.com/*)
if path.starts_with?(self.facebook_callback_path)
#GOOD! Go to here if you set the right facebook.yml in the common case
path.sub!(self.facebook_callback_path, self.facebook_canvas_path)
path = “http://apps.facebook.com#{path}”
elsif “#{path}/”.starts_with?(self.facebook_callback_path)
path.sub!(self.facebook_callback_path.chop, self.facebook_canvas_path.chop)
path = “http://apps.facebook.com#{path}”
elsif (path.starts_with?(”http://www.facebook.com”) or path.starts_with?(”https://www.facebook.com”))
# be sure that URLs that go to some other Facebook service redirect back to the canvas
if path.include?(”?”)
path = “#{path}&canvas=true”
else
path = “#{path}?canvas=true”
end
elsif (!path.starts_with?(”http://”) and !path.starts_with?(”https://”))
#BAD! Go to here if you set the wrong facebook.yml
# default to a full URL (will link externally)
RAILS_DEFAULT_LOGGER.debug “** RFACEBOOK INFO: failed to get canvas-friendly URL (”+path+”) for ["+options.inspect+"], creating an external URL instead”
path = “#{request.protocol}#{request.host}:#{request.port}#{path}”
end
# full callback rewriting
elsif fullCallback
options[:only_path] = true
path = “#{request.protocol}#{request.host}:#{request.port}#{url_for__ALIASED(options, *parameters)}”
# regular Rails rewriting
else
path = url_for__ALIASED(options, *parameters)
end
return path
end[/ruby]
For instance, we configure facebook.yml in Rails config directory as the following. When we call url_for(:controller=>’facebook’, :action => ‘test’), it actually calls url_for__RFACEBOOK. url_for_RFACEBOOK will replace /facebook/test with /netvibez/test. However, if we call url_for(:controller=>’somethingelse’, :action=> ‘test’), url_for_RFACEBOOK will generate http://www.netvibez.com/facebook/test which is NOT canvas friendly URL.
p. p.s. However, url_for(:controller=>’facebook’,:action=>’index’) will return http://www.netvibez.com/facebook. This is NOT what I expect. The reason is url_for_RFACEBOOK will only replace /facebook/ with /netvibez/. The ’slash’ makes big difference. If anyone knows how to fix, please drop me a line.
[code]development:
key: xxxxxxxxxx
secret: xxxxxxxxxx
canvas_path: /netvibez
callback_path: /facebook[/code]
VERIFY: To enable full use of ruby schema support, uncomment ‘config.active_record.schema_format = :ruby’ in your /config/environment. (Update: The rails schema mechanism is the default as of Rails 1.1)
(run rake -T for most of this information as rake usage information)
Example schema.rb:
[ruby]ActiveRecord::Schema.define(:version => 2) do
create_table “comments”, :force => true do |t|
t.column “body”, :text
t.column “post_id”, :integer
end
create_table “posts”, :force => true do |t|
t.column “title”, :string
t.column “body”, :text
t.column “created_at”, :datetime
t.column “author_name”, :string
t.column “comments_count”, :integer, :default => 0
end
end[/ruby]
See the Rails API for details on these.
Example migration:
class UpdateUsersAndCreateProducts < ActiveRecord::Migration def self.up rename_column "users", "password", "hashed_password" remove_column "users", "email" create_table "products", :force => true do |t| t.column "name", :text t.column "description", :text end end def self.down rename_column "users", "hashed_password", "password" add_column "users", "email" drop_table "products" end end
Tip: if you need to manually override the the schema version that in the DB:
ruby script/runner 'ActiveRecord::Base.connection.execute( "INSERT INTO schema_info (version) VALUES(0)")'
On OS X, I’m using TextMate with the syncPEOPLE on Rails v.0.9
TextMate Bundle. This provides the following…
(snipped from the release notes)
Snippets are small capsules of code that are activated by a key sequence followed by the [tab] key. For example, mcdt[tab] will activate the Migration Create and Drop Table snippet.
See Also Sami Samhuri’s information for a more complete description of these snippets
I am trying to setup up a CMS site based on Rails. I installed Radiant and Rubricks. Although Radiant is very succint, but I love Rubricks more because of features. But I hardly find useful document for Rubricks. Any comment?
After reading Dan Webb’s article about OpenID , I decide to have a bash at supporting OpenID in Rails application.
First of all, install ruby-openid gem.
You can unpack them into vendor directory
OpenID ,WOT adn FOAF. Can we combine them together? Whitelisting gives us some direction. Any comment is very welcome!
The great YouTube and Flickr Mashup site can be found in http://www.netvibez.com. It is very easy to watch Video on YouTube, AOL, Yahoo, Metacafe, asterpix and ‘hide me’ is freindly at work:>
Netvibez is an YouTube/Flickr mashup for finding video, images(photos) and music.
image: detail of installation by Bronwyn Lace