From: yasushiito Date: Tue, 6 Nov 2012 09:27:57 +0000 (+0900) Subject: t#30009:fix views X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=4b5ea5abe420f26bd59a7f869b38893394306243 t#30009:fix views --- diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index fdc3fe3e..83142c51 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -90,17 +90,6 @@ class HomeController < ApplicationController end end - def picture - @page = OriginalPicture.page params[:page] - @page_size = OriginalPicture.page_size params[:page_size] - @original_pictures = OriginalPicture.mylist(@artist.id, @page, @page_size) - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @original_pictures.to_json(OriginalPicture.list_json_opt) } - end - end - def panel_picture @page = Author.page params[:page] @page_size = Author.panel_picture_page_size params[:page_size] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..b3709d15 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,6 @@ module ApplicationHelper + def full_url filename + request.protocol + request.host_with_port + filename + end + end diff --git a/app/models/comic.rb b/app/models/comic.rb index 7802ba5b..f32b0bd2 100644 --- a/app/models/comic.rb +++ b/app/models/comic.rb @@ -31,10 +31,6 @@ class Comic < ActiveRecord::Base self.visible > 0 end - def disp_visible - visible == 1 ? 'O' : 'X' - end - def self.default_page_size 25 end diff --git a/app/models/panel_picture.rb b/app/models/panel_picture.rb index 47b293ea..31c4305e 100644 --- a/app/models/panel_picture.rb +++ b/app/models/panel_picture.rb @@ -27,12 +27,12 @@ class PanelPicture < ActiveRecord::Base end def opt_img_tag - {:src => self.url, :vPicture => self.id, :width => self.width.abs, :height => self.height.abs, :style => "top:#{self.y}px; left:#{self.x}px; z-index:#{self.z}; "} + {:src => self.url, :vPicture => self.id, :width => self.width.abs, :height => self.height.abs, :alt => self.caption, :style => "top:#{self.y}px; left:#{self.x}px; z-index:#{self.z}; "} end def tmb_opt_img_tag tw, th = PettanImager.thumbnail_size(self.width.abs, self.height.abs) - {:src => self.url, :width => tw, :height => th} + {:src => self.url, :width => tw, :height => th, :alt => self.caption} end def self.default_page_size diff --git a/app/views/comics/_form.html.erb b/app/views/comics/_form.html.erb index 636f7fdb..c547013d 100644 --- a/app/views/comics/_form.html.erb +++ b/app/views/comics/_form.html.erb @@ -17,7 +17,7 @@
<%= f.label :visible %>
- <%= f.collection_select :visible, [['only me', 0], ['everyone', 1]], :last, :first, :html => {:selected => @comic.visible} %> + <%= f.collection_select :visible, MagicNumber['comic_visible_items'], :last, :first, :html => {:selected => @comic.visible} %>
diff --git a/app/views/comics/_list_item.html.erb b/app/views/comics/_list_item.html.erb new file mode 100644 index 00000000..532ca64f --- /dev/null +++ b/app/views/comics/_list_item.html.erb @@ -0,0 +1,17 @@ + + + <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> + + + <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %> + + + <%= comic.updated_at %> + + + <% if comic.own? author %> + <%= link_to 'edit', edit_comic_path(comic) %> + <%= link_to 'destroy', comic_path(comic), :method => :dellete %> + <% end %> + + diff --git a/app/views/comics/index.html.erb b/app/views/comics/index.html.erb index 246b92e2..0fdac378 100644 --- a/app/views/comics/index.html.erb +++ b/app/views/comics/index.html.erb @@ -1,14 +1,14 @@

Listing comics

