Navigation Menu

Skip to content

Commit

Permalink
enhancement: adding metadata to item show pages in order to support Z…
Browse files Browse the repository at this point in the history
…otero, though appears to need more work.
  • Loading branch information
Kieran Pilkington committed Dec 21, 2009
1 parent b24f085 commit 828c0fc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -369,7 +369,7 @@ def show_basket_list_naviation_menu?
end

# caching related
SHOW_PARTS = ['page_title_[privacy]', 'page_keywords_[privacy]',
SHOW_PARTS = ['page_title_[privacy]', 'page_keywords_[privacy]', 'dc_metadata_[privacy]',
'page_description_[privacy]', 'google_map_api_[privacy]', 'edit_[privacy]',
'details_first_[privacy]', 'details_second_[privacy]',
'contributor_[privacy]', 'flagging_[privacy]',
Expand Down
36 changes: 33 additions & 3 deletions app/helpers/application_helper.rb
Expand Up @@ -91,6 +91,32 @@ def page_description
strip_tags(truncate(description_text, :length => 180, :omission => '...')).gsub("\"", "").squish
end

def meta_tag(*args)
tag(:meta, *args) + "\n"
end

def dc_metadata_for(item)
metadata = String.new

metadata += meta_tag(:name => 'DC.Identifier', :content => url_to_item(item, :locale => false, :only_path => false), :scheme => "URI")
metadata += meta_tag(:name => 'DC.Title', :content => stripped_title)
metadata += meta_tag(:name => 'DC.Description', :content => page_description)
metadata += meta_tag(:name => 'DC.Subject', :content => page_keywords)
metadata += meta_tag(:name => 'DC.Creator', :content => item.creator.user_name)
contributors = item.contributors.uniq[0..3].collect { |c| c.user_name }
metadata += meta_tag(:name => 'DC.Contributor', :content => contributors.join(', ') + ", et al") if contributors.size > 1
metadata += meta_tag(:name => 'DC.Publisher', :content => PRETTY_SITE_NAME)
metadata += meta_tag(:name => 'DC.Type', :content => 'Text', :scheme => "IMT")
metadata += meta_tag(:name => 'DC.Format', :content => 'text/html')
metadata += meta_tag(:name => 'DC.Rights', :content => item.license.url) if item.license
metadata += meta_tag(:name => 'DC.Rights', :content => item.license.name) if item.license
metadata += meta_tag(:name => 'DC.Language', :content => I18n.locale, :scheme => "RFC3066")
metadata += meta_tag(:name => 'DC.Date.created', :content => item.created_at.to_date, :scheme => "IS08601")
metadata += meta_tag(:name => 'DC.Date.modified', :content => item.updated_at.to_date, :scheme => "IS08601")

metadata
end

def header_links_to_baskets
html = '<ul id="basket-list" class="nav-list">'

Expand Down Expand Up @@ -452,10 +478,14 @@ def link_to_cancel(from_form = "")
html += "</div>"
end

def link_to_item(item)
link_to h(item.title), :controller => zoom_class_controller(item.class.name),
def url_to_item(item, options = {})
url_for({:controller => zoom_class_controller(item.class.name),
:urlified_name => item.basket.urlified_name,
:action => :show, :id => item
:action => :show, :id => item}.merge(options))
end

def link_to_item(item)
link_to h(item.title), url_to_item(item)
end

def url_for_contributions_of(user, zoom_class)
Expand Down
8 changes: 8 additions & 0 deletions app/views/layouts/application.rhtml
Expand Up @@ -29,6 +29,14 @@
<% end -%>
<% end -%>
<%= meta_tag :name => 'content-language', :content => I18n.locale %>
<% if cached_controllers.include?(params[:controller]) && params[:action] == "show" %>
<% cache_with_privacy(current_item, { :part => 'dc_metadata' }) do %>
<%= dc_metadata_for(current_item) unless current_item.private? %>
<% end %>
<% end %>
<% if using_tiny_mce? -%>
<% # Include TinyMCE before other JS to avoid problems,
# tinymce not compatible with bundle_fu -%>
Expand Down

0 comments on commit 828c0fc

Please sign in to comment.