Walksalong
2008-Jul-15  20:15 UTC
Trying to write a lite Rails version of Yahoo Shortcuts or something similiar.
Has anyone ever seen Yahoo Shortcuts or something similiar? I would
like to write my own in Rails, but I''m not sure the best approach...
or is there something already out there that I''ve missed?
The story goes I have a list of site specific keywords I would like to
compare my other site content with. As the page loads the content I
would like to do a comparison- basically parse over the text and if
there is a match with a keyword then I can create a connection and
link.
Right now, I am using Hpricot along with Prototip.js. I''ve been
manually wrapping keywords using a span tag along with attributes
within the data to test:
<% doc = Hpricot("#{e.description}") %>
<% (doc/"//span").each do |span| %>
<% set_record_type = span.attributes["record_type"] rescue nil
%>
<style>
#<%= span.attributes["id"] %>{
font-size: 12px;
color: dodgerblue;
}
</style>
<script type=''text/javascript''>
//<![CDATA[
new Tip(''<%= span.attributes["id"] %>'', {
ajax: {
url: ''/<%= set_record_type
%>/prototip/<%span.attributes["record_id"] %>'',
options: {
onComplete: function(){
//alert(''ajax content loaded'');
}
}
},
effect: ''appear''
});
//]]>
</script>
<% end %>
If I hit a match I underline the term then I drop in some Prototip
code to load up a show in my controller.
I''m wondering if there is a better approach. I thought about putting
the keywords in an XML file and parsing through that instead to
improve performance, but I''m not quite sure how to cache XML in Rails
or if that would be helpful.
Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---