-<% @comics.each do |comic| %> -
-
- <%= link_to h(comic.title), :controller => 'stories', :action => :comic, :id => comic.id %> -
-
- 作家:<%= h comic.author.name %> - 更新:<%= comic.updated_at %> -
-
-<% end %> + + + + + + + + <% @comics.each do |comic| %> + <%= render 'list_item', :comic => comic, :author => @author %> + <% end %> +
titleauthorupdated_atedit
<%= link_to 'new comic', new_comic_path %> diff --git a/app/views/comics/play.html.erb b/app/views/comics/play.html.erb deleted file mode 100644 index 2134033b..00000000 --- a/app/views/comics/play.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

<%= h @comic.title %>

-<% if @comic.own? @author -%> -
- <%= link_to 'edit comic property', edit_comic_path(@comic), :remote => true %> -
-
-
-<% end -%> - -<% @comic.panels.each do |panel| %> - <% @panel = panel %> - <%= render 'panels/standard' %> -<% end %> - -<%= link_to 'Back', comics_path %> diff --git a/app/views/comics/show.html.erb b/app/views/comics/show.html.erb index 15154295..83b669f1 100644 --- a/app/views/comics/show.html.erb +++ b/app/views/comics/show.html.erb @@ -1,8 +1,9 @@ +

コミックの表示

<%= notice %>

Title: - <%= h @comic.title %> + <%= link_to h(@comic.title), :controller => 'stories', :action => :comic, :id => @comic.id %>

@@ -11,8 +12,8 @@

- author_id: - <%= @comic.author_id %> + author: + <%= link_to h(@comic.author.name), author_path(@comic.author) %>

@@ -20,4 +21,6 @@ <%= @comic.updated_at %>

+<%= link_to 'edit', edit_comic_path(@comic) %> + <%= link_to 'Back', comics_path %> diff --git a/app/views/home/comic.html.erb b/app/views/home/comic.html.erb index f6088026..687265cd 100644 --- a/app/views/home/comic.html.erb +++ b/app/views/home/comic.html.erb @@ -3,15 +3,14 @@ <%= render 'comics/form' %> -<% @comics.each do |comic| %> -
-
- <%= link_to h(comic.title), :controller => 'comics', :action => :play, :id => comic.id %> - 一般投稿:<%= comic.disp_editable %> - 公開:<%= comic.disp_visible %> -
-
- 更新:<%= comic.updated_at %> -
-
-<% end %> + + + + + + + + <% @comics.each do |comic| %> + <%= render 'comics/list_item', :comic => comic, :author => @author %> + <% end %> +
titleauthorupdated_atedit
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 85659b5e..26ddf739 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -10,7 +10,3 @@ <%= render 'original_pictures/artist_register' %> <% end -%>
-<%= link_to 'my comics', :action => :comic %> -<%= link_to 'my panels', :action => :panel %> -<%= link_to 'my pictures', :action => :picture %> -<%= link_to 'my panel pictures', :action => :panel_picture %> diff --git a/app/views/home/panel.html.erb b/app/views/home/panel.html.erb index 3afba88d..d0aa666b 100644 --- a/app/views/home/panel.html.erb +++ b/app/views/home/panel.html.erb @@ -1,11 +1,7 @@ -

Listing panels

+

Listing My panels

<% @panels.each do |panel| %>
-
-
-
- 更新:<%= panel.updated_at %> -
+ <%= render 'panels/standard', :panel => panel, :author => @author %>
<% end %> diff --git a/app/views/home/panel_picture.html.erb b/app/views/home/panel_picture.html.erb index 0770b645..88801c95 100644 --- a/app/views/home/panel_picture.html.erb +++ b/app/views/home/panel_picture.html.erb @@ -1,10 +1,19 @@

Listing my panel pictures

+ + + + + + + + + + + + + <% @panel_pictures.each do |panel_picture| %> -
- <%= panel_picture.picture.filename %> - - <%= panel_picture.picture.width %>x<%= panel_picture.picture.height %> - <%= panel_picture.picture.filesize %>bytes -
+ <%= render 'panel_pictures/list_item', :panel_picture => panel_picture %> <% end %> +
picturecreditpanellinkx, y, ztWidthxHeightvhupdated_at
diff --git a/app/views/home/picture.html.erb b/app/views/home/picture.html.erb deleted file mode 100644 index 403add7c..00000000 --- a/app/views/home/picture.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -

