Hi guys, can you spare a sec? My question is: how can I create a link so that a customer, when clicking an author;s name, can find the results of that name googled already(like rails entering something in the search box, find web results and take the user to that google page) Pls expalin the problem, step by step, NOOB HERE :( thx a billion, radu -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jan-26 18:22 UTC
Re: noob question: create a link to google a parameter
radu puspana wrote:> Hi guys, can you spare a sec? > My question is: how can I create a link so that a customer, when > clicking an author;s name, can find the results of that name googled > already(like rails entering something in the search box, find web > results and take the user to that google page) > > Pls expalin the problem, step by step, NOOB HERE :(Well, first, you have to find out what Google needs from you. Once you''ve found that, it''s simply a question of building the proper URL from Rails.> > thx a billion, > raduBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
thx for your time Marnen. On Jan 26, 8:22 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> radu puspana wrote: > > Hi guys, can you spare a sec? > > My question is: how can I create a link so that a customer, when > > clicking an author;s name, can find the results of that name googled > > already(like rails entering something in the search box, find web > > results and take the user to that google page) > > > Pls expalin the problem, step by step, NOOB HERE :( > > Well, first, you have to find out what Google needs from you. Once > you''ve found that, it''s simply a question of building the proper URL > from Rails. > > > > > thx a billion, > > radu > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve written a complete custom built gui search engine in C++, and I''m also in the process of building a new GUI search engine for ruby. In order to understand google''s references, you have to look at their API. http://www.googleguide.com/advanced_operators.html This will get you started. In terms of answering your question the search would be: http://www.google.com/search?hl=en&as_q=&as_epq=my+author .. where search?hl=en (means english) .. where &as_q= (means start a query output) .. where &as_epq= (means find an author) .. where my+author (would be first+last name) It seems pretty simple but it''s not. You should make sure that you enforce URI encoding standards when submitting your URLs. I hope this helps you to get started. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 26, 10:05 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''ve written a complete custom built gui search engine in C++, and I''m > also in the process of building a new GUI search engine for ruby. In > order to understand google''s references, you have to look at their API. > > http://www.googleguide.com/advanced_operators.html > > This will get you started.That is a great site Alpha, with the tutorial and all that, much appreciate it.Howwver i;m in a big hurry here...> In terms of answering your question the search would be: > > http://www.google.com/search?hl=en&as_q=&as_epq=my+author > > .. where search?hl=en (means english) > .. where &as_q= (means start a query output) > .. where &as_epq= (means find an author) > .. where my+author (would be first+last name) > > It seems pretty simple but it''s not. You should make sure that you > enforce URI encoding standards when submitting your URLs.What does this mean " You should make sure that you enforce URI encoding standards when submitting your URL." ?? Can you explain the problem in more detail or give me a link? Can I find the answer, to the URI encoding question, in the tutorial on the site u googleguides.com ?> I hope this helps you to get started. >Many many thx, radu> Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Jan-27 09:31 UTC
Re: noob question: create a link to google a parameter
On Jan 27, 9:16 am, radu puspana <radupusp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > It seems pretty simple but it''s not. You should make sure that you > > enforce URI encoding standards when submitting your URLs. > > What does this mean " You should make sure that you enforce URI > encoding standards when submitting your URL." ??It basically boils down to making sure you escape special characters. If my memory is correct ruby has some functions for url encoding parameters in the CGI module Fred> Can you explain the problem in more detail or give me a link? Can I > find the answer, to the URI encoding question, in the tutorial on the > site u googleguides.com ? > > > I hope this helps you to get started. > > Many many thx, > radu > > > > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 27, 11:16 am, radu puspana <radupusp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 26, 10:05 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > I''ve written a complete custom built gui search engine in C++, and I''m > > also in the process of building a new GUI search engine for ruby. In > > order to understand google''s references, you have to look at their API. > > >http://www.googleguide.com/advanced_operators.html > > > This will get you started. > > That is a great site Alpha, with the tutorial and all that, much > appreciate it.Howwver i;m in a big hurry here... > > > In terms of answering your question the search would be: > > >http://www.google.com/search?hl=en&as_q=&as_epq=my+authorso how can i get the parameters my and author in there. I;m using a link_to method, something like this <%= link_to "google it", "http://www.google.com/search?hl=en&as_q=&as_epq=my+author" %> any idea how to do this? I also checked the CGI module on railsapi.com, and found something like this Module CGI::QueryExtension * actionpack/lib/action_controller/cgi_ext/query_extension.rb Methods I * initialize_query Instance Public methods initialize_query() Neuter CGI parameter parsing. Source: show | on GitHub This is it? And how do i use it?> > > .. where search?hl=en (means english) > > .. where &as_q= (means start a query output) > > .. where &as_epq= (means find an author) > > .. where my+author (would be first+last name) > > > It seems pretty simple but it''s not. You should make sure that you > > enforce URI encoding standards when submitting your URLs. > > What does this mean " You should make sure that you enforce URI > encoding standards when submitting your URL." ?? > Can you explain the problem in more detail or give me a link? Can I > find the answer, to the URI encoding question, in the tutorial on the > site u googleguides.com ? > > > I hope this helps you to get started. > > Many many thx, > radu > > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 27, 11:16 am, radu puspana <radupusp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 26, 10:05 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > I''ve written a complete custom built gui search engine in C++, and I''m > > also in the process of building a new GUI search engine for ruby. In > > order to understand google''s references, you have to look at their API. > > >http://www.googleguide.com/advanced_operators.html > > > This will get you started. > > That is a great site Alpha, with the tutorial and all that, much > appreciate it.Howwver i;m in a big hurry here... > > > In terms of answering your question the search would be: > > >http://www.google.com/search?hl=en&as_q=&as_epq=my+authorso how can i get the parameters my and author in there. I;m using a link_to method, something like this <%= link_to "google it", "http://www.google.com/search?hl=en&as_q=&as_epq=my+author" %> any idea how to do this? I also checked the CGI module on railsapi.com, and found something like this Module CGI::QueryExtension * actionpack/lib/action_controller/cgi_ext/query_extension.rb Methods I * initialize_query Instance Public methods initialize_query() Neuter CGI parameter parsing. Source: show | on GitHub This is it? And how do i use it?> > > .. where search?hl=en (means english) > > .. where &as_q= (means start a query output) > > .. where &as_epq= (means find an author) > > .. where my+author (would be first+last name) > > > It seems pretty simple but it''s not. You should make sure that you > > enforce URI encoding standards when submitting your URLs. > > What does this mean " You should make sure that you enforce URI > encoding standards when submitting your URL." ?? > Can you explain the problem in more detail or give me a link? Can I > find the answer, to the URI encoding question, in the tutorial on the > site u googleguides.com ? > > > I hope this helps you to get started. > > Many many thx, > radu > > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
and do you know a link on how to buid links using raisl, like the one i need? On Jan 27, 11:31 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 27, 9:16 am, radu puspana <radupusp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > It seems pretty simple but it''s not. You should make sure that you > > > enforce URI encoding standards when submitting your URLs. > > > What does this mean " You should make sure that you enforce URI > > encoding standards when submitting your URL." ?? > > It basically boils down to making sure you escape special characters. > If my memory is correct ruby has some functions for url encoding > parameters in the CGI module > > Fred > > > Can you explain the problem in more detail or give me a link? Can I > > find the answer, to the URI encoding question, in the tutorial on the > > site u googleguides.com ? > > > > I hope this helps you to get started. > > > Many many thx, > > radu > > > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Test this out in IRB so you can see what happens: irb require ''cgi'' puts CGI.escape( "J.R.R. Tolkien" ) puts CGI.escape( "Jack Daniels" ) You can create a simple helper file that does the formatting for you and then use a simple link_tag method to submit the link to google with the helper. If you don''t understand what I''m saying here then you are not ready to do this type of event in rails. You should read up on the very basics for using rails at http://guides.rubyonrails.org/. Take care, JD -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
thx again for your time JD. I did dry the code snippets you gave me, and i also searched the web for the methods of CGI, and couldn''t find it anywhere, including on railsguides.com and at railsapi.com, which served me fine up till now. where should i get the fucntions for CGI? Can ri show them to me?How do i do that? if i understand correctly, regarding the link business : first 1) the helper file for products:(the ONLY place where I wanna use it) requre ''cgi def format_string_for_google(query) CGI.escape(query) end 2)the show.html.erb <%=link_to "google it", ""http://www.google.com /search? hl=en"as_q=&"as_epq=" + format_string_for_google(@product.author)" Is this code here of any good to my problem? a billion thx in advance, radu On Jan 27, 6:08 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Test this out in IRB so you can see what happens: > > irb > require ''cgi'' > puts CGI.escape( "J.R.R. Tolkien" ) > puts CGI.escape( "Jack Daniels" ) > > You can create a simple helper file that does the formatting for you and > then use a simple link_tag method to submit the link to google with the > helper. > > If you don''t understand what I''m saying here then you are not ready to > do this type of event in rails. You should read up on the very basics > for using rails athttp://guides.rubyonrails.org/. > > Take care, > > JD > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
just tested my code in my last post and worket like a charm :) a zillion thx to JD >:D< So i guess i''m kinda ready for this type of event huh? :) all my best, radu On Jan 27, 6:40 pm, radu puspana <radupusp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> thx again for your time JD. > I did dry the code snippets you gave me, and i also searched the web > for the methods of CGI, and couldn''t find it anywhere, including on > railsguides.com and at railsapi.com, which served me fine up till now. > > where should i get the fucntions for CGI? Can ri show them to me?How > do i do that? > > if i understand correctly, regarding the link business : > first > 1) the helper file for products:(the ONLY place where I wanna use it) > requre ''cgi > def format_string_for_google(query) > CGI.escape(query) > end > > 2)the show.html.erb > <%=link_to "google it", ""http://www.google.com /search? > hl=en"as_q=&"as_epq=" + format_string_for_google(@product.author)" > > Is this code here of any good to my problem? > > a billion thx in advance, > radu > On Jan 27, 6:08 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Test this out in IRB so you can see what happens: > > > irb > > require ''cgi'' > > puts CGI.escape( "J.R.R. Tolkien" ) > > puts CGI.escape( "Jack Daniels" ) > > > You can create a simple helper file that does the formatting for you and > > then use a simple link_tag method to submit the link to google with the > > helper. > > > If you don''t understand what I''m saying here then you are not ready to > > do this type of event in rails. You should read up on the very basics > > for using rails athttp://guides.rubyonrails.org/. > > > Take care, > > > JD > > -- > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 26, 10:05 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''ve written a complete custom built gui search engine in C++, and I''m > also in the process of building a new GUI search engine for ruby. In > order to understand google''s references, you have to look at their API. > > http://www.googleguide.com/advanced_operators.html > > This will get you started. > > In terms of answering your question the search would be: > > http://www.google.com/search?hl=en&as_q=&as_epq=my+author > > .. where search?hl=en (means english) > .. where &as_q= (means start a query output) > .. where &as_epq= (means find an author) > .. where my+author (would be first+last name)Just found the google api, at http://code.google.com/apis/soapsearch/reference.html, and there is no trace of your as_q neither as_epq :( Can you tell me why ?> It seems pretty simple but it''s not. You should make sure that you > enforce URI encoding standards when submitting your URLs. > > I hope this helps you to get started. > > -- > Posted viahttp://www.ruby-forum.com/.all my best, radu -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I was just providing an example of how queries are formed. Here''s a quick and dirty test for you for the author find: def find_author(author) require ''cgi'' cgi_author = CGI.escape(author) q_author = cgi_author.gsub(/\+/, ''+author:'') + '' '' query = "http://www.google.com/groups?q=author:" + q_author link_to(author, query) end then call that using <%= find_author("Author Name") %> in your views. Note that if you searched for author in the api you''ll see that it only uses author in google groups and the format is generally author:first+author:middle+author:last etc... in the query output. In your example, since all you need is an author, you just need to make sure that the string for author is escaped correctly, not the entire URL. But, this should get you started. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 27, 7:46 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I was just providing an example of how queries are formed. Here''s a > quick and dirty test for you for the author find: > > def find_author(author) > require ''cgi'' > cgi_author = CGI.escape(author) > q_author = cgi_author.gsub(/\+/, ''+author:'') + '' ''what does this line do? I know gsub will replace the +author text with something that comes out from /\+/ (althought i don''t know what this regwxp could generate)> query = "http://www.google.com/groups?q=author:" + q_authorwhat''s with google groups? i only wanted to search websites. and while testing it in irb, shouldn''t it be query = "http://www.google.com/groups?q=" + q_author ??> link_to(author, query) > end > > then call that using <%= find_author("Author Name") %> in your views.> Note that if you searched for author in the api you''ll see that it only > uses author in google groups and the format is generally > author:first+author:middle+author:last etc... in the query output. > > In your example, since all you need is an author, you just need to make > sure that the string for author is escaped correctly, not the entire > URL. > > But, this should get you started.much appreciate it!! radu> -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 27, 7:46 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I was just providing an example of how queries are formed. Here''s a > quick and dirty test for you for the author find: > > def find_author(author) > require ''cgi'' > cgi_author = CGI.escape(author) > q_author = cgi_author.gsub(/\+/, ''+author:'') + '' ''what does this line do? I know gsub will replace the +author text with something that comes out from /\+/ (althought i don''t know what this regwxp could generate)> query = "http://www.google.com/groups?q=author:" + q_authorwhat''s with google groups? i only wanted to search websites. and while testing it in irb, shouldn''t it be query = "http://www.google.com/groups?q=" + q_author ??> link_to(author, query) > end > > then call that using <%= find_author("Author Name") %> in your views.> Note that if you searched for author in the api you''ll see that it only > uses author in google groups and the format is generally > author:first+author:middle+author:last etc... in the query output. > > In your example, since all you need is an author, you just need to make > sure that the string for author is escaped correctly, not the entire > URL. > > But, this should get you started.much appreciate it!! radu> -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> � q_author = cgi_author.gsub(/\+/, ''+author:'') + '' '' > what does this line do? I know gsub will replace the +author text with > something that comes out from /\+/ (althought i don''t know what this > regwxp could generate)gsub is used for substitution. Unlike sub which only substitutes the first regexp match found, gsub substitutes any number of matches found. The /\+/ is looking for anything that has a + symbol. So, My+Name+Is etc. When you use the cgi method above on the author name, it will correctly escape the html, which is necessary because an author''s name could be anything from First Middle Last to First M. Last etc. Once the cgi method correctly formats the author''s name, you are just providing a bit of substitution for Google''s query engine. It''s going to replace the + between the author''s name with ''+author:'' and then add a space after the entire string so that if you had a name like John+Doe, it would appear as: John+author:Doe The query then appends this string: query = "http://www.google.com/groups?q=author:" + q_author .. to this .. to form.. http://www.google.com/groups?q=author:John+author:Doe And if you click the link for this above, you''ll see what happens when you get to google. Like I mentioned, you can tidy it up a bit if you want or keep it as needed. It will work. Just replace any author''s name in your view with the helper method like I showed above and then test out your view by clicking on the author links and you''ll see what happens. You can add a lot more to this helper method or build yourself an entire class for handling google queries and use methods from the class in your helpers, which is what I do. I thought about handing out a plugin that does all of this, but because google changes things often, I don''t want to have to manage a project at this time. Maybe in the future sometime.. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
i don''t know where to begin in thanking you for all the time and skill that you put into my problem, and for explaining the problem step by step, just like someone should for a noob. I;ll keep in mind every tip u gave me and try tsome day to undestand the thing with the classes and the helpers for queries and become a query search googel exper. Until then there is a lot of work for me, but i know i can rely on my friends here, on RoR Talk. all my best, radu p.s i know a lot of programmers and us noob programmers love a gooed rock song, so care for Mark Knopfler? :) i know i do so this is a small gift for helping a fellowpRoR programmer still in noob form :) http://www.youtube.com/watch?v=F1-uOIKJLvg On Jan 27, 10:38 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> >> q_author = cgi_author.gsub(/\+/, ''+author:'') + '' '' > > what does this line do? I know gsub will replace the +author text with > > something that comes out from /\+/ (althought i don''t know what this > > regwxp could generate) > > gsub is used for substitution. Unlike sub which only substitutes the > first regexp match found, gsub substitutes any number of matches found. > > The /\+/ is looking for anything that has a + symbol. So, My+Name+Is > etc. When you use the cgi method above on the author name, it will > correctly escape the html, which is necessary because an author''s name > could be anything from First Middle Last to First M. Last etc. > > Once the cgi method correctly formats the author''s name, you are just > providing a bit of substitution for Google''s query engine. It''s going > to replace the + between the author''s name with ''+author:'' and then add > a space after the entire string so that if you had a name like John+Doe, > it would appear as: > > John+author:Doe > > The query then appends this string: > > query = "http://www.google.com/groups?q=author:" + q_author > > .. to this .. > > to form.. > > http://www.google.com/groups?q=author:John+author:Doe > > And if you click the link for this above, you''ll see what happens when > you get to google. > > Like I mentioned, you can tidy it up a bit if you want or keep it as > needed. It will work. Just replace any author''s name in your view with > the helper method like I showed above and then test out your view by > clicking on the author links and you''ll see what happens. > > You can add a lot more to this helper method or build yourself an entire > class for handling google queries and use methods from the class in your > helpers, which is what I do. I thought about handing out a plugin that > does all of this, but because google changes things often, I don''t want > to have to manage a project at this time. Maybe in the future > sometime.. > > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Joel Dezenzio
2010-Jan-29 04:06 UTC
RE: Re: noob question: create a link to google a parameter
No problem Radu, glad to help. Definitely start with the basics and work your way up. One thing I would definitely suggest is learning how to create tests for your code and to also read a few books. I own a Kindle so I have a small library of roughly 12 rails books and 4 ruby books. If you don''t like Kindle, you can go to http://my.safaribooksonline.com/ which is another fantastic site that has a small monthly subscription - around 9 dollars or so a month. What I like about safaribooksonline is that you can select and rotate up to 4 books a month. So, I keep 4 books for one month, read through them and then the following month I swap them out for new books. If one is really good for reference, I add it to my Kindle. Books = food Sincerely, Joel Dezenzio Website Bio: http://jdezenzio.com/ Rails Production Sites: http://ncaastatpages.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jan-29 05:41 UTC
RE: Re: noob question: create a link to google a parameter
Alpha Blue wrote:> No problem Radu, glad to help. Definitely start with the basics and work > your way up. One thing I would definitely suggest is learning how to > create > tests for your code and to also read a few books. I own a Kindle so I > have > a small library of roughly 12 rails books and 4 ruby books.And for those with iPhones, you can now do likewise with the Kindle app.> If you > don''t > like Kindle, you can go to http://my.safaribooksonline.com/ which is > another > fantastic site that has a small monthly subscription - around 9 dollars > or > so a month. What I like about safaribooksonline is that you can select > and > rotate up to 4 books a month. So, I keep 4 books for one month, read > through them and then the following month I swap them out for new books.Personally, I don''t like the idea of learning Rails from books. It changes too fast. (I''m also a cheapskate.. :) )> If > one is really good for reference, I add it to my Kindle. > > Books = foodYeah.> > Sincerely, > > Joel Dezenzio > Website Bio: http://jdezenzio.com/ > Rails Production Sites: http://ncaastatpages.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.