Add content sections to trending feed

This commit is contained in:
syeopite 2021-05-08 06:07:30 -07:00
parent d3384e17f1
commit fbe9a0c0f2
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
4 changed files with 49 additions and 5 deletions

View File

@ -600,3 +600,20 @@ hr {
display: none; display: none;
} }
} }
.category {
margin: 3em 0px 4em 0px;
}
.category .heading > p {
display: inline-block;
}
.category .badge.featured {
background: #005aa7;
color: white;
padding: 3px 4px 1px 4px;
border-radius: 5px;
font-size: 14px;
margin-left: 10px;
}

View File

@ -27,7 +27,7 @@ def fetch_trending(trending_type, region, locale)
end end
initial_data = extract_initial_data(trending) initial_data = extract_initial_data(trending)
trending = extract_videos(initial_data) trending = extract_items(initial_data)
return {trending, plid} return {trending, plid}
end end

View File

@ -37,9 +37,36 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<% trending.each_slice(4) do |slice| %> <% trending.each do |category| %>
<% slice.each do |item| %> <% if category.is_a? Category %>
<%# We don't need to differinate between a category that only
# contains videos and no metadata %>
<% if category.title.empty? %>
<% category.contents.each do |item| %>
<%= rendered "components/item" %> <%= rendered "components/item" %>
<% end %> <% end %>
<% else %>
<div class="category pure-u-1">
<div class="category-heading h-box">
<p> <%= category.title %> </p>
<% if (badges = category.badges).is_a? Array %>
<% badges.each do | badge |%>
<% if badge[0] == "BADGE_STYLE_TYPE_FEATURED" %>
<div class="badge featured">
<span> <%=badge[1] %><span>
</div>
<% end %>
<% end %>
<% end %>
</div>
<div class="pure-g">
<% category.contents.each do |item| %>
<%= rendered "components/item" %>
<% end %>
</div>
</div>
<% end %>
<% end %>
<% end %> <% end %>
</div> </div>