Skip to content
Browse files

add some canned searches to the search engines to the profile pages

  • Loading branch information...
1 parent 9c58215 commit 9f2b47ecc769f2097c75a9da7b8f32458e8015fe @jronallo committed Mar 3, 2012
Showing with 62 additions and 1 deletion.
  1. +1 −0 Gemfile
  2. +1 −0 Gemfile.lock
  3. +21 −0 app/helpers/profiles_helper.rb
  4. +10 −0 app/models/profile.rb
  5. +18 −0 app/views/profiles/show.html.erb
  6. +11 −1 lib/capsys/imlsdcc_profile.rb
View
1 Gemfile
@@ -18,6 +18,7 @@ gem 'thin'
gem 'omniauth'
gem 'omniauth-twitter'
+gem 'addressable', :require => ["addressable/uri"]
gem 'anjlab-bootstrap-rails', '>= 2.0', :require => 'bootstrap-rails'
View
1 Gemfile.lock
@@ -214,6 +214,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ addressable
anjlab-bootstrap-rails (>= 2.0)
bson_ext
coffee-rails (~> 3.2.1)
View
21 app/helpers/profiles_helper.rb
@@ -5,4 +5,25 @@ def link_to_category(category)
link_to link_text, profiles_path(:category => category['_id']),
:class => [:btn, 'btn-small', 'btn-primary', :category]
end
+
+ def url_with_site_query(text, url, profile)
+ site_url = CGI::escape(profile.search_url)
+ link_to text, "http://#{url}?q=site:#{site_url}", :target => '_blank'
+ end
+ def google_web_link(profile)
+ url_with_site_query('Google Web', 'www.google.com/search', profile)
+ end
+ def google_image_link(profile)
+ url_with_site_query('Google Images', 'www.google.com/images', profile)
+ end
+ def google_video_link(profile)
+ url_with_site_query('Google Videos', 'www.google.com/videos', profile)
+ end
+ def bing_web_link(profile)
+ url_with_site_query('Bing Web', 'www.bing.com/search', profile)
+ end
+ def bing_image_link(profile)
+ url_with_site_query('Bing Images', 'www.bing.com/images/search', profile)
+ end
+
end
View
10 app/models/profile.rb
@@ -28,6 +28,16 @@ def as_json(options={})
super.merge(:achievements => json_achievements)
end
+ def search_url
+ uri = Addressable::URI.parse url
+ path = if File.split(uri.path).last.include?('.')
+ File.split(uri.path).first
+ else
+ uri.path
+ end
+ File.join(uri.host, path)
+ end
+
private
def update_achievement_count
View
18 app/views/profiles/show.html.erb
@@ -50,21 +50,39 @@
</ul>
<% end -%>
</div>
+ <div></div>
</div>
<div>
<p>Created At: <%= @profile.created_at %></p>
<p>Updated At: <%= @profile.updated_at %></p>
</div>
+ <div>
+ <h3>Searches on this collection</h3>
+ <p>Check how much of this collection is indexed by the search engines with a "site:" search.</p>
+ <ul>
+ <li><%= google_web_link(@profile) %></li>
+ <li><%= google_image_link(@profile) %></li>
+ <li><%= google_video_link(@profile) %></li>
+ <li><%= bing_web_link(@profile) %></li>
+ <li><%= bing_image_link(@profile) %></li>
+
+ </ul>
+ </div>
</div>
</div>
+<% if !@profile.edits.blank? %>
<div>
<h2>Edits</h2>
<%= render :partial => '/edits/table', :locals => {:edits => @profile.edits} %>
</div>
+<% end -%>
<% if Rails.env == 'development' %>
+<div class="row">
+ <br><br><br><br><br><br>
<%= debug @profile.attributes %>
+</div>
<% end -%>
View
12 lib/capsys/imlsdcc_profile.rb
@@ -18,14 +18,24 @@ def profile
fields
end
+ def vcard
+ vcard_xml = @doc.xpath('//vcard:VCARD/vcard:ADR/..', namespaces)
+ fields = []
+ vcard_xml.xpath('*').each do |child|
+ puts child.name
+ end
+ fields
+ end
+
protected
def namespaces
{'cld' => "http://purl.org/cld/terms/",
'imlsdccProf' => "http://imlsdcc.grainger.uiuc.edu/profile#",
'dcterms' => "http://purl.org/dc/terms/",
'dc' => "http://purl.org/dc/elements/1.1/",
- 'xsi'=>"http://www.w3.org/2001/XMLSchema-instance"
+ 'xsi'=>"http://www.w3.org/2001/XMLSchema-instance",
+ 'vcard' => 'http://www.w3.org/2001/vcard-rdf/3.0#'
}
end
end

0 comments on commit 9f2b47e

Please sign in to comment.
Something went wrong with that request. Please try again.