Revision c7dd4b36
Added by Marc Dequènes over 15 years ago
- ID c7dd4b36a429fbcb4b8ac26f141b914bae774149
app/controllers/view_controller.rb | ||
---|---|---|
class ViewController < ApplicationController
|
||
end
|
app/helpers/application_helper.rb | ||
---|---|---|
end
|
||
image_tag(img.public_filename(thumb_name))
|
||
end
|
||
|
||
def display_artwork_frame(artwork, params = {})
|
||
frame_type = params.has_key?(:frame_type) ? params[:frame_type] : :classic
|
||
size = params[:size] || :thumb_big
|
||
display_title = params.has_key?(:display_title) ? params[:display_title] : true
|
||
display_size = params.has_key?(:display_size) ? params[:display_size] : true
|
||
|
||
style = "text-align: center; padding: 0px;"
|
||
case frame_type
|
||
when :classic
|
||
style += " margin: 7px;"
|
||
when :cell
|
||
style += " padding-left: 3px; padding-right: 3px; margin-top: 7px; margin-bottom: 7px; margin-left: auto; margin-right: auto;"
|
||
when :float
|
||
style += " margin: 7px; float: left;"
|
||
end
|
||
|
||
html = "<div style=\"" + style + "\">"
|
||
html += "<div style=\padding: 0px; margin: 0px;\">" + display_thumbnail(artwork.image, size) + "</div>"
|
||
infos = []
|
||
if display_title
|
||
title = params[:force_title] ? params[:force_title] : artwork.title
|
||
infos << title
|
||
end
|
||
if display_size
|
||
infos << "<span style=\"font-size: smaller;\">(" + artwork.artwork_size.human_size + ")</span>"
|
||
end
|
||
html += infos.join("<br />")
|
||
html += "</div>"
|
||
end
|
||
end
|
app/views/layouts/application.rhtml | ||
---|---|---|
<div id="header">
|
||
<h1><%= link_to_unless_current "~°~ #{site_name} ~°~", root_path %></h1>
|
||
<ul class="nav" id="menu">
|
||
<li><strong><%= _("View") %></strong>
|
||
<ul>
|
||
<li><%= link_to _("Cyma Tree"), :controller => 'view', :action => 'tree' %></li>
|
||
</ul>
|
||
</li>
|
||
<%
|
||
current_user ||= ((session[:user_id] && User.find_by_id(session[:user_id])) || nil)
|
||
if current_user
|
app/views/view/tree.rhtml | ||
---|---|---|
<h1><%= _("Tree view of the Cyma") %></h1>
|
||
|
||
<table>
|
||
<% ArtworkSet.find(:all).each do |set| %>
|
||
<tr><th><%= display_artwork_frame(set.artworks.last, :frame_type => :cell, :size => :thumb_small, :force_title => set.name, :display_size => false) %></th>
|
||
<% unless set.artwork_groups.empty? %>
|
||
<% set.artwork_groups.each do |group| %>
|
||
<td><%= display_artwork_frame(group.artworks.last, :frame_type => :cell, :size => :thumb_small, :force_title => group.name, :display_size => false) %></td>
|
||
<% end %>
|
||
<% end %>
|
||
</tr>
|
||
<% end %>
|
||
</table>
|
app/views/welcome/index.rhtml | ||
---|---|---|
# reload to ensure joint objects are well loaded
|
||
artwork = Artwork.find(artwork.id)
|
||
%>
|
||
<div style="float: left; text-align: center; margin: 7px;"><div><%= display_thumbnail(artwork.image, :thumb_big) %></div><%= artwork.title %><br /><span style="font-size: smaller;">(<%= artwork.artwork_size.human_size %>)</span></div>
|
||
<%= display_artwork_frame(artwork, :frame_type => :float) %>
|
||
<% end %>
|
||
<br style="clear: both;"/>
|
||
</p>
|
Also available in: Unified diff
[evol] created display_artwork_frame() helper function and now use it in the welcome page + created a set/group tree view with it too