Listing my pictures

-<%= render 'original_pictures/uploader' %> - -<% @original_pictures.each do |original_picture| %> -
- <%= original_picture.filename %> - - <%= original_picture.width %>x<%= original_picture.height %> - <%= original_picture.filesize %>bytes -
-<% end %> diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb index 017ef840..64b5dfeb 100644 --- a/app/views/layouts/test.html.erb +++ b/app/views/layouts/test.html.erb @@ -11,6 +11,11 @@
<% if user_signed_in? %> <%= link_to "my home", '/home' %> + <%= link_to 'my comics', '/home/comic' %> + <%= link_to 'my panels', '/home/panel' %> + <%= link_to 'my pictures', main_app.original_pictures_path %> + <%= link_to 'my panel pictures', '/home/panel_picture' %> + <%= link_to 'configure', '/home/configure' %> <%= link_to "sign out", main_app.destroy_user_session_path, :method => :delete %> <% else %> <%= link_to "sign in", main_app.new_user_session_path %> @@ -19,6 +24,12 @@
<% if admin_signed_in? %> <%= link_to "system", '/system' %> + <%= link_to "browse", '/system/browse' %> + <%= link_to "approve", '/system/waiting_list' %> + <%= link_to "token", '/system/auth_token' %> + layout: + <%= link_to "test", '/system/test_layout' %> + <%= link_to "production", '/system/production_layout' %> <%= link_to "sign out", main_app.destroy_admin_session_path, :method => :delete %> <% else %> <%= link_to "sign in", main_app.new_admin_session_path %> diff --git a/app/views/panel_pictures/_list_item.html.erb b/app/views/panel_pictures/_list_item.html.erb new file mode 100644 index 00000000..0bd0af45 --- /dev/null +++ b/app/views/panel_pictures/_list_item.html.erb @@ -0,0 +1,12 @@ + + <%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture.picture) %> + <%= render panel_picture.picture.credit_template, :picture => panel_picture.picture %> + <%= link_to panel_picture.panel.id, panel_path(panel_picture.panel) %> + <%= h panel_picture.link %> + <%= h panel_picture.caption %> + <%= panel_picture.x %>, <%= panel_picture.y %>, <%= panel_picture.z %> + <%= panel_picture.t %> + <%= panel_picture.width %>x<%= panel_picture.height %> + <%= panel_picture.flip %> + <%= panel_picture.updated_at %> + diff --git a/app/views/panel_pictures/index.html.erb b/app/views/panel_pictures/index.html.erb index d0ba00b4..21f51248 100644 --- a/app/views/panel_pictures/index.html.erb +++ b/app/views/panel_pictures/index.html.erb @@ -2,10 +2,11 @@ - - + + + @@ -14,16 +15,6 @@ <% @panel_pictures.each do |panel_picture| %> - - - - - - - - - - - + <%= render 'list_item', :panel_picture => panel_picture %> <% end %>
idpanel picturecreditpanel linkcaption x, y, z t WidthxHeight
<%= panel_picture.id %><%= panel_picture.panel_id %><%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture.picture) %><%= h panel_picture.link %><%= panel_picture.x %>, <%= panel_picture.y %>, <%= panel_picture.z %><%= panel_picture.t %><%= panel_picture.width %>x<%= panel_picture.height %><%= panel_picture.flip %><%= panel_picture.updated_at %>
diff --git a/app/views/panel_pictures/list.html.erb b/app/views/panel_pictures/list.html.erb index 640c79b6..ed929cae 100644 --- a/app/views/panel_pictures/list.html.erb +++ b/app/views/panel_pictures/list.html.erb @@ -12,6 +12,7 @@ t Width Height + caption created_at updated_at @@ -28,6 +29,7 @@ <%= panel_picture.t %> <%= panel_picture.width %> <%= panel_picture.height %> + <%= h panel_picture.caption %> <%= panel_picture.created_at %> <%= panel_picture.updated_at %> diff --git a/app/views/panel_pictures/list_item.html.erb b/app/views/panel_pictures/list_item.html.erb new file mode 100644 index 00000000..9f0fa4cd --- /dev/null +++ b/app/views/panel_pictures/list_item.html.erb @@ -0,0 +1,11 @@ + + <%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture.picture) %> + <%= panel_picture.panel_id %> + <%= link_to panel_picture.panel_id, panel_path(panel_picture.panel) %> + <%= h panel_picture.link %> + <%= panel_picture.x %>, <%= panel_picture.y %>, <%= panel_picture.z %> + <%= panel_picture.t %> + <%= panel_picture.width %>x<%= panel_picture.height %> + <%= panel_picture.flip %> + <%= panel_picture.updated_at %> + diff --git a/app/views/panels/_body.html.erb b/app/views/panels/_body.html.erb index 0b622fa1..ce1d04b1 100644 --- a/app/views/panels/_body.html.erb +++ b/app/views/panels/_body.html.erb @@ -3,15 +3,28 @@ <% case elm.class.to_s %> <% when 'PanelPicture' %> <%= tag(:img, elm.opt_img_tag) %> - <% when Balloon %> -
- + <% when 'SpeechBalloon' %> + <% balloon = elm.balloons.first %> +
+ <%= balloon.caption -%> <% elm.speeches.each do |speech| %>

