end
+ def index
+ end
+
def waiting_list
@newadmins = Admin.find(:all, :conditions => ['activate = 0'])
end
img = nil
if (f = prm[:system_picture][:file]).respond_to?(:read)
if f.size > 1000000
- @original_picture.width = 0
- @original_picture.height = 0
- @original_picture.ext = 'none'
- @original_picture.filesize = 1.megabytes
+ @system_picture.width = 0
+ @system_picture.height = 0
+ @system_picture.ext = 'none'
+ @system_picture.filesize = 1.megabytes
else
img = Magick::Image.from_blob(f.read).shift
- @original_picture.width = img.columns
- @original_picture.height = img.rows
- @original_picture.ext = img.format.downcase
- @original_picture.filesize = f.size
+ @system_picture.width = img.columns
+ @system_picture.height = img.rows
+ @system_picture.ext = img.format.downcase
+ @system_picture.filesize = f.size
end
else
- dat = Base64.decode64(prm[:original_picture][:file].to_s.gsub(' ', '+')) #rubyのバグ?+でデコードされるべきキャラがスペースになる
+ dat = Base64.decode64(prm[:system_picture][:file].to_s.gsub(' ', '+')) #rubyのバグ?+でデコードされるべきキャラがスペースになる
img = Magick::Image.from_blob(dat).shift
- @original_picture.width = img.columns
- @original_picture.height = img.rows
- @original_picture.ext = img.format.downcase
- @original_picture.filesize = 1000
+ @system_picture.width = img.columns
+ @system_picture.height = img.rows
+ @system_picture.ext = img.format.downcase
+ @system_picture.filesize = 1000
end
img
end
+ public
+
# GET /system_pictures
# GET /system_pictures.json
def index
@system_picture = SystemPicture.find(params[:id])
respond_to do |format|
+ opt = {:type => @system_picture.mime_type, :disposition=>"inline"}
+ format.png { send_data(@system_picture.restore, opt ) }
+ format.gif { send_data(@system_picture.restore, opt ) }
+ format.jpeg { send_data(@system_picture.restore, opt ) }
format.html # show.html.erb
- format.json { render json: @system_picture }
+ format.json { render json: @system_picture}
end
end
# POST /system_pictures
# POST /system_pictures.json
def create
- @original_picture = OriginalPicture.new
+ @system_picture = SystemPicture.new
img = set_image params
respond_to do |format|
SystemPicture.transaction do
- if @original_picture.save
- if @original_picture.store(img)
- format.html { redirect_to @original_picture, notice: 'Original picture was successfully created.' }
- format.json { render json: @original_picture, status: :created, location: @original_picture }
+ if @system_picture.save
+ if @system_picture.store(img)
+ format.html { redirect_to @system_picture, notice: 'system picture was successfully created.' }
+ format.json { render json: @system_picture, status: :created, location: @system_picture }
else
- format.html { redirect_to @original_picture, notice: 'Failed! Original picture was NOT created.' }
- format.json { render json: @original_picture.errors, status: :unprocessable_entity }
+ format.html { redirect_to @system_picture, notice: 'Failed! system picture was NOT created.' }
+ format.json { render json: @system_picture.errors, status: :unprocessable_entity }
end
else
format.html { render action: "new" }
- format.json { render json: @original_picture.errors, status: :unprocessable_entity }
+ format.json { render json: @system_picture.errors, status: :unprocessable_entity }
end
end
end
- @system_picture = SystemPicture.new(params[:system_picture])
-
- respond_to do |format|
- if @system_picture.save
- format.html { redirect_to @system_picture, notice: 'System picture was successfully created.' }
- format.json { render json: @system_picture, status: :created, location: @system_picture }
- else
- format.html { render action: "new" }
- format.json { render json: @system_picture.errors, status: :unprocessable_entity }
- end
- end
end
# PUT /system_pictures/1
# PUT /system_pictures/1.json
def update
@system_picture = SystemPicture.find(params[:id])
+ img = set_image params
respond_to do |format|
- if @system_picture.update_attributes(params[:system_picture])
- format.html { redirect_to @system_picture, notice: 'System picture was successfully updated.' }
- format.json { head :ok }
- else
- format.html { render action: "edit" }
- format.json { render json: @system_picture.errors, status: :unprocessable_entity }
+ SystemPicture.transaction do
+ if @system_picture.save
+ if @system_picture.store(img)
+ format.html { redirect_to @system_picture, notice: 'System picture was successfully updated.' }
+ format.json { head :ok }
+ else
+ format.html { redirect_to @system_picture, notice: 'Failed! System picture was NOT created.' }
+ format.json { render json: @system_picture.errors, status: :unprocessable_entity }
+ end
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @system_picture.errors, status: :unprocessable_entity }
+ end
end
end
end
class Balloon < ActiveRecord::Base
has_many :speaches
belongs_to :panel
- belongs_to :resource_picture
+ belongs_to :system_picture
accepts_nested_attributes_for :speaches
- def picture_url
- '/resource_pictures/' + self.resource_picture.filename
+ def url
+ '/system_pictures/' + self.system_picture.filename
end
end
class BalloonTemplate < ActiveRecord::Base
belongs_to :speach_balloon
has_many :speach_templates, :dependent => :destroy
- belongs_to :resource_picture
+ belongs_to :system_picture
accepts_nested_attributes_for :speach_templates
end
class SystemPicture < ActiveRecord::Base
+ has_many :balloons
+ has_many :balloon_templates
+
def validate
errors.add(:filesize, 'size over(1MB)') if self.filesize > 1000000
end
<table>
<tr>
<th>speach balloon</th>
- <th>resource_picture</th>
+ <th>system_picture</th>
<th>Tail</th>
<th>Border</th>
<th>MinWidth</th>
<% @balloon_templates.each do |balloon_template| %>
<tr>
<td><%= balloon_template.speach_balloon_id %></td>
- <td><%= balloon_template.resource_picture_id %></td>
+ <td><%= balloon_template.system_picture_id %></td>
<td><%= balloon_template.tail %></td>
<td><%= balloon_template.border %></td>
<td><%= balloon_template.min_width %></td>
<tr>
<th>panel</th>
<th>balloonTemplate</th>
- <th>resource_picture</th>
+ <th>system_picture</th>
<th>Tail</th>
<th>Border</th>
<th>Zindex</th>
<tr>
<td><%= balloon.panel_id %></td>
<td><%= balloon.balloon_template_id %></td>
- <td><%= balloon.resource_picture_id %></td>
+ <td><%= balloon.system_picture_id %></td>
<td><%= balloon.tail %></td>
<td><%= balloon.border %></td>
<td><%= balloon.zindex %></td>
</head>
<body>
+<div>
<% if author_signed_in? %>
-<%= link_to "my home", :controller => '/home' %>
-<%= link_to "ログアウト", destroy_author_session_path, :method => :delete %>
+ <%= link_to "my home", :controller => '/home' %>
+ <%= link_to "ログアウト", destroy_author_session_path, :method => :delete %>
<% else %>
-<%= link_to "ログイン", new_author_session_path %>
+ <%= link_to "ログイン", new_author_session_path %>
<% end %>
-<%= link_to "管理者", new_admin_session_path %>
+</div>
+<div>
+<% if author_signed_in? %>
+ <%= link_to "system", :controller => '/system' %>
+<% else %>
+ <%= link_to "管理者", new_admin_session_path %>
+<% end %>
+</div>
<div>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= link_to 'artists', artists_path %>
<%= link_to 'lesences', lisences_path %>
(<%= link_to 'common', common_lisences_path %> <%= link_to 'original', original_lisences_path %>)
+<%= link_to 'system_pictures', system_pictures_path %>
</div>
<%= yield %>
<% end %>
<% @panel.balloons.each do |balloon| %>
<div id="vballoon<%= balloon.id -%>" class="balloon" style="position:relative; top:<%= balloon.top_offset -%>px; left:<%= balloon.left_offset -%>px; z-index:<%= balloon.zindex -%>; ">
- <img style=" position:absolute; width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; " src="<%= balloon.resource_picture.url -%>">
+ <img style=" position:absolute; width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; " src="<%= balloon.system_picture.url -%>">
<% balloon.speaches.each do |speach| %>
<div style="position:relative; top:<%= speach.top_offset -%>px; left:<%= speach.left_offset -%>px;width:<%= speach.width -%>px; height:<%= speach.height -%>px; top:1px; left:1px; z-index:1; ">
<%= h speach.content -%>
--- /dev/null
+ <%# current_admin.authentication_token %>
-<h1>Listing original_pictures</h1>
+<h1>Listing system_pictures</h1>
+
+<% if admin_signed_in? -%>
+ <%= form_tag( {:action => "create"} , { :multipart => true }) do %>
+ <label for="file">File to Upload</label> <%= file_field_tag "system_picture[file]" %>
+ <%= submit_tag 'upload' -%>
+ <% end -%>
+<% end -%>
-<%= render 'uploader' %>
<table>
<tr>
<th>Ext</th>
<th>Width</th>
<th>Height</th>
<th>filesize</th>
- <th>artist</th>
<th></th>
</tr>
-<% @original_pictures.each do |original_picture| %>
+<% @system_pictures.each do |system_picture| %>
<tr>
- <td><%= original_picture.ext %></td>
- <td><%= original_picture.width %></td>
- <td><%= original_picture.height %></td>
- <td><%= original_picture.filesize %></td>
- <td><%= original_picture.artist_id %></td>
- <td><%= link_to 'Show', original_picture %></td>
+ <td><%= system_picture.ext %></td>
+ <td><%= system_picture.width %></td>
+ <td><%= system_picture.height %></td>
+ <td><%= system_picture.filesize %></td>
+ <td><%= link_to 'Show', system_picture %></td>
<td>
- <% if author_signed_in? -%>
- <% if original_picture.own? current_author -%>
- <%= link_to 'Destroy', original_picture, confirm: 'Are you sure?', method: :delete %>
- <% end -%>
+ <% if admin_signed_in? -%>
+ <%= link_to 'Destroy', system_picture, confirm: 'Are you sure?', method: :delete %>
<% end -%>
</td>
</tr>
<p>
<b>Ext:</b>
- <%= @original_picture.ext %>
+ <%= @system_picture.ext %>
</p>
<p>
<b>Width:</b>
- <%= @original_picture.width %>
+ <%= @system_picture.width %>
</p>
<p>
<b>Height:</b>
- <%= @original_picture.height %>
+ <%= @system_picture.height %>
</p>
<p>
<b>filesize:</b>
- <%= @original_picture.filesize %>
+ <%= @system_picture.filesize %>
</p>
-<p>
- <b>artist:</b>
- <%= @original_picture.artist_id %>
-</p>
-
-<img src="<%= @original_picture.url -%>">
+<img src="<%= @system_picture.url -%>">
<p>
-<a href="<%= @original_picture.url %>">browse picture</a>
-</p>
-<p>
-<%= link_to '再生成', :action => :refresh, :id => @original_picture.id %>
+<a href="<%= @system_picture.url %>">browse picture</a>
</p>
-<% if @original_picture.own? current_author -%>
+<% if admin_signed_in? -%>
<p>
Replace picture
</p>
- <%= form_for(@original_picture, :html => { :multipart => true }) do |f| %>
+ <%= form_for(@system_picture, :html => { :multipart => true }) do |f| %>
<label for="file">File to Upload</label> <%= f.file_field "file" %>
<div class="actions">
<%= f.submit 'replace' %>
<% end %>
<% end -%>
-<%= link_to 'Back', original_pictures_path %>
+<%= link_to 'Back', system_pictures_path %>
resources :lisences, only: [:index]
resources :original_lisences
resources :common_lisences
- resources :system_pictures, only: [:index, :show]
+ resources :system_pictures, except: [:new, :edit]
# The priority is based upon order of creation:
# first created -> highest priority.
match 'help/(:action)', :controller => 'help'
controller 'system' do
get 'start'
+ get 'index'
# match 'start', :to => 'system#start'
end
def change
create_table :balloon_templates do |t|
t.integer :speach_balloon_id, :null => false
- t.integer :resource_picture_id, :null => false
+ t.integer :system_picture_id, :null => false
t.integer :tail, :null => false, :default => 1
t.integer :border, :null => false, :default => 1
t.integer :min_width, :null => false, :default => 0
create_table :balloons do |t|
t.integer :panel_id, :null => false
t.integer :balloon_template_id, :null => false
- t.integer :resource_picture_id, :null => false
+ t.integer :system_picture_id, :null => false
t.integer :tail, :null => false, :default => 1
t.integer :border, :null => false, :default => 1
t.integer :zindex, :null => false
#\r
# It's strongly recommended to check this file into your version control system.\r
\r
-ActiveRecord::Schema.define(:version => 20111213073529) do\r
+ActiveRecord::Schema.define(:version => 20120102071851) do\r
\r
create_table "admins", :force => true do |t|\r
t.string "email", :default => "", :null => false\r
\r
add_index "speaches", ["balloon_id"], :name => "index_speaches_on_balloon_id"\r
\r
+ create_table "system_pictures", :force => true do |t|\r
+ t.string "ext", :null => false\r
+ t.integer "width", :null => false\r
+ t.integer "height", :null => false\r
+ t.integer "filesize", :null => false\r
+ t.datetime "created_at"\r
+ t.datetime "updated_at"\r
+ end\r
+\r
end\r