end
def play
- @comic = Comic.find(params[:id], include: {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}, order: 'panels.seqno')
+ @comic = Comic.find(params[:id], include: {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}, order: 'panels.t')
respond_to do |format|
format.html # index.html.erb
if @panel.own? current_author
respond_to do |format|
Panel.transaction do
- if params[:panel][:seqno] and params[:panel][:seqno].to_i != @panel.seqno
- @panel.move_to params[:panel][:seqno].to_i
+ if params[:panel][:t] and params[:panel][:t].to_i != @panel.t
+ @panel.move_to params[:panel][:t].to_i
end
if @panel.update_attributes(params[:panel])
format.html { redirect_to @panel, notice: 'Panel was successfully updated.' }
def move
@panel = Panel.find(params[:id])
- @new_seq = params[:panel][:seqno].to_i
+ @new_seq = params[:panel][:t].to_i
respond_to do |format|
Panel.transaction do
- if @panel.move_to(@new_seq)
+ if @panel.move_to(@new_t)
format.html { redirect_to @panel, notice: 'Panel was successfully moved.' }
format.json { head :ok }
else
class Admin < ActiveRecord::Base
# Include default devise modules. Others available are:
- # , :encryptable, :lockable, :timeoutable and :omniauthable
+ # , :encryptable, :lockable, :timeoutable and :omniauthable, :confirmable
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :confirmable
+ :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
before_save :ensure_authentication_token\r
+ def active_for_authentication?\r
+ super && (self.approve == 1)\r
+ end
+
def self.start(email, passwd)
a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
- a.confirm!
+ a.approve = 1
+ a.save!
end
end
def save_save
lisence = Lisence.new( {
:name => self.name, :url => self.url, :cc_by => self.cc_by, :cc_sa => self.cc_sa, :cc_nd => self.cc_nd, :cc_nc => self.cc_nc,
- :no_resize => self.no_resize, :no_flip => self.no_flip, :keep_aspect_ratio => self.keep_aspect_ratio
+ :no_resize => self.no_resize, :no_flip => self.no_flip, :no_convert => self.no_convert, :keep_aspect_ratio => self.keep_aspect_ratio
})
self.lisence_id = 0
res = self.save
def save_save
lisence = Lisence.new( {
:name => self.name, :url => self.url, :cc_by => self.cc_by, :cc_sa => self.cc_sa, :cc_nd => self.cc_nd, :cc_nc => self.cc_nc,
- :no_resize => self.no_resize, :no_flip => self.no_flip, :keep_aspect_ratio => self.keep_aspect_ratio
+ :no_resize => self.no_resize, :no_flip => self.no_flip, :no_convert => self.no_convert, :keep_aspect_ratio => self.keep_aspect_ratio
})
return false unless lisence.save
self.lisence_id = lisence.id
accepts_nested_attributes_for :panel_pictures, :allow_destroy => true
accepts_nested_attributes_for :balloons, :allow_destroy => true
- def self.max_seq comic_id
- Panel.maximum(:seqno, :conditions => ['comic_id = ?', comic_id]).to_i
+ def self.max_t comic_id
+ Panel.maximum(:t, :conditions => ['comic_id = ?', comic_id]).to_i
end
- def self.find_seq comic_id, seqno
- Panel.find(:first, :conditions => ['comic_id = ? and seqno = ?', comic_id, seqno])
+ def self.find_t comic_id, t
+ Panel.find(:first, :conditions => ['comic_id = ? and t = ?', comic_id, t])
end
#更新する時にPanelIDをチェックしとかないと勝手に所属先を変えられるゾ!?
def vdt_save
f = nil
- max_seq = Panel.max_seq self.comic_id
- f = Panel.find_seq(self.comic_id, self.seqno) if self.seqno
+ max_t = Panel.max_t self.comic_id
+ f = Panel.find_t(self.comic_id, self.t) if self.t
if f
- Panel.update_all('seqno = seqno + 1', ['comic_id = ? and seqno >= ?', self.comic_id, self.seqno])
+ Panel.update_all('t = t + 1', ['comic_id = ? and t >= ?', self.comic_id, self.t])
else
- self.seqno = max_seq + 1
+ self.t = max_t + 1
end
self.save
end
- def move_to new_seq
- return true if self.seqno == new_seq
- if self.seqno > new_seq
- Panel.update_all('seqno = seqno + 1', ['comic_id = ? and (seqno >= ? and seqno < ?)', self.comic_id, new_seq, self.seqno])
+ def move_to new_t
+ return true if self.t == new_t
+ if self.t > new_t
+ Panel.update_all('t = t + 1', ['comic_id = ? and (t >= ? and t < ?)', self.comic_id, new_t, self.t])
else
- nf = Panel.find_seq(self.comic_id, new_seq)
- max_seq = Panel.max_seq self.comic_id
- new_seq = max_seq if new_seq > max_seq
- Panel.update_all('seqno = seqno - 1', ['comic_id = ? and (seqno > ? and seqno <= ?)', self.comic_id, self.seqno, new_seq])
+ nf = Panel.find_t(self.comic_id, new_t)
+ max_t = Panel.max_t self.comic_id
+ new_t = max_t if new_t > max_t
+ Panel.update_all('t = t - 1', ['comic_id = ? and (t > ? and t <= ?)', self.comic_id, self.t, new_t])
end
- self.seqno = new_seq
+ self.t = new_t
self.save
end
def destroy_and_shorten
- Panel.update_all('seqno = seqno - 1', ['comic_id = ? and (seqno > ?)', self.comic_id, self.seqno])
+ Panel.update_all('t = t - 1', ['comic_id = ? and (t > ?)', self.comic_id, self.t])
self.destroy
end
class SpeachBalloon < ActiveRecord::Base
has_many :balloon_templates, :dependent => :destroy
accepts_nested_attributes_for :balloon_templates
+ before_create :supply_t
+
+ def supply_t
+ self.t = SpeachBalloon.maximum(:t).to_i + 1
+ end
+
end
<tr>
<th>id</th>
<th>Title</th>
- <th>Default width</th>
- <th>Default height</th>
+ <th>width</th>
+ <th>height</th>
<th>author_id</th>
<th>updated_at</th>
+ <th>visible</th>
+ <th>editable</th>
<th></th>
<th></th>
<th></th>
<td><%= h comic.title %></td>
<td><%= comic.width %></td>
<td><%= comic.height %></td>
+ <td><%= comic.visible %></td>
+ <td><%= comic.editable %></td>
<td><%= comic.author_id%></td>
<td><%= comic.updated_at %></td>
<td><%= link_to 'Show', comic %></td>
</p>
<p>
- <b>Default width:</b>
+ <b>width:</b>
<%= @comic.width %>
</p>
<p>
- <b>Default height:</b>
+ <b>height:</b>
<%= @comic.height %>
</p>
+<p>
+ <b>visible:</b>
+ <%= @comic.visible %>
+</p>
+
+<p>
+ <b>editable:</b>
+ <%= @comic.editable %>
+</p>
+
<%= link_to 'Back', comics_path %>
<%= f.check_box :no_flip %>
</div>
<div class="field">
+ <%= f.label :no_convert %><br />
+ <%= f.check_box :no_convert %>
+ </div>
+ <div class="field">
<%= f.label :keep_aspect_ratio %><br />
<%= f.check_box :keep_aspect_ratio %>
</div>
<th>cc_nc</th>
<th>no_resize</th>
<th>no_flip</th>
+ <th>no_convert</th>
<th>keep_aspect_ratio</th>
<th></th>
<th></th>
<% @common_lisences.each do |common_lisence| %>
<tr>
- <td><%= h @common_lisence.name %></td>
- <td><%= h @common_lisence.url %></td>
- <td><%= @common_lisence.cc_by %></td>
- <td><%= @common_lisence.cc_sa %></td>
- <td><%= @common_lisence.cc_nd %></td>
- <td><%= @common_lisence.cc_nc %></td>
- <td><%= @common_lisence.no_resize %></td>
- <td><%= @common_lisence.no_flip %></td>
- <td><%= @common_lisence.keep_aspect_ratio %></td>
+ <td><%= h common_lisence.name %></td>
+ <td><%= h common_lisence.url %></td>
+ <td><%= common_lisence.cc_by %></td>
+ <td><%= common_lisence.cc_sa %></td>
+ <td><%= common_lisence.cc_nd %></td>
+ <td><%= common_lisence.cc_nc %></td>
+ <td><%= common_lisence.no_resize %></td>
+ <td><%= common_lisence.no_flip %></td>
+ <td><%= common_lisence.no_convert %></td>
+ <td><%= common_lisence.keep_aspect_ratio %></td>
<td><%= link_to 'Show', common_lisence %></td>
<td><%= link_to 'Edit', edit_common_lisence_path(common_lisence) %></td>
<td><%= link_to 'Destroy', common_lisence, confirm: 'Are you sure?', method: :delete %></td>
</p>
<p>
+ <b>no_convert:</b>
+ <%= @common_lisence.no_convert %>
+</p>
+
+<p>
<b>keep_aspect_ratio:</b>
<%= @common_lisence.keep_aspect_ratio %>
</p>
<th>cc_nc</th>
<th>no_resize</th>
<th>no_flip</th>
+ <th>no_convert</th>
<th>keep_aspect_ratio</th>
<th></th>
</tr>
<td><%= lisence.cc_nc %></td>
<td><%= lisence.no_resize %></td>
<td><%= lisence.no_flip %></td>
+ <td><%= lisence.no_convert %></td>
<td><%= lisence.keep_aspect_ratio %></td>
<td>
<% if lisence.common_lisence -%>
<%= f.check_box :no_flip %>
</div>
<div class="field">
+ <%= f.label :no_convert %><br />
+ <%= f.check_box :no_convert %>
+ </div>
+ <div class="field">
<%= f.label :keep_aspect_ratio %><br />
<%= f.check_box :keep_aspect_ratio %>
</div>
</p>
<p>
+ <b>no_convert:</b>
+ <%= @original_lisence.no_convert %>
+</p>
+
+<p>
<b>keep_aspect_ratio:</b>
<%= @original_lisence.keep_aspect_ratio %>
</p>
<th>id</th>
<th>panel</th>
<th>resource_picture</th>
+ <th>url</th>
<th>Width</th>
<th>Height</th>
- <th>Top offset</th>
- <th>Left offset</th>
+ <th>x</th>
+ <th>y</th>
<th>z</th>
+ <th>t</th>
<th>flip</th>
<th>updated_at</th>
</tr>
<td><%= panel_picture.id %></td>
<td><%= panel_picture.panel_id %></td>
<td><%= panel_picture.resource_picture_id %></td>
- <td><%= panel_picture.width %></td>
- <td><%= panel_picture.height %></td>
- <td><%= panel_picture.y %></td>
+ <td><%= h panel_picture.url %></td>
<td><%= panel_picture.x %></td>
+ <td><%= panel_picture.y %></td>
<td><%= panel_picture.z %></td>
+ <td><%= panel_picture.t %></td>
+ <td><%= panel_picture.width %></td>
+ <td><%= panel_picture.height %></td>
<td><%= panel_picture.flip %></td>
<td><%= panel_picture.updated_at %></td>
</tr>
<span>
-Seqno:<%= @panel.seqno %>
+t:<%= @panel.t %>
</span>
<div class="panel" style="width:<%= @panel.width %>px;height:<%= @panel.height %>px;overflow:hidden; border:solid black <%= @panel.border %>px; background:white;">
<% @panel.panel_pictures.each do |panel_picture| %>
</span>
<%= form_for(@panel) do |f| %>
<%= f.submit 'move to' %>
- <%= f.number_field :seqno %>
+ <%= f.number_field :t %>
<% end %>
<%= button_to 'Destroy', @panel, confirm: 'Are you sure?', method: :delete %>
<th>Width</th>
<th>Height</th>
<th>Border</th>
- <th>Seqno</th>
+ <th>x</th>
+ <th>y</th>
+ <th>z</th>
+ <th>t</th>
<th>author_id</th>
<th>updated_at</th>
<th></th>
<td><%= panel.width %></td>
<td><%= panel.height %></td>
<td><%= panel.border %></td>
- <td><%= panel.seqno %></td>
+ <td><%= panel.x %></td>
+ <td><%= panel.y %></td>
+ <td><%= panel.z %></td>
+ <td><%= panel.t %></td>
<td><%= panel.author_id %></td>
<td><%= panel.updated_at %></td>
<td><%= link_to 'Show', panel %></td>
<th>Name</th>
<th>Tail limit</th>
<th>size limit</th>
+ <th>t</th>
<th></th>
<th></th>
</tr>
<td><%= h speach_balloon.name %></td>
<td><%= speach_balloon.tail_count %></td>
<td><%= speach_balloon.size_count %></td>
+ <td><%= speach_balloon.t %></td>
<td><%= link_to 'show', speach_balloon %></td>
<td>
<% if admin_signed_in? -%>
<b>size limit:</b>
<%= @speach_balloon.size_count %>
</p>
+
+<p>
+ <b>t:</b>
+ <%= @speach_balloon.t %>
+</p>
<% @speach_balloon.balloon_templates.each do |balloon_template| -%>\r
<div>\r
<p>\r
t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
t.token_authenticatable
+ t.integer :approve, :null => false, :default => 0
t.timestamps
end
create_table :panel_pictures do |t|
t.integer :panel_id, :null => false
t.integer :resource_picture_id, :null => false
- t.string :url, :limit => 200
+ t.string :link, :limit => 200
t.integer :x, :null => false
t.integer :y, :null => false
t.integer :z, :null => false
t.datetime "confirmed_at"\r
t.datetime "confirmation_sent_at"\r
t.string "authentication_token"\r
+ t.integer "approve", :default => 0, :null => false\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
end\r
create_table "panel_pictures", :force => true do |t|\r
t.integer "panel_id", :null => false\r
t.integer "resource_picture_id", :null => false\r
- t.string "url", :limit => 200\r
+ t.string "link", :limit => 200\r
t.integer "x", :null => false\r
t.integer "y", :null => false\r
t.integer "z", :null => false\r
# Mayor.new(name: 'Emanuel', city: cities.first)
cl = CommonLisence.new name: 'Public Domain',
url: 'http://ja.wikipedia.org/wiki/%E3%83%91%E3%83%96%E3%83%AA%E3%83%83%E3%82%AF%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3',
- cc_by: 0, cc_sa: 0, cc_nd: 0, cc_nc: 0, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 0, cc_sa: 0, cc_nd: 0, cc_nc: 0, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl = CommonLisence.new name: 'Creative Commons 3.0(by)',
url: 'http://creativecommons.org/licenses/by/3.0/legalcode',
- cc_by: 1, cc_sa: 0, cc_nd: 0, cc_nc: 0, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 1, cc_sa: 0, cc_nd: 0, cc_nc: 0, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl.save_save
cl = CommonLisence.new name: 'Creative Commons 3.0(by_sa)',
url: 'http://creativecommons.org/licenses/by-sa/3.0/legalcode',
- cc_by: 1, cc_sa: 1, cc_nd: 0, cc_nc: 0, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 1, cc_sa: 1, cc_nd: 0, cc_nc: 0, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl.save_save
cl = CommonLisence.new name: 'Creative Commons 3.0(by_nd)',
url: 'http://creativecommons.org/licenses/by-nd/3.0/legalcode',
- cc_by: 1, cc_sa: 0, cc_nd: 1, cc_nc: 0, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 1, cc_sa: 0, cc_nd: 1, cc_nc: 0, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl.save_save
cl = CommonLisence.new name: 'Creative Commons 3.0(by_nc)',
url: 'http://creativecommons.org/licenses/by-nc/3.0/legalcode',
- cc_by: 1, cc_sa: 0, cc_nd: 0, cc_nc: 1, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 1, cc_sa: 0, cc_nd: 0, cc_nc: 1, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl.save_save
cl = CommonLisence.new name: 'Creative Commons 3.0(by_nc_sa)',
url: 'http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode',
- cc_by: 1, cc_sa: 1, cc_nd: 0, cc_nc: 1, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 1, cc_sa: 1, cc_nd: 0, cc_nc: 1, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl.save_save
cl = CommonLisence.new name: 'Creative Commons 3.0(by_nc_nd)',
url: 'http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode',
- cc_by: 1, cc_sa: 0, cc_nd: 1, cc_nc: 1, no_resize: 0, no_flip: 0, keep_aspect_ratio: 0
+ cc_by: 1, cc_sa: 0, cc_nd: 1, cc_nc: 1, no_resize: 0, no_flip: 0, no_convert: 0, keep_aspect_ratio: 0
cl.save_save