The application I''m currently working on has a Glossary model. The Glossary table has columns for the term and its definition. The application also has Pages which have content. The content needs to highlight any words that match a term in the Glossary table. There''ll be a few ways to do this but I''d appreciate your advice on the way you''d accomplish this. -- 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 Tue, Mar 1, 2011 at 6:13 PM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> The application I''m currently working on has a Glossary model. The > Glossary table has columns for the term and its definition. > > The application also has Pages which have content. The content needs to > highlight any words that match a term in the Glossary table. > > There''ll be a few ways to do this but I''d appreciate your advice on the > way you''d accomplish this. > >create a helper that would parse the content of the page and would auto link if a certain term corresponds to a glossary record. if the pages are gonna be hit quite a lot, i suggest caching the list of words so you minimize the number of hits to the db.> -- > 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. > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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 Tue, Mar 1, 2011 at 10:13 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> The application I''m currently working on has a Glossary model. The > Glossary table has columns for the term and its definition. > > The application also has Pages which have content. The content needs to > highlight any words that match a term in the Glossary table. > > There''ll be a few ways to do this but I''d appreciate your advice on the > way you''d accomplish this. > > Yes, there are a lot of ways to do this. My approach would be:1. Send the names of all the Glossary as json object when you load the page, bcoz you will be matching the contents of pages with names, i guess. 2. You could send the names as a string like " name1 | name2 | name3 | ....| " or simply pass a hash. 3. Now, when you display the contents of a page, use jQuery to do the matching on the names json with the contents in the http_response coming from server. How you want to do the matching would determine, in which format you are sending the names json from server. Advantages of this approach: 1. You are not saving the matches in DB, although you can. But if you change your glossary, you would have to do it again and change the matches for each page''s contents. You would have understood what I mean to convey here. 2. Use javascript libraries when it comes to things like these, until and unless you want to save the changes(matches here) in DB. There could be a better way of doing this, so lets wait and see what the experienced ones here say about it. --> 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. > >-- 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 Tue, Mar 1, 2011 at 10:52 AM, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Tue, Mar 1, 2011 at 6:13 PM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> The application I''m currently working on has a Glossary model. The >> Glossary table has columns for the term and its definition. >> >> The application also has Pages which have content. The content needs to >> highlight any words that match a term in the Glossary table. >> >> Why are you using the server to do this, when you could use clientprocessor to do the matching for you. NOTE: He just wants to highlight them and not show them as links. If it had been links, I would have completely agreed with your approach. There''ll be a few ways to do this but I''d appreciate your advice on the>> way you''d accomplish this. >> >> > create a helper that would parse the content of the page and would auto > link > if a certain term corresponds to a glossary record. > > if the pages are gonna be hit quite a lot, i suggest caching the list of > words so > you minimize the number of hits to the db. > > > >> -- >> >> 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. >> >> > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.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. >-- 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 Tue, Mar 1, 2011 at 6:56 PM, Jatin kumar <jatinkumar.nitk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > On Tue, Mar 1, 2011 at 10:52 AM, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On Tue, Mar 1, 2011 at 6:13 PM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >>> The application I''m currently working on has a Glossary model. The >>> Glossary table has columns for the term and its definition. >>> >>> The application also has Pages which have content. The content needs to >>> highlight any words that match a term in the Glossary table. >>> >>> Why are you using the server to do this, when you could use client > processor to do the matching for you. > NOTE: > He just wants to highlight them and not show them as links. > > If it had been links, I would have completely agreed with your approach. > >I''m assuming that he wants to link them because I think there''s no use just highlighting them.> There''ll be a few ways to do this but I''d appreciate your advice on the >>> way you''d accomplish this. >>> >>> >> create a helper that would parse the content of the page and would auto >> link >> if a certain term corresponds to a glossary record. >> >> if the pages are gonna be hit quite a lot, i suggest caching the list of >> words so >> you minimize the number of hits to the db. >> >> >> >>> -- >>> >>> 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. >>> >>> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.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. >> > > -- > 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. >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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.
Jim ruther Nill wrote in post #984685:> On Tue, Mar 1, 2011 at 6:56 PM, Jatin kumar > <jatinkumar.nitk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > I''m assuming that he wants to link them because I think there''s no use > just > highlighting them. >Ideally, I''d display the definition of the matched term in the Page itself but a glossary listing will also be available. Honestly, I''m not really sure what the best method of displaying the definition on the page would be; I don''t want the definition to be obtrusive. -- 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 Tue, Mar 1, 2011 at 11:11 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Jim ruther Nill wrote in post #984685: > > On Tue, Mar 1, 2011 at 6:56 PM, Jatin kumar > > <jatinkumar.nitk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > > > I''m assuming that he wants to link them because I think there''s no use > > just > > highlighting them. > > > > Ideally, I''d display the definition of the matched term in the Page > itself but a glossary listing will also be available. > > Honestly, I''m not really sure what the best method of displaying the > definition on the page would be; I don''t want the definition to be > obtrusive. > > Where do you want to show the definition, and on what event, i mean is itlike when you hover over the highlighted text or what?> -- > 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. > >-- 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.
Jatin Kumar wrote in post #984692:> On Tue, Mar 1, 2011 at 11:11 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > > itself but a glossary listing will also be available. > > Honestly, I''m not really sure what the best method of displaying the > definition on the page would be; I don''t want the definition to be > obtrusive. > >> Where do you want to show the definition, and on what event, i mean is it >> like when you hover over the highlighted text or what?onmouseover -- 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 Tue, Mar 1, 2011 at 7:37 PM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Jatin Kumar wrote in post #984692: > > On Tue, Mar 1, 2011 at 11:11 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > > wrote: > > > > itself but a glossary listing will also be available. > > > > Honestly, I''m not really sure what the best method of displaying the > > definition on the page would be; I don''t want the definition to be > > obtrusive. > > > >> Where do you want to show the definition, and on what event, i mean is > it > >> like when you hover over the highlighted text or what? > > onmouseover > >if this is the functionality you want, then i agree that you can just create a js function that would bind an onmouseover event to specific words of the content.> -- > 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. > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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 Tue, Mar 1, 2011 at 11:37 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Jatin Kumar wrote in post #984692: > > On Tue, Mar 1, 2011 at 11:11 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > > wrote: > > > > itself but a glossary listing will also be available. > > > > Honestly, I''m not really sure what the best method of displaying the > > definition on the page would be; I don''t want the definition to be > > obtrusive. > > > >> Where do you want to show the definition, and on what event, i mean is > it > >> like when you hover over the highlighted text or what? > > onmouseover > > When you are doing the matching using jQuery, you could change the contentof pages, in such a way that each matching word (highlighted word) is like an anchor tag or simple text, which when hovered over, can do two things via jQuery: 1. Fire an ajax call to the server, asking for the description of the name. or 2. Send the description alongwith the names in json format, and when hovered over, display the description from the json object you have.> -- > 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. > >-- 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 Tue, Mar 1, 2011 at 7:57 PM, Jatin kumar <jatinkumar.nitk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > On Tue, Mar 1, 2011 at 11:37 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Jatin Kumar wrote in post #984692: >> > On Tue, Mar 1, 2011 at 11:11 AM, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >> > wrote: >> > >> > itself but a glossary listing will also be available. >> > >> > Honestly, I''m not really sure what the best method of displaying the >> > definition on the page would be; I don''t want the definition to be >> > obtrusive. >> > >> >> Where do you want to show the definition, and on what event, i mean is >> it >> >> like when you hover over the highlighted text or what? >> >> onmouseover >> >> When you are doing the matching using jQuery, you could change the content > of pages, in such a way that each matching word (highlighted word) is like > an anchor tag or simple text, which when hovered over, can do two things via > jQuery: >> 1. Fire an ajax call to the server, asking for the description of the > name. > > I think this is the better option. plus you can minimize the request tothe server if you somehow store already hovered words into a global js variable. so onmouseover, check the array if the word is there. if it''s there, then you don''t need to do an ajax request anymore.> or > > 2. Send the description alongwith the names in json format, and when > hovered over, display the description from the json object you have. > >> -- >> 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. >> >> > -- > 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. >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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.
I remember there is a gem acts_as_tags, Is it useful for you? -- 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.