app/views/content/display/_category_panel.html.erb
<div id="<%= category[:name].gsub("'", '') %>_panel" class="card panel">
<div class="<%= @content.class.text_color %> text-darken-1 section-title sticky-below-navbar <%= @content.class.color %> lighten-5">
<i class="material-icons right"><%= category[:icon] %></i>
<%= category[:label] %>
</div>
<div class="card-content">
<% category[:fields].reject { |field| field[:hidden] }.each do |serialized_field| %>
<%# Don't show private fields unless we're signed in AND the owner of the content %>
<% if serialized_field[:label].start_with?("Private") %>
<%
next unless user_signed_in? && (
(content.raw_model.is_a?(Universe) && content.user == current_user) ||
(content.raw_model.respond_to?(:universe) && content.universe && content.universe.user == current_user) ||
(content.raw_model.respond_to?(:universe) && content.universe.nil? && content.user == current_user)
)
%>
<% end %>
<%
value = case serialized_field[:type]
when 'universe'
Universe.where(id: serialized_field[:value].to_i)
when 'name', 'text_area'
serialized_field[:value]
when 'link'
serialized_field[:value]
when 'tags'
content.page_tags
else
raise "unknown field type = " + serialized_field[:type].inspect
end
%>
<%
# Don't show fields with a blank value
next if value.blank?
%>
<div class="col s12 field-value">
<div class="grey-text">
<%
prompt = I18n.translate "attributes.#{content.class_name.downcase}.#{serialized_field[:label].downcase.gsub(/\s/, '_')}",
scope: :serendipitous_questions,
name: content.name || "this #{content.class_name}",
default: ''
%>
<span>
<strong class="uppercase"><%= serialized_field[:label] %></strong>
<%= "- #{prompt}" unless prompt.blank? %>
</span>
</div>
<%=
render partial: "content/display/attribute_value/#{serialized_field[:type]}",
locals: { value: value, content: content }
%>
</div>
<% end %>
<div class="clearfix"></div>
</div>
</div>