<%= h speech.content -%>

<% end %>
- <% end ; p elm.class %> + <% when 'GroundColor' %> +
+ +
+ <% when 'PanelColor' %> +
;"> + +
+ <% when 'GroundPicture' %> +
+ +
+ <% end %> <% end %>
diff --git a/app/views/panels/_footer.html.erb b/app/views/panels/_footer.html.erb index b1c8efc6..b77c9ce6 100644 --- a/app/views/panels/_footer.html.erb +++ b/app/views/panels/_footer.html.erb @@ -1,10 +1,22 @@ + + +
+ <%= link_to '■', panel_path(panel) %> + + <%= link_to h(panel.author.name), author_path(panel.author) %> + <%= panel.width %>x<%= panel.height %> <%= panel.updated_at %> + <% if panel.own? author %> + <%= link_to 'edit', edit_panel_path(panel) %> + <%= link_to 'destroy', panel_path(panel), :method => :dellete %> + <% end %> +
diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index b3f0c106..08e6d608 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -1,4 +1,15 @@ <%= form_tag( {:controller => 'panels',:action => "create"}) do %> + <% if @panel.errors.any? %> +
+

<%= pluralize(@panel.errors.count, "error") %> prohibited this panel from being saved:

+ +
    + <% @panel.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> <%= text_field_tag "json" %> <%= submit_tag 'upload' -%> <% end -%> diff --git a/app/views/panels/_header.html.erb b/app/views/panels/_header.html.erb deleted file mode 100644 index 3aed425b..00000000 --- a/app/views/panels/_header.html.erb +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -
- ID:<%= link_to panel.id, panel_path(panel) %> - - <%= link_to h(panel.author.name), author_path(panel.author) %> -
diff --git a/app/views/panels/_standard.html.erb b/app/views/panels/_standard.html.erb index 778ac0f3..02c0dfdf 100644 --- a/app/views/panels/_standard.html.erb +++ b/app/views/panels/_standard.html.erb @@ -1,5 +1,4 @@ -<%= render 'panels/header', :panel => panel %> -<%= render 'panels/body', :panel => panel %> -<%= render 'panels/footer', :panel => panel %> +<%= render 'panels/body', :panel => panel, :author => author %> +<%= render 'panels/footer', :panel => panel, :author => author %> <%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %> diff --git a/app/views/panels/edit.html.erb b/app/views/panels/edit.html.erb index 2d343636..208c00d7 100644 --- a/app/views/panels/edit.html.erb +++ b/app/views/panels/edit.html.erb @@ -1 +1,3 @@ +

