app/views/anime/show.html.erb
<% content_for :head do %>
<% if @anime.show_type == "Movie" %>
<meta property="og:type" content="video.movie">
<% elsif ["OVA", "ONA", "TV"].include? @anime.show_type %>
<meta property="og:type" content="video.tv_show">
<% else %>
<meta property="og:type" content="video.other">
<% end %>
<meta property="og:url" content="<%= anime_url(@anime) %>">
<meta property="og:description" content="<%= @anime.synopsis.gsub('"', '\\"') %>">
<meta property="og:image" content="<%= @anime.poster_image.url %>">
<% if @anime.cover_image.file? %>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="<%= @anime.cover_image.url(:thumb) %>">
<% else %>
<meta name="twitter:card" content="summary">
<% end %>
<meta name="twitter:site" content="@hummingbird_me">
<meta name="twitter:title" content="<%= @anime.canonical_title %>">
<% end %>
<% content_for :body do %>
<div class="container bg-image" itemscope itemtype="http://schema.org/TVSeries">
<div class="row">
<div class="gallery">
<% if @anime.youtube_video_id %>
<div class="trailer" <%= schema_scope(:VideoObject, :trailer) %>>
<a href="#">
<div class="play-icon"><i class="fa fa-play fa-4x"></i></div>
<%= schema_image(:thumbnailURL,
"http://img.youtube.com/vi/#{@anime.youtube_video_id}/hqdefault.jpg",
{ width: "100%", height: "auto", alt: "Trailer Video" }) %>
<%= schema_tag(:span, :embedUrl, "https://youtube.googleapis.com/v/#{@anime.youtube_video_id}") %>
</a>
</div>
<% end %>
<ul class="gallery-images">
<% @anime.gallery_images.each do |img| %>
<li class="gallery-image">
<%= schema_image(:image, img.image.url) %>
</li>
<% end %>
</ul>
</div>
<div class="series-body">
<div class="panel panel-default series-panel">
<div class="series-sidebar">
<%= schema_image(:image, @anime.poster_image.url, {class: "series-poster", alt: "Poster"}) %>
<div class="community-rating personal-rating" <%= schema_scope(:AggregateRating, :aggregateRating) %>>
<h5 class="sidebar-title text-center">Community Rating</h5>
<%= schema_tag(:meta, :bestRating, 5.0) %>
<%= schema_tag(:meta, :worstRating, 0.5) %>
<div class="awesome-rating-widget" <%= schema_prop(:ratingValue, @anime.bayesian_rating) if @anime.bayesian_rating > 0 %>>
<%# TODO: actually make this not suck %>
<%- rating = @anime.bayesian_rating.floor %>
<%- open_star = content_tag(:span, content_tag(:i, "", class: "fa fa-star-o"), class: "icon-container") %>
<%- full_star = content_tag(:span, content_tag(:i, "", class: "fa fa-star"), class: "icon-container") %>
<%= (full_star * rating).html_safe %>
<%= (open_star * (5 - rating)).html_safe %>
</div>
</div>
</div>
<div class="series-content">
<h1 itemprop="name" class="series-title"><%= @anime.canonical_title %></h1>
<ul class="series-metadata">
<%= schema_tag(:meta, :inLanguage, "ja-JP") %>
<li <%= schema_prop(:isFamilyFriendly, @anime.sfw?) %>><%= @anime.sfw? ? "SFW" : "NSFW" %></li>
<li <%= schema_prop(:contentRating) %>><%= @anime.age_rating %></li>
<li <%= schema_prop(:numberOfEpisodes, @anime.episode_count) %>><%= @anime.episode_count %> episodes</li>
<!-- There's no microformat for episode-length, but we can set a duration on episode items -->
<li><%= @anime.episode_length %> min</li>
<li><%= case @anime.status
when "Finished Airing"; "Aired"
when "Currently Airing"; "Airing"
else "Will air"
end %><% started = @anime.started_airing_date; finished = @anime.finished_airing_date %>
<%= @anime.episodes.count == 1 ? "on" : "from" %>
<time <%= schema_prop(:startDate, started.try(:iso8601)) %>><%= started && started.strftime("%e %b %Y") %></time>
<% unless finished.nil? %>
to <time <%= schema_prop(:endDate, finished.try(:iso8601)) %>><%= finished && finished.strftime("%e %b %Y") %></time>
<% end %>
</li>
</ul>
<div class="series-description" itemprop="description">
<p><%= @anime.synopsis.gsub("\n", "</p><p>").html_safe %></p>
</div>
<h3>Cast</h3>
<ul class="cast">
<% @anime.castings.where.not(character: nil).where(language: "Japanese", featured: true).each do |casting| %>
<li class="actor" <%= schema_scope(:PerformanceRole, :actor) %>>
<a class="character">
<%= schema_image(:image, casting.character.image.url, { alt: ""}) %>
<span <%= schema_prop(:characterName) %>><%= casting.character.name %></span>
</a>
<%- unless casting.person.nil? %>
<span class="va" <%= schema_scope(:Person, :actor) %>>
<a class="voice-actor">
<span <%= schema_prop(:name) %>><%= casting.person.name %></span>
<%= schema_image(:image, casting.person.image.url, { alt: ""}) %>
</a>
</span>
<%- end %>
</li>
<% end %>
</ul>
<h3>Franchise</h3>
<% @anime.franchises.each do |franchise| %>
<h4><%= franchise.english_title %></h4>
<ul>
<% franchise.anime.each do |anime| %>
<li><%= link_to anime.canonical_title, anime %></li>
<% end %>
</ul>
<% end %>
<h3>Studios</h3>
<div class="genre-tab">
<% @anime.producers.each do |producer| %>
<span class="badge" <%= schema_prop(:productionCompany) %>><%= producer.name %></span> <% end %>
</div>
<h3>Quotes</h3>
<%= link_to "View All", "#{url_for(@anime)}/quotes" %>
<h3>Genres</h3>
<div class="genre-tab">
<% @anime.genres.each do |genre| %>
<span class="badge"><a href="<%= url_for(genre) %>" <%= schema_prop(:genre) %>><%= genre.name %></a></span>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>