class GroundColorsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
if MagicNumber['run_mode'] == 0
- before_filter :authenticate_user, :only => []
- before_filter :authenticate_author, :only => []
+ before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
else
before_filter :authenticate_reader, :only => [:index, :show]
- before_filter :authenticate_user, :only => []
- before_filter :authenticate_author, :only => []
+ before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
end
- # GET /ground_colors
- # GET /ground_colors.json
def index
@page = GroundColor.page params[:page]
@page_size = GroundColor.page_size params[:page_size]
format.json { render json: @ground_color.to_json(GroundColor.show_json_opt) }
end
end
+
+ def new
+ @ground_color = GroundColor.new params[:ground_color]
+ @ground_color.supply_default
+ @panel = @author.working_panel
+
+ respond_to do |format|
+ format.html
+ format.json { render :json => @ground_color.to_json(GroundColor.show_json_opt) }
+ end
+ end
+
+ def edit
+ @ground_color = GroundColor.show(params[:id], @author)
+ @panel = Panel.edit(@ground_color.panel.id, @author)
+
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ def create
+ @ground_color = GroundColor.new params[:ground_color]
+ @ground_color.supply_default
+ @panel = Panel.edit(@author.working_panel, @author)
+ @ground_color.overwrite @panel.id
+
+ respond_to do |format|
+ if @ground_color.valid?
+ if @ground_color.store @author
+ flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
+ format.html { redirect_to @panel }
+ format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
+ else
+ format.html { render action: "panels/new" }
+ format.json { render json: @panel.errors, status: :unprocessable_entity }
+ end
+ else
+ format.html { render action: "new" }
+ format.json { render json: @ground_color.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ def update
+ @ground_color = GroundColor.show(params[:id], @author)
+ @ground_color.attributes = params[:ground_color]
+ @panel = Panel.edit(@ground_color.panel.id, @author)
+ @ground_color.overwrite @panel.id
+
+ respond_to do |format|
+ if @ground_color.store @author
+ flash[:notice] = I18n.t('flash.notice.updated', :model => GroundColor.model_name.human)
+ format.html { redirect_to @ground_color }
+ format.json { head :ok }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @ground_color.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ def destroy
+ @ground_color = GroundColor.show(params[:id], @author)
+ @panel = Panel.edit(@ground_color.panel.id, @author)
+
+ respond_to do |format|
+ if @ground_color.remove @author
+ flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundColor.model_name.human)
+ format.html { redirect_to @panel }
+ format.json { head :ok }
+ else
+ flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundColor.model_name.human)
+ format.html { redirect_to @ground_color }
+ format.json { render json: @ground_color.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
end
def supply_default
end
- def overwrite
+ def overwrite pid
+ self.panel_id = pid
end
def visible? roles
{:include => {:panel => {:include => {:author => {}}} }}
end
+ def store au
+ if self.new_record?
+ self.panel.ground_colors.build(self.attributes)
+ else
+ self.panel.ground_colors.each do |ground_color|
+ next unless ground_color == self
+ attr = self.attributes
+ attr.delete 'id'
+ ground_color.attributes = attr
+ break
+ end
+ end
+ self.panel.store({}, au)
+ end
+
+ def remove au
+ PanelPicture.transaction do
+ d = false
+ panel_pictures_attributes = {}
+
+ self.panel.panel_pictures.each do |panel_picture|
+ attr = panel_picture.attributes
+ if panel_picture == self
+ attr['_destroy'] = true
+ d = true
+ else
+ if d
+ attr['t'] -= 1
+ end
+ end
+ panel_pictures_attributes[panel_picture.id] = attr
+ end
+ self.panel.attributes = {:panel_pictures_attributes => panel_pictures_attributes}
+ self.panel.store({}, au)
+ end
+ end
+
def scenario
''
end
end
panel_pictures_attributes[panel_picture.id] = attr
end
-p panel_pictures_attributes
self.panel.attributes = {:panel_pictures_attributes => panel_pictures_attributes}
self.panel.store({}, au)
-p self.panel.errors
end
end
<table>
<tr>
- <th><%= t_m 'GroundColor.panel_id' -%></th>
+ <th><%= t_m 'GroundColor.id' -%></th>
+ <th><%= t_m 'GroundColor.caption' -%></th>
<th><%= t_m 'GroundColor.code' -%></th>
+ <th><%= t_m 'GroundColor.panel_id' -%></th>
<th><%= t_m 'GroundColor.z' -%></th>
<th><%= t_m 'GroundColor.updated_at' -%></th>
</tr>
<th><%= -%></th>
<th><%= t_m 'PanelPicture.panel_id' -%></th>
<th><%= t_m 'PanelPicture.link' -%></th>
+ <th><%= t_m 'PanelPicture.z' -%></th>
<th><%= t_m 'PanelPicture.updated_at' -%></th>
</tr>
--- /dev/null
+<div class="pettanr-comic-panel" style="width:<%= panel.width %>px;height:<%= panel.height %>px;border-style: solid;border-width: <%= panel.border %>px;border-color:black; background-color:white;">
+ <% panel.panel_elements.each do |elm| %>
+ <% case elm.class.to_s %>
+ <% when 'PanelPicture' %>
+ <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(elm == spot ? nil : 33)), elm.link) %>
+ <% when 'SpeechBalloon' %>
+ <% balloon = elm.balloons.first %>
+ <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= elm.z -%>; ">
+ <img src="<%= balloon.system_picture.url -%>" alt="<%= balloon.caption -%>">
+ <% elm.speeches.each do |speech| %>
+ <p style="top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px;">
+ <span><%= h speech.content -%></span>
+ </p>
+ <% end %>
+ </div>
+ <% when 'GroundColor' %>
+ <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
+
+ </div>
+ <% when 'GroundPicture' %>
+ <div id="ground-picture<%= elm.id -%>" class="pettanr-comic-ground-picture" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-image: url(<%= full_url elm.picture.url -%>); background-repeat: <%= MagicNumber['ground_picture_repeat_items'][elm.repeat] -%>; background-position: <%= elm.x -%>px, <%= elm.y -%>px;">
+
+ </div>
+ <% end %>
+ <% end %>
+</div>
--- /dev/null
+<%= form_for(@ground_color) do |f| %>
+ <%= render 'system/error_explanation', :obj => @ground_color %>
+
+ <div class="field">
+ <%= f.label :code %><br />
+ <%= f.text_field :code %>
+ </div>
+ <div class="field">
+ <%= f.label :z %><br />
+ <%= f.number_field :z %>
+ </div>
+ <%= f.hidden_field :panel_id %>
+
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
<tr>
<td>
- <%= link_to ground_color.panel_id, panel_path(ground_color.panel) %>
+ <%= link_to ground_color.id, ground_color_path(ground_color) %>
+ </td>
+ <td>
+ <%= link_to(h(truncate(ground_color.caption, :length => 12)), ground_color_path(ground_color)) %>
+ </td>
+ <td style="color: #<%= format("%06x", ground_color.code ^ 0xffffff) -%>; background-color: #<%= format("%06x", ground_color.code) -%>;">
+ <%= format("%06x", ground_color.code ^ 0xffffff) %>
+ </td>
+ </td>
+ <td>
+ <%= link_to panel_icon(:object => ground_color.panel, :size => 25), panel_path(ground_color.panel) %>
+ <%= link_to h(truncate((ground_color.panel.caption), :length => 12)), panel_path(ground_color.panel) %>
</td>
- <td style="color: #<%= format("%06x", ground_color.code ^ 0xffffff) -%>; background-color: #<%= format("%06x", ground_color.code) -%>;"><%= format("%06x", ground_color.code ^ 0xffffff) %></td>
<td>
<%= ground_color.z %>
</td>
--- /dev/null
+<b><%= t_m 'Panel.caption' -%>:</b>
+<%= h(panel.caption) %>
+<%= render 'panel_pictures/body', :panel => panel, :author => author, :spot => spot %>
+<%= render 'panels/footer', :panel => panel, :author => author %>
+<%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %>
+
--- /dev/null
+<h1><%= t('.title') %></h1>
+
+<h2><%= t('home.index.catch') -%></h2>
+<%= render 'panels/standard', :panel => @panel, :author => @author %>
+<h2><%= t('ground_colors.update_color') -%></h2>
+<%= render 'form' %>
<table>
<tr>
- <th><%= t_m 'GroundColor.panel_id' -%></th>
+ <th><%= t_m 'GroundColor.id' -%></th>
+ <th><%= t_m 'GroundColor.caption' -%></th>
<th><%= t_m 'GroundColor.code' -%></th>
+ <th><%= t_m 'GroundColor.panel_id' -%></th>
<th><%= t_m 'GroundColor.z' -%></th>
- <th><%= t_m 'GroundColor.created_at' -%></th>
<th><%= t_m 'GroundColor.updated_at' -%></th>
</tr>
<%= render 'list_item', :ground_color => gc %>
<% end -%>
</table>
+<%= link_to t('ground_colors.new.title'), new_ground_color_path %>
--- /dev/null
+<h1><%= t('.title') %></h1>
+
+<h2><%= t('home.index.catch') -%></h2>
+<%= render 'panels/standard', :panel => @panel, :author => @author %>
+<h2><%= t('ground_colors.create_color') -%></h2>
+<%= render 'form' %>
<h1><%= t('.title') %></h1>
<p id="notice"><%= notice %></p>
+<%= render 'panel_pictures/standard', :panel => @ground_color.panel, :author => @author, :spot => @ground_color %>
+
+<p>
+ <b><%= t_m 'GroundColor.caption' -%>:</b>
+ <%= h @ground_color.caption %>
+</p>
+
+<p>
+ <b><%= t_m 'GroundColor.z' -%>:</b>
+ <%= @ground_color.z %>
+</p>
+
+<p>
+ <b><%= t_m 'GroundColor.t' -%>:</b>
+ <%= @ground_color.t %>
+</p>
+
+<p>
+ <b><%= t_m 'GroundColor.code' -%>:</b>
+ <%= @ground_color.code %>
+</p>
+
+<p>
+ <b><%= t_m 'GroundColor.created_at' -%>:</b>
+ <%= l @ground_color.created_at %>
+</p>
+
+<p>
+ <b><%= t_m 'GroundColor.updated_at' -%>:</b>
+ <%= l @ground_color.updated_at %>
+</p>
+
+<%= link_to t('link.edit'), edit_ground_color_path(@ground_color) %>
+<%= link_to t('link.destroy'), ground_color_path(@ground_color), :method => :delete %>
<table>
<tr>
- <th><%= t_m 'GroundColor.color_id' -%></th>
+ <th><%= t_m 'GroundColor.id' -%></th>
+ <th><%= t_m 'GroundColor.caption' -%></th>
<th><%= t_m 'GroundColor.code' -%></th>
+ <th><%= t_m 'GroundColor.panel_id' -%></th>
<th><%= t_m 'GroundColor.z' -%></th>
<th><%= t_m 'GroundColor.updated_at' -%></th>
</tr>
<%= render 'ground_colors/list_item', :ground_color => gc, :author => @author %>
<% end -%>
</table>
+<%= link_to t('ground_colors.new.title'), new_ground_color_path %>
<th><%= -%></th>
<th><%= t_m 'PanelPicture.panel_id' -%></th>
<th><%= t_m 'PanelPicture.link' -%></th>
+ <th><%= t_m 'PanelPicture.z' -%></th>
<th><%= t_m 'PanelPicture.updated_at' -%></th>
</tr>
<% end %>
</div>
<% when 'GroundColor' %>
- <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:<%= elm.color.name -%>;">
-
- </div>
- <% when 'PanelColor' %>
- <div id="panel-color<%= elm.id -%>" class="pettanr-comic-panel-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
+ <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
</div>
<% when 'GroundPicture' %>
<% end %>
<td>
<%= link_to panel_icon(:object => panel_picture.panel, :size => 25), panel_path(panel_picture.panel) %>
- <%= h(truncate((panel_picture.panel.caption), :length => 12)) %></td>
+ <%= link_to h(truncate((panel_picture.panel.caption), :length => 12)), panel_path(panel_picture.panel) %>
+ </td>
+ <td>
+ <%= link_to h(truncate(panel_picture.link, :length => 12)), panel_picture.link %>
+ </td>
<td>
- <%= link_to h(truncate(panel_picture.link, :length => 12)), panel_picture.link %></td>
- <td><%= distance_of_time_in_words_to_now panel_picture.updated_at %></td>
+ <%= panel_picture.z %>
+ </td>
+ <td>
+ <%= distance_of_time_in_words_to_now panel_picture.updated_at %>
+ </td>
</tr>
<th><%= -%></th>
<th><%= t_m 'PanelPicture.panel_id' -%></th>
<th><%= t_m 'PanelPicture.link' -%></th>
+ <th><%= t_m 'PanelPicture.z' -%></th>
<th><%= t_m 'PanelPicture.updated_at' -%></th>
</tr>
<p id="notice"><%= notice %></p>
<%= render 'panel_pictures/standard', :panel => @panel_picture.panel, :author => @author, :spot => @panel_picture %>
-<p>
- <b><%= t_m 'PanelPicture.panel_id' -%>:</b>
- <%= link_to @panel_picture.panel_id, panel_path(@panel_picture.panel) %>
-</p>
<p>
<b><%= t_m 'PanelPicture.caption' -%>:</b>
<% end %>
</div>
<% when 'GroundColor' %>
- <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:<%= elm.color.name -%>;">
-
- </div>
- <% when 'PanelColor' %>
- <div id="panel-color<%= elm.id -%>" class="pettanr-comic-panel-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
+ <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
</div>
<% when 'GroundPicture' %>
x: X
y: Y
z: 重なり
+ t: 話順
+ caption: 様子
created_at: 作成
updated_at: 更新
ground_color:
panel_id: コマ
code: カラーコード
z: 重なり
+ t: 話順
+ caption: 様子
created_at: 作成
updated_at: 更新
original_picture:
author:
name: ペンネーム
user_id: ユーザ
+ working_panel_id: つかんでいるコマ
created_at: 作成
updated_at: 更新
artist:
title: 色地一覧
show:
title: 色地詳細
+ new:
+ title: 色地作成
+ edit:
+ title: 色地編集
+ create:
+ title: 色地作成
+ update:
+ title: 色地編集
+ destroy:
+ title: 色地削除
list:
title: 色地 生一覧
browse:
title: 色地 生単票
+ create_color: 追加する色地
+ update_color: 変更する色地
original_pictures:
index:
title: 原画一覧
end
end
resources :ground_colors do
+ new do
+ get :new
+ end
collection do
get :index
get :show
end
member do
+ get :edit
+ put :update
+ delete :destroy
get :browse
end
end
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
- #match ':controller(/:action(/:id(.:format)))'
+ match ':controller(/:action(/:id(.:format)))'
end
--- /dev/null
+class AddCaptionAndTOnGroundColors < ActiveRecord::Migration
+ def up
+ add_column :ground_colors, :t, :integer, :null => false, :default => 0
+ add_column :ground_colors, :caption, :string
+ end
+
+ def down
+ remove_column :ground_colors, :t
+ remove_column :ground_colors, :caption
+ end
+end
--- /dev/null
+class AddCaptionAndTOnGroundPictures < ActiveRecord::Migration
+ def up
+ add_column :ground_pictures, :t, :integer, :null => false, :default => 0
+ add_column :ground_pictures, :caption, :string
+ end
+
+ def down
+ remove_column :ground_pictures, :t
+ remove_column :ground_pictures, :caption
+ end
+end