コマの編集

+<%= render 'standard', :panel => @panel, :author => @author %> <%= render 'form' %> diff --git a/app/views/panels/index.html.erb b/app/views/panels/index.html.erb index 8fd31278..a46a178c 100644 --- a/app/views/panels/index.html.erb +++ b/app/views/panels/index.html.erb @@ -1,8 +1,8 @@

Listing panels 最近の投稿

<% @panels.each do |panel| %> - <%= render 'standard', :panel => panel %> + <%= render 'standard', :panel => panel, :author => @author %> <% end %> <%= link_to 'open form', new_panel_path, :remote => true %>
- uploader + ...
diff --git a/app/views/panels/new.html.erb b/app/views/panels/new.html.erb index 2d343636..2e796ef4 100644 --- a/app/views/panels/new.html.erb +++ b/app/views/panels/new.html.erb @@ -1 +1,2 @@ +

コマの新規作成

<%= render 'form' %> diff --git a/app/views/panels/show.html.erb b/app/views/panels/show.html.erb index 02df25fc..90a1de8a 100644 --- a/app/views/panels/show.html.erb +++ b/app/views/panels/show.html.erb @@ -1,15 +1,5 @@ - <% if @panel.errors.any? %> -
-

<%= pluralize(@panel.errors.count, "error") %> prohibited this panel from being saved:

- -
    - <% @panel.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> +

コマの表示

<%= notice %>

-<%= render 'standard', :panel => @panel %> +<%= render 'standard', :panel => @panel, :author => @author %> <%= link_to 'Back', panels_path %> diff --git a/app/views/stories/_footer.html.erb b/app/views/stories/_footer.html.erb deleted file mode 100644 index d850cd89..00000000 --- a/app/views/stories/_footer.html.erb +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -
- <%= story.panel.width %>x<%= story.panel.height %> - - <%= story.panel.updated_at %> -
diff --git a/app/views/stories/_header.html.erb b/app/views/stories/_header.html.erb index 103f9608..50b563b1 100644 --- a/app/views/stories/_header.html.erb +++ b/app/views/stories/_header.html.erb @@ -1,13 +1,21 @@ +
- No.<%= link_to story.t, story_path(story) %> + No.<%= link_to story.t, story_path(story) %>: <%= link_to h(story.panel.author.name), author_path(story.panel.author) %> - ID:<%= link_to story.panel.id, panel_path(story.panel) %> + <%= story.updated_at %> + + <% if story.own? @author -%> + <%= link_to 'edit', edit_story_path(story), :remote => true %> + + ... + + <% end -%>
diff --git a/app/views/stories/comic.html.erb b/app/views/stories/comic.html.erb index 2801f31f..305621d4 100644 --- a/app/views/stories/comic.html.erb +++ b/app/views/stories/comic.html.erb @@ -1,19 +1,12 @@ -

<%= h @comic.title %>

+

<%= h @comic.title %> <%= link_to 'p', comic_path(@comic) %> <%= link_to 'edit', edit_comic_path(@comic) %>

<% @stories.each do |story| %> <% @story = story %> - <%= render 'header', :story => story %> - <%= render 'panels/body', :panel => story.panel %> - <%= render 'footer', :story => story %> - <% if story.own? @author -%> - <%= link_to 'move', edit_story_path(story), :remote => true %> - - t - - <% end -%> + <%= render 'header', :story => story, :author => @author %> + <%= render 'panels/body', :panel => story.panel, :author => @author %> + <%= render 'panels/footer', :panel => story.panel, :author => @author %> <% end %> <%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %> -

<%= h @comic.title %>

