OSDN Git Service

t#31282:add appender
authoryasushiito <yas@pen-chan.jp>
Mon, 6 May 2013 00:20:03 +0000 (09:20 +0900)
committeryasushiito <yas@pen-chan.jp>
Mon, 6 May 2013 00:20:03 +0000 (09:20 +0900)
app/controllers/home_controller.rb
app/controllers/panels_controller.rb
app/controllers/stories_controller.rb
app/views/panels/_append_comic.html.erb [new file with mode: 0644]
app/views/panels/show.html.erb
app/views/stories/_append_panel.html.erb [new file with mode: 0644]
app/views/stories/comic.html.erb
config/locales/pettanr.ja.yml

index 3d8c537..c9b3390 100644 (file)
@@ -68,7 +68,7 @@ class HomeController < ApplicationController
     @panels = Panel.mylist(@author, @page, @page_size)
 
     respond_to do |format|
-      format.html # index.html.erb
+      format.html 
       format.json { render text: Panel.list_as_json_text(@panels) }
     end
   end
index 2804bad..f099e64 100644 (file)
@@ -29,7 +29,12 @@ class PanelsController < ApplicationController
     @panel = Panel.show(params[:id], [@user, @admin])
 
     respond_to do |format|
-      format.html # show.html.erb
+      format.html {
+        if @author
+          @new_comics = Comic.mylist(@author, 0, 5)
+          @fresh_comics = Story.mylist(@author, 0, 5).map {|s| s.comic}
+        end
+      }
       format.json { render json: @panel.panel_elements_as_json }
       format.jsonp {
         render :json => "callback(" + @panel.panel_elements_as_json + ");"
index 7d12912..da255bd 100644 (file)
@@ -37,7 +37,11 @@ class StoriesController < ApplicationController
     @panel_count = Story.panel_count cnt, params[:count]
     @stories = Story.play_list(@comic, @author, @offset, @panel_count)
     respond_to do |format|
-      format.html # index.html.erb
+      format.html {
+        if @author
+          @new_panels = Panel.mylist(@author, 0, 5)
+        end
+      }
       format.json {render text: Story.list_as_json_text(@stories, @author)}
       format.jsonp {
         render :json => "callback(" + @stories.to_json_list + ");"
diff --git a/app/views/panels/_append_comic.html.erb b/app/views/panels/_append_comic.html.erb
new file mode 100644 (file)
index 0000000..2190d65
--- /dev/null
@@ -0,0 +1,32 @@
+<tr>
+  <td>
+    <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
+    <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
+    (<%= comic.stories.size -%>)
+  </td>
+  <td>
+    <%= distance_of_time_in_words_to_now comic.updated_at %>
+  </td>
+  <td>
+    <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %>
+    <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %>
+  </td>
+  <td>
+    <% if comic.own? author %>
+      <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id %>
+      <%= form_for(@story) do |f| %>
+        <%= f.hidden_field :comic_id %>
+        <%= f.hidden_field :t %>
+        <%= f.hidden_field :panel_id %>
+        <div class="actions">
+          <%= f.submit t('panels.show.append') %>
+        </div>
+      <% end %>
+    <% end %>
+  </td>
+</tr>
+<tr>
+  <td colspan="4">
+    <%= h(truncate(comic.description, :length => 40)) %>
+  </td>
+</tr>
index d8bfa24..98c685e 100644 (file)
@@ -4,3 +4,16 @@
 
 <%= link_to t('link.edit'), edit_panel_path(@panel) %>
 <%= link_to t('link.destroy'), panel_path(@panel), :method => :delete %>
+
+<h2><%= t('panels.show.new_comics') -%></h2>
+<table>
+  <% @new_comics.each do |comic| %>
+    <%= render 'append_comic', :panel => @panel, :comic => comic, :author => @author %>
+  <% end %>
+</table>
+<h2><%= t('panels.show.fresh_comics') -%></h2>
+<table>
+  <% @fresh_comics.each do |comic| %>
+    <%= render 'append_comic', :panel => @panel, :comic => comic, :author => @author %>
+  <% end %>
+</table>
diff --git a/app/views/stories/_append_panel.html.erb b/app/views/stories/_append_panel.html.erb
new file mode 100644 (file)
index 0000000..241bcf8
--- /dev/null
@@ -0,0 +1,21 @@
+<tr>
+  <td>
+    <%= link_to panel_icon(:object => panel, :size => 25), panel_path(panel) %>
+    <%= link_to author_icon(:object => panel.author, :size => 17), author_path(panel.author) %>
+  </td>
+  <td>
+    <%= link_to h(truncate(h(panel.caption), :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
+  </td>
+  <td>
+    <%= l panel.updated_at %>
+  </td>
+  <td>
+    <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id -%>
+    <%= form_for(@story) do |f| %>
+      <%= f.hidden_field :comic_id %>
+      <%= f.hidden_field :t %>
+      <%= f.hidden_field :panel_id %>
+      <%= f.submit t('stories.comic.append') %>
+    <% end %>
+  </td>
+</tr>
index 9c042e5..82dbb4b 100644 (file)
   <%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %>
 <% end %>
 <% if @comic.own? @author -%>
-  <h3><%= t('stories.new.title') %></h3>
-  <% @story = Story.new ; @story.comic_id = @comic.id ; @story.t = Story.new_t @comic.id -%>
-  <%= form_for(@story) do |f| %>
-
-    <div class="field">
-      <%= f.hidden_field :comic_id %>
-    </div>
-    <div class="field">
-      <%= f.label :t %><br />
-      <%= f.number_field :t %>
-    </div>
-    <div class="field">
-      <%= f.label :panel_id %><br />
-      <%= f.number_field :panel_id %>
-    </div>
-
-    <div class="actions">
-      <%= f.submit %>
-    </div>
-  <% end %>
+  <h3><%= t('stories.comic.new_panels') -%></h3>
+  <table>
+    <% @new_panels.each do |panel| %>
+      <%= render 'append_panel', :comic => @comic, :panel => panel, :author => @author %>
+    <% end %>
+  </table>
 <% end %>
index 6d4ed08..5026181 100644 (file)
@@ -467,6 +467,8 @@ ja:
     comic:
       title: コミックを読む
       empty: ストーリーはありません
+      append: このコマを追加する
+      new_panels: 最近作成したコマ
     list:
       title: ストーリー 生一覧
     browse:
@@ -477,6 +479,9 @@ ja:
       title: コマ一覧
     show:
       title: コマ詳細
+      append: このコミックに追加する
+      new_comics: 最近作成したコミック
+      fresh_comics: 最近更新したコミック
     new:
       title: コマ作成
     edit: