This plugin provides helpers for your views that allow you to gain implicit data about the user browsing the site. This is intended to be used to customise what the user see''s, maybe to improve usability or for cross-browser issues Url: http://www.railslodge.com/plugins/303-personalise-site SVN: http://svn.railslodge.com/svn/plugins/personalise_site/ The following methods are available: Returns the name of the browser the user is using <%= def which_browser? %> Returns the version number of the browser being used <%=which_browser_version?%> Returns the name of the platform the user is using <%= which_platform? %> Nil is always returned if the data is unavailable ==== Example usage An example below looks at the platform and outputs the right command to install this plugin <% if which_platform? == ''Windows'' -%> ruby script/plugin install http://svn.railslodge.com/svn/plugins/personalise_site/ <% elsif which_platform? == ''Mac'' -%> ./script/plugin install http://svn.railslodge.com/svn/plugins/personalise_site/ <% else -%> script/plugin install http://svn.railslodge.com/svn/plugins/personalise_site/ <% end -%> Info ============Author: Scott Sherwood License: MIT Date: 30-09-07 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This is a stylistic nit pick, but typically methods that end in "?" return true or false rather than some other value. I would personally name the methods "user_browser_version" or "user_platform" or something like that. --Jeremy On 9/30/07, Scott A S <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > This plugin provides helpers for your views that allow you to gain > implicit data about the user browsing the site. > > This is intended to be used to customise what the user see''s, maybe to > improve usability or for cross-browser issues > > Url: http://www.railslodge.com/plugins/303-personalise-site > SVN: http://svn.railslodge.com/svn/plugins/personalise_site/ > > The following methods are available: > > Returns the name of the browser the user is using > <%= def which_browser? %> > > Returns the version number of the browser being used > <%=which_browser_version?%> > > Returns the name of the platform the user is using > <%= which_platform? %> > > Nil is always returned if the data is unavailable > > ==== Example usage > > An example below looks at the platform and outputs the right command to > install this plugin > > <% if which_platform? == ''Windows'' -%> > ruby script/plugin install > http://svn.railslodge.com/svn/plugins/personalise_site/ > <% elsif which_platform? == ''Mac'' -%> > ./script/plugin install > http://svn.railslodge.com/svn/plugins/personalise_site/ > <% else -%> > script/plugin install > http://svn.railslodge.com/svn/plugins/personalise_site/ > <% end -%> > > Info > ============> Author: Scott Sherwood > License: MIT > Date: 30-09-07 > -- > Posted via http://www.ruby-forum.com/. > > > >-- http://www.jeremymcanally.com/ My free Ruby e-book: http://www.humblelittlerubybook.com/book/ My blogs: http://www.mrneighborly.com/ http://www.rubyinpractice.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Jeremy, Thanks for your feedback, I have made the changes to remove the ''?'' based on your comments. Cheers, Scott Sherwood Jeremy McAnally wrote:> This is a stylistic nit pick, but typically methods that end in "?" > return true or false rather than some other value. I would personally > name the methods "user_browser_version" or "user_platform" or > something like that. > > --Jeremy-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Just some ideas... On 10/1/07, Scott A S <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi Jeremy, > > Thanks for your feedback, > I have made the changes to remove the ''?'' based on your comments.You could also add some methods like the following: running_windows? running_os_x? then your example becomes: <% if running_windows? -%> ruby script/plugin install http://svn.railslodge.com/svn/plugins/personalise_site/ <% elsif running_os_x? -%> ./script/plugin install http://svn.railslodge.com/svn/plugins/personalise_site/ <% else -%> script/plugin install http://svn.railslodge.com/svn/plugins/personalise_site/ <% end -%> Cheers,> Scott Sherwood > > > Jeremy McAnally wrote: > > This is a stylistic nit pick, but typically methods that end in "?" > > return true or false rather than some other value. I would personally > > name the methods "user_browser_version" or "user_platform" or > > something like that. > > > > --Jeremy > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Yeah it''s a good idea, however this would require an extra 5 or 6 methods to replace the single which_platform. As I am very likley to be devleoping this one further, I really want to keep the code as small and DRY as possible. Scott Michael Guterl wrote:> > You could also add some methods like the following: > > running_windows? > running_os_x? > > then your example becomes: > > <% if running_windows? -%> > ruby script/plugin install > http://svn.railslodge.com/svn/plugins/personalise_site/ > <% elsif running_os_x? -%> > ./script/plugin install > http://svn.railslodge.com/svn/plugins/personalise_site/ > <% else -%> > script/plugin install > http://svn.railslodge.com/svn/plugins/personalise_site/ > <% end -%> > > > Cheers,-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Scott A S wrote:> Yeah it''s a good idea, however this would require an extra 5 or 6 > methods to replace the single which_platform. > > As I am very likley to be devleoping this one further, I really want to > keep the code as small and DRY as possible.I dig it. If you really want methods like internet_explorer? you could easily write your own. I probably will. =) Thanks for the plugin, Scott. - Rabbit -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What? Replace methods? No way. Just add some nice convenience methods to pretty up the views. For example: def running_osx? which_platform == ''Mac'' end def running_windows which_platform == "Windows" end Etc. You''re not replacing methods.. you are adding a DSL to your plugin.. which makes views much easier. It also allows you to change the underlying implementation. For example... which_platform might return "Windows" right now... but what if it returns win32 in some cases? It might also return something else in the future. This is one reason why you access your params in a Rails application via params (a method) and not @params (an instance variable) Nice plugin btw... have you submitted this to agilewebdevelopment.com/plugins yet? On 10/2/07, Scott A S <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi, > > Yeah it''s a good idea, however this would require an extra 5 or 6 > methods to replace the single which_platform. > > As I am very likley to be devleoping this one further, I really want to > keep the code as small and DRY as possible. > > Scott > > > > Michael Guterl wrote: > > > > You could also add some methods like the following: > > > > running_windows? > > running_os_x? > > > > then your example becomes: > > > > <% if running_windows? -%> > > ruby script/plugin install > > http://svn.railslodge.com/svn/plugins/personalise_site/ > > <% elsif running_os_x? -%> > > ./script/plugin install > > http://svn.railslodge.com/svn/plugins/personalise_site/ > > <% else -%> > > script/plugin install > > http://svn.railslodge.com/svn/plugins/personalise_site/ > > <% end -%> > > > > > > Cheers, > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---