<% if @comic.own? @author -%> <%= link_to 'add panel', new_story_path, :remote => true %>
diff --git a/config/magic_number.yml b/config/magic_number.yml index 7412f3f3..e8e218dc 100644 --- a/config/magic_number.yml +++ b/config/magic_number.yml @@ -2,3 +2,5 @@ thumbnail_width: 64 thumbnail_height: 64 + + comic_visible_items: [['private', 0], ['public', 1]] diff --git a/db/migrate/20121106083518_add_caption_on_panel_pictures.rb b/db/migrate/20121106083518_add_caption_on_panel_pictures.rb new file mode 100644 index 00000000..178c4933 --- /dev/null +++ b/db/migrate/20121106083518_add_caption_on_panel_pictures.rb @@ -0,0 +1,9 @@ +class AddCaptionOnPanelPictures < ActiveRecord::Migration + def up + add_column :panel_pictures, :caption, :string + end + + def down + remove_column :panel_pictures, :caption + end +end diff --git a/spec/cli/u/panels/create.json b/spec/cli/u/panels/create.json index a9d642cd..3cd21885 100644 --- a/spec/cli/u/panels/create.json +++ b/spec/cli/u/panels/create.json @@ -11,29 +11,45 @@ "new1": { "picture_id": 3, "x": 10, - "y": 135, + "y": 85, "z": 3, "t": 0, "width": 100, - "height": 103 + "height": 103, + "caption": "penjiro doing" } }, - "ground_pictures_attributes": { + "speech_balloons_attributes": { "new1": { - "picture_id": 1, - "z": 1 + "speech_balloon_template_id": 1, + "classname": "Square", + "z": 1, + "t": 1, + "balloons_attributes": { + "new1": { + "system_picture_id": 4, + "x": 110, + "y": 15, + "width": 100, + "height": 43, + "caption": "penjiro said" + } + }, + "speeches_attributes": { + "new1": { + "x": 10, + "y": 135, + "width": 100, + "height": 103, + "content": "Washoy" + } + } } }, "ground_colors_attributes": { "new1": { - "color_id": 1, - "z": 1 - } - }, - "panel_colors_attributes": { - "new1": { - "code": 1, - "z": 1 + "color_id": 2, + "z": 4 } } }, diff --git a/spec/cli/u/panels/create_gp.json b/spec/cli/u/panels/create_gp.json new file mode 100644 index 00000000..4c197bef --- /dev/null +++ b/spec/cli/u/panels/create_gp.json @@ -0,0 +1,29 @@ +{ + "panel": { + "width": 400, + "height": 200, + "border": 1, + "x": 0, + "y": 0, + "z": 1, + "publish": 1, + "panel_pictures_attributes": { + "new1": { + "picture_id": 3, + "x": 10, + "y": 135, + "z": 3, + "t": 0, + "width": 100, + "height": 103 + } + }, + "ground_pictures_attributes": { + "new1": { + "picture_id": 5, + "z": 1 + } + } + }, + "auth_token": "3fhobSVvDxjUSUPSKy5y" +} \ No newline at end of file diff --git a/spec/cli/u/panels/create_pc.json b/spec/cli/u/panels/create_pc.json new file mode 100644 index 00000000..f0d68f50 --- /dev/null +++ b/spec/cli/u/panels/create_pc.json @@ -0,0 +1,29 @@ +{ + "panel": { + "width": 400, + "height": 200, + "border": 1, + "x": 0, + "y": 0, + "z": 1, + "publish": 1, + "panel_pictures_attributes": { + "new1": { + "picture_id": 3, + "x": 10, + "y": 135, + "z": 3, + "t": 0, + "width": 100, + "height": 103 + } + }, + "panel_colors_attributes": { + "new1": { + "code": 10526848, + "z": 1 + } + } + }, + "auth_token": "3fhobSVvDxjUSUPSKy5y" +} \ No newline at end of file