Skip to content

Commit

Permalink
Implement Share::File views
Browse files Browse the repository at this point in the history
  • Loading branch information
mizoki authored and kaosf committed Jun 11, 2015
1 parent fd91638 commit d3b7ad0
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/views/share/files/_menu.html.erb
@@ -0,0 +1,17 @@
<nav class="act-menu">
<% if params[:action] =~ /index/ %>
<%= link_to t('views.button.upload'), action: :new %>
<% elsif params[:action] =~ /new|create/ %>
<%= link_to :back_to_index, action: :index %>
<% elsif params[:action] =~ /edit|update|delete/ %>
<%= link_to :back_to_show, action: :show, id: @item %>
<%= link_to :back_to_index, action: :index %>
<% else %>
<%= link_to :delete, action: :delete, id: @item %>
<%= link_to :back_to_index, action: :index %>
<% end %>
</nav>

<% if params[:action] =~ /show|new|edit|create|update/ %>
<%= render file: "_addons_menu" %>
<% end %>
47 changes: 47 additions & 0 deletions app/views/share/files/index.html.erb
@@ -0,0 +1,47 @@
<% unless @items.empty? %>

<div class="index share-files">
<table class="share-files-view">
<thead>
<tr>
<th>&nbsp;</th>
<th><%= @model.t("basename") %></th>
<th><%= @model.t("size") %></th>
<th><%= @model.t("user_id") %></th>
<th><%= @model.t("created") %></th>
<th><%= @model.t("updated") %></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<% @items.each do |item| %>
<tr id="share-file<%= item.id %>">
<td>
<a class="thumb view" href="<%= url_for action: :view, id: item %>">
<% if item.image? %>
<img src="<%= url_for(action: :thumb, id: item) %>" alt="<%= item.basename %>" />
<% else %>
<span class="ext icon-<%= item.extname %>"><%= item.extname %></span>
<% end %>
</a>
</td>
<td><a class="detail" href="<%= url_for action: :show, id: item %>"><%= item.basename %></a></td>
<td class="filesize"><%= number_to_human_size(item.size) %></td>
<td class="owner"><%= item.user.name %></td>
<td><%= item.created.strftime("%Y/%m/%d %H:%M") %></td>
<td><%= item.updated.strftime("%Y/%m/%d %H:%M") %></td>
<td>
<%= link_to t("views.button.download"), download_share_file_path(id: item), class: "download" %>
<%= link_to t("views.button.delete"), delete_share_file_path(id: item), class: "delete", id: "#share-file#{item.id}" %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

<div style="clear: both;"></div>

<%= paginate @items if @items.try(:current_page) %>
<% end %>
9 changes: 9 additions & 0 deletions app/views/share/files/new.html.erb
@@ -0,0 +1,9 @@
<%= form_for :item, url: { action: :create }, html: { class: "share-file", multipart: true } do |f| %>
<%= error_messages_for :item %>

<div class="uploader">
<%= f.file_field :in_files, multiple: :multiple, required: :required %>
<%= f.submit t("views.button.upload"), class: :save %>
</div>

<% end %>
23 changes: 23 additions & 0 deletions app/views/share/files/show.html.erb
@@ -0,0 +1,23 @@
<div class="file-detail">
<a class="thumb" href="<%= view_share_file_path(id: @item) %>" target="_blank">
<% if @item.image? %>
<img src="<%= thumb_share_file_path(id: @item) %>" alt="<%= @item.basename %>" />
<% else %>
<span class="ext icon-<%= @item.extname %>"><%= @item.extname %></span>
<% end %>
</a>
<div class="name">
<input type="hidden" name="item[image_id]" value="<%= @item.id %>" />
<%= @item.basename %>
<br />
</div>
<div class="filesize">
<%= number_to_human_size(@item.size) %>
</div>
<div class="owner">
<%= @item.user.name %>
</div>
<div class="action download">
<%= link_to t("views.button.download"), download_share_file_path(id: @item), class: "download" %>
</div>
</div>

0 comments on commit d3b7ad0

Please sign in to comment.