OSDN Git Service

list browser created
authoryasushiito <yas@pen-chan.jp>
Fri, 13 Jan 2012 23:40:57 +0000 (08:40 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 13 Jan 2012 23:40:57 +0000 (08:40 +0900)
33 files changed:
app/controllers/artists_controller.rb
app/controllers/balloon_templates_controller.rb
app/controllers/balloons_controller.rb
app/controllers/comics_controller.rb
app/controllers/common_lisences_controller.rb
app/controllers/lisences_controller.rb
app/controllers/original_lisences_controller.rb
app/controllers/original_pictures_controller.rb
app/controllers/panel_pictures_controller.rb
app/controllers/panels_controller.rb
app/controllers/resource_pictures_controller.rb
app/controllers/speach_balloons_controller.rb
app/controllers/speach_templates_controller.rb
app/controllers/speaches_controller.rb
app/controllers/system_controller.rb
app/controllers/system_pictures_controller.rb
app/models/comic.rb
app/models/panel.rb
app/models/resource_picture.rb
app/views/comics/index.html.erb
app/views/comics/play.html.erb
app/views/comics/top.html.erb
app/views/common_lisences/edit.html.erb
app/views/common_lisences/new.html.erb
app/views/layouts/application.html.erb
app/views/lisences/_form.html.erb [deleted file]
app/views/lisences/edit.html.erb [deleted file]
app/views/lisences/new.html.erb [deleted file]
app/views/original_pictures/index.html.erb
app/views/panels/index.html.erb
app/views/resource_pictures/index.html.erb
app/views/system/index.html.erb
config/routes.rb

index 442890a..a2fa524 100644 (file)
@@ -1,4 +1,7 @@
 class ArtistsController < ApplicationController
+  before_filter :authenticate_author!, :only => [:index, :show, :create, :update, :destroy]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
+
   # GET /artists
   # GET /artists.json
   def index
@@ -21,6 +24,24 @@ class ArtistsController < ApplicationController
     end
   end
 
+  def list
+    @artists = Artist.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @artists }
+    end
+  end
+
+  def browse
+    @artist = Artist.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @artist }
+    end
+  end
+
   # GET /artists/new
   # GET /artists/new.json
   def new
index 22728ce..faa1ca0 100644 (file)
@@ -1,5 +1,6 @@
 class BalloonTemplatesController < ApplicationController
-  before_filter :authenticate_admin!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
   
   # GET /balloon_templates
   # GET /balloon_templates.json
@@ -11,4 +12,13 @@ class BalloonTemplatesController < ApplicationController
       format.json { render json: @balloon_templates }
     end
   end
+
+  def list
+    @balloon_templates = BalloonTemplate.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @balloon_templates }
+    end
+  end
 end
index 617e9b5..69a9232 100644 (file)
@@ -1,5 +1,7 @@
 class BalloonsController < ApplicationController
-  before_filter :authenticate_user!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
+  
   # GET /balloons
   # GET /balloons.json
   def index
@@ -11,76 +13,12 @@ class BalloonsController < ApplicationController
     end
   end
 
-=begin
-  # GET /balloons/1
-  # GET /balloons/1.json
-  def show
-    @balloon = Balloon.find(params[:id])
-
-    respond_to do |format|
-      format.html # show.html.erb
-      format.json { render json: @balloon }
-    end
-  end
-
-  # GET /balloons/new
-  # GET /balloons/new.json
-  def new
-    @balloon = Balloon.new
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @balloon }
-    end
-  end
-
-  # GET /balloons/1/edit
-  def edit
-    @balloon = Balloon.find(params[:id])
-  end
-
-  # POST /balloons
-  # POST /balloons.json
-  def create
-    @balloon = Balloon.new(params[:balloon])
-
-    respond_to do |format|
-      if @balloon.save
-        format.html { redirect_to @balloon, notice: 'Balloon was successfully created.' }
-        format.json { render json: @balloon, status: :created, location: @balloon }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @balloon.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # PUT /balloons/1
-  # PUT /balloons/1.json
-  def update
-    @balloon = Balloon.find(params[:id])
-
-    respond_to do |format|
-      if @balloon.update_attributes(params[:balloon])
-        format.html { redirect_to @balloon, notice: 'Balloon was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @balloon.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # DELETE /balloons/1
-  # DELETE /balloons/1.json
-  def destroy
-    @balloon = Balloon.find(params[:id])
-    @balloon.destroy
+  def list
+    @balloons = Balloon.all
 
     respond_to do |format|
-      format.html { redirect_to balloons_url }
-      format.json { head :ok }
+      format.html { render layout: 'system' }
+      format.json { render json: @balloons }
     end
   end
-=end
 end
index 7200ab0..8a5169c 100644 (file)
@@ -1,5 +1,6 @@
 class ComicsController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index, :show, :play]
+  before_filter :authenticate_author!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   private
   
@@ -10,12 +11,19 @@ class ComicsController < ApplicationController
   public
   
   def top
+    @comics = Comic.all
+
+    respond_to do |format|
+      format.html # index.html.erb
+    end
   end
   
   # GET /comics
   # GET /comics.json
   def index
-    @comics = Comic.all
+    @comics = Comic.find(:all, 
+      :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 20
+    )
 
     respond_to do |format|
       format.html # index.html.erb
@@ -29,24 +37,24 @@ class ComicsController < ApplicationController
     @comic = Comic.find(params[:id])
 
     respond_to do |format|
-      format.html # show.html.erb
+#      format.html # show.html.erb
       format.json { render json: @comic }
     end
   end
 
   def play
-    @comic = Comic.find(params[:id], include: {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}, order: 'panels.t')
+    @comic = Comic.find(params[:id], include: [:author, {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}], order: 'panels.t')
 
     respond_to do |format|
       format.html # index.html.erb
       format.json {
         render :json => @comic.to_json(
-          :include => {
+          :include => [:author, {
             :panels => {:include => {
               :panel_pictures => {:include => :resource_picture}, 
               :balloons => {:include => :speaches}
             }}
-          }
+          }]
         )
       }
       format.jsonp {
@@ -62,6 +70,24 @@ class ComicsController < ApplicationController
     end
   end
   
+  def list
+    @comics = Comic.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }# index.html.erb
+      format.json { render json: @comics }
+    end
+  end
+
+  def browse
+    @comic = Comic.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' } # show.html.erb
+      format.json { render json: @comic }
+    end
+  end
+  
   # GET /comics/new
   # GET /comics/new.json
   def new
index 35ac50d..927e460 100644 (file)
@@ -1,4 +1,7 @@
 class CommonLisencesController < ApplicationController
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse, :new, :edit, :create, :update, :destroy]
+
   # GET /common_lisences
   # GET /common_lisences.json
   def index
@@ -21,6 +24,24 @@ class CommonLisencesController < ApplicationController
     end
   end
 
+  def list
+    @common_lisences = CommonLisence.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @common_lisences }
+    end
+  end
+
+  def browse
+    @common_lisence = CommonLisence.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @common_lisence }
+    end
+  end
+
   # GET /common_lisences/new
   # GET /common_lisences/new.json
   def new
@@ -45,7 +66,7 @@ class CommonLisencesController < ApplicationController
     respond_to do |format|
       CommonLisence.transaction do
         if @common_lisence.save_save
-          format.html { redirect_to @common_lisence, notice: 'Common lisence was successfully created.' }
+          format.html { redirect_to :action => :browse, :id => @common_lisence.id, notice: 'Common lisence was successfully created.' }
           format.json { render json: @common_lisence, status: :created, location: @common_lisence }
         else
           format.html { render action: "new" }
@@ -62,7 +83,7 @@ class CommonLisencesController < ApplicationController
 
     respond_to do |format|
       if @common_lisence.update_attributes(params[:common_lisence])
-        format.html { redirect_to @common_lisence, notice: 'Common lisence was successfully updated.' }
+        format.html { redirect_to :action => :browse, :id => @common_lisence.id, notice: 'Common lisence was successfully updated.' }
         format.json { head :ok }
       else
         format.html { render action: "edit" }
index 941c838..e40e463 100644 (file)
@@ -1,4 +1,7 @@
 class LisencesController < ApplicationController
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
+
   # GET /lisences
   # GET /lisences.json
   def index
@@ -14,70 +17,28 @@ class LisencesController < ApplicationController
   # GET /lisences/1.json
   def show
     @lisence = Lisence.find(params[:id])
-
-    respond_to do |format|
-      format.html # show.html.erb
-      format.json { render json: @lisence }
-    end
-  end
-
-  # GET /lisences/new
-  # GET /lisences/new.json
-  def new
-    @lisence = Lisence.new
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @lisence }
-    end
-  end
-
-  # GET /lisences/1/edit
-  def edit
-    @lisence = Lisence.find(params[:id])
-  end
-
-  # POST /lisences
-  # POST /lisences.json
-  def create
-    @lisence = Lisence.new(params[:lisence])
-
-    respond_to do |format|
-      if @lisence.save
-        format.html { redirect_to @lisence, notice: 'Lisence was successfully created.' }
-        format.json { render json: @lisence, status: :created, location: @lisence }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @lisence.errors, status: :unprocessable_entity }
-      end
+    if @lisence.common_lisence
+      redirect_to :controller => 'common_lisences', :action => :browse, :id => @lisence.common_lisence.id
+    else
+      redirect_to :controller => 'original_lisences', :action => :browse, :id => @lisence.original_lisence.id
     end
   end
 
-  # PUT /lisences/1
-  # PUT /lisences/1.json
-  def update
-    @lisence = Lisence.find(params[:id])
+  def list
+    @lisences = Lisence.all
 
     respond_to do |format|
-      if @lisence.update_attributes(params[:lisence])
-        format.html { redirect_to @lisence, notice: 'Lisence was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @lisence.errors, status: :unprocessable_entity }
-      end
+      format.html { render layout: 'system' }
+      format.json { render json: @lisences }
     end
   end
 
-  # DELETE /lisences/1
-  # DELETE /lisences/1.json
-  def destroy
+  def browse
     @lisence = Lisence.find(params[:id])
-    @lisence.destroy
 
     respond_to do |format|
-      format.html { redirect_to lisences_url }
-      format.json { head :ok }
+      format.html { render layout: 'system' }
+      format.json { render json: @lisence }
     end
   end
 end
index b0b32b9..c1a2fd2 100644 (file)
@@ -1,5 +1,6 @@
 class OriginalLisencesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   # GET /original_lisences
   # GET /original_lisences.json
@@ -23,6 +24,24 @@ class OriginalLisencesController < ApplicationController
     end
   end
 
+  def list
+    @original_lisences = OriginalLisence.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @original_lisences }
+    end
+  end
+
+  def browse
+    @original_lisence = OriginalLisence.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @original_lisence }
+    end
+  end
+
   # GET /original_lisences/new
   # GET /original_lisences/new.json
   def new
index 0b651ff..27d8b01 100644 (file)
@@ -1,5 +1,6 @@
 class OriginalPicturesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index, :show]
+  before_filter :authenticate_author!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   private
   
@@ -34,11 +35,15 @@ class OriginalPicturesController < ApplicationController
   # GET /original_pictures
   # GET /original_pictures.json
   def index
-    @original_pictures = OriginalPicture.all
+    @original_pictures = OriginalPicture.find(:all, 
+      :include => [:artist, :lisence, :resource_picture], :order => 'updated_at', :limit => 20
+    )
 
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: @original_pictures }
+      format.json { render :json => @original_pictures.to_json(
+        :include => [:resource_picture, :artist, :lisence]
+      ) }
     end
   end
 
@@ -61,6 +66,24 @@ class OriginalPicturesController < ApplicationController
     end
   end
 
+  def list
+    @original_pictures = OriginalPicture.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @original_pictures }
+    end
+  end
+
+  def browse
+    @original_picture = OriginalPicture.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @original_picture }
+    end
+  end
+
   def refresh
     @original_picture = OriginalPicture.find(params[:id])
     img = Magick::Image.from_blob(@original_picture.restore).shift
@@ -99,6 +122,7 @@ class OriginalPicturesController < ApplicationController
     @original_picture = OriginalPicture.new
     img = set_image params
     @original_picture.artist_id = current_author.artist.id
+    @original_picture.lisence_id = current_author.artist.default_lisence_id
 
     respond_to do |format|
       OriginalPicture.transaction do
index 94d3218..37594b7 100644 (file)
@@ -1,5 +1,6 @@
 class PanelPicturesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   # GET /panel_pictures
   # GET /panel_pictures.json
@@ -12,4 +13,13 @@ class PanelPicturesController < ApplicationController
     end
   end
 
+  def list
+    @panel_pictures = PanelPicture.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @panel_pictures }
+    end
+  end
+
 end
index c67cc58..82475e9 100644 (file)
@@ -1,5 +1,6 @@
 class PanelsController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index, :show]
+  before_filter :authenticate_author!, :only => [:index, :show, :create, :update, :destroy]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   private
   
@@ -12,11 +13,13 @@ class PanelsController < ApplicationController
   # GET /panels
   # GET /panels.json
   def index
-    @panels = Panel.all :order => 'updated_at'
+    @panels = Panel.find(:all, :include => [:comic, :author], :order => 'updated_at', :limit => 20)
 
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: @panels }
+      format.json { render :json => @panels.to_json(
+        :include => [:comic, :author]
+      ) }
     end
   end
 
@@ -40,23 +43,24 @@ class PanelsController < ApplicationController
 #      format.json { render :json => @frame.to_json(include: {
 #        :comic => {:only => :title}, :panel_pictures => {:include => {:image => {:only => [:width]}},:only => [:width, :height, :z, :image_id]}
 #      }, only: [:border]) }
-   end
+    end
   end
 
-  # GET /panels/new
-  # GET /panels/new.json
-  def new
-    @panel = Panel.new
+  def list
+    @panels = Panel.all :order => 'updated_at'
 
     respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @panel }
+      format.html { render layout: 'system' }
+      format.json { render json: @panels }
     end
   end
 
-  # GET /panels/1/edit
-  def edit
+  def browse
     @panel = Panel.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+    end
   end
 
   # POST /panels
index f422561..0ab406b 100644 (file)
@@ -1,14 +1,19 @@
 class ResourcePicturesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index, :show]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   # GET /resource_pictures
   # GET /resource_pictures.json
   def index
-    @resource_pictures = ResourcePicture.all
+    @resource_pictures = ResourcePicture.find(:all, 
+      :include => {:original_picture => [:artist, :lisence]}, :order => 'updated_at', :limit => 20
+    )
 
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: @resource_pictures }
+      format.json { render :json => @resource_pictures.to_json(
+        :include => [:original_picture, :artist, :lisence]
+      ) }
     end
   end
 
@@ -27,65 +32,22 @@ class ResourcePicturesController < ApplicationController
     end
   end
 
-=begin
-  # GET /resource_pictures/new
-  # GET /resource_pictures/new.json
-  def new
-    @resource_picture = ResourcePicture.new
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @resource_picture }
-    end
-  end
-
-  # GET /resource_pictures/1/edit
-  def edit
-    @resource_picture = ResourcePicture.find(params[:id])
-  end
-
-  # POST /resource_pictures
-  # POST /resource_pictures.json
-  def create
-    @resource_picture = ResourcePicture.new(params[:resource_picture])
+  def list
+    @resource_pictures = ResourcePicture.all
 
     respond_to do |format|
-      if @resource_picture.save
-        format.html { redirect_to @resource_picture, notice: 'Resource picture was successfully created.' }
-        format.json { render json: @resource_picture, status: :created, location: @resource_picture }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
-      end
+      format.html { render layout: 'system' }
+      format.json { render json: @resource_pictures }
     end
   end
 
-  # PUT /resource_pictures/1
-  # PUT /resource_pictures/1.json
-  def update
+  def browse
     @resource_picture = ResourcePicture.find(params[:id])
 
     respond_to do |format|
-      if @resource_picture.update_attributes(params[:resource_picture])
-        format.html { redirect_to @resource_picture, notice: 'Resource picture was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
-      end
+      format.html { render layout: 'system' }
+      format.json { render json: @resource_picture }
     end
   end
 
-  # DELETE /resource_pictures/1
-  # DELETE /resource_pictures/1.json
-  def destroy
-    @resource_picture = ResourcePicture.find(params[:id])
-    @resource_picture.destroy
-
-    respond_to do |format|
-      format.html { redirect_to resource_pictures_url }
-      format.json { head :ok }
-    end
-  end
-=end
 end
index 1eeba3d..1072cc9 100644 (file)
@@ -1,6 +1,6 @@
 class SpeachBalloonsController < ApplicationController
-  before_filter :authenticate_author!, :only => [:index]
-  before_filter :authenticate_admin!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
 
   private
   
@@ -29,7 +29,8 @@ class SpeachBalloonsController < ApplicationController
     res
   end
   
-  public  # GET /speach_balloons
+  public
+  # GET /speach_balloons
   # GET /speach_balloons.json
   def index
     @speach_balloons = SpeachBalloon.all
@@ -60,20 +61,22 @@ class SpeachBalloonsController < ApplicationController
     end
   end
 
-  # GET /speach_balloons/new
-  # GET /speach_balloons/new.json
-  def new
-    @speach_balloon = SpeachBalloon.new
+  def list
+    @speach_balloons = SpeachBalloon.all
 
     respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @speach_balloon }
+      format.html { render layout: 'system' }
+      format.json { render json: @speach_balloons }
     end
   end
 
-  # GET /speach_balloons/1/edit
-  def edit
+  def browse
     @speach_balloon = SpeachBalloon.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @speach_balloon }
+    end
   end
 
   # POST /speach_balloons
index d8bb57a..ddc3011 100644 (file)
@@ -1,5 +1,6 @@
 class SpeachTemplatesController < ApplicationController
-  before_filter :authenticate_admin!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   # GET /speach_templates
   # GET /speach_templates.json
@@ -12,4 +13,13 @@ class SpeachTemplatesController < ApplicationController
     end
   end
 
+  def list
+    @speach_templates = SpeachTemplate.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @speach_templates }
+    end
+  end
+
 end
index 06675f8..1619319 100644 (file)
@@ -1,5 +1,6 @@
 class SpeachesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   # GET /speaches
   # GET /speaches.json
@@ -12,76 +13,12 @@ class SpeachesController < ApplicationController
     end
   end
 
-=begin
-  # GET /speaches/1
-  # GET /speaches/1.json
-  def show
-    @speach = Speach.find(params[:id])
-
-    respond_to do |format|
-      format.html # show.html.erb
-      format.json { render json: @speach }
-    end
-  end
-
-  # GET /speaches/new
-  # GET /speaches/new.json
-  def new
-    @speach = Speach.new
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @speach }
-    end
-  end
-
-  # GET /speaches/1/edit
-  def edit
-    @speach = Speach.find(params[:id])
-  end
-
-  # POST /speaches
-  # POST /speaches.json
-  def create
-    @speach = Speach.new(params[:speach])
-
-    respond_to do |format|
-      if @speach.save
-        format.html { redirect_to @speach, notice: 'Speach was successfully created.' }
-        format.json { render json: @speach, status: :created, location: @speach }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @speach.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # PUT /speaches/1
-  # PUT /speaches/1.json
-  def update
-    @speach = Speach.find(params[:id])
-
-    respond_to do |format|
-      if @speach.update_attributes(params[:speach])
-        format.html { redirect_to @speach, notice: 'Speach was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @speach.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # DELETE /speaches/1
-  # DELETE /speaches/1.json
-  def destroy
-    @speach = Speach.find(params[:id])
-    @speach.destroy
+  def list
+    @speaches = Speach.all
 
     respond_to do |format|
-      format.html { redirect_to speaches_url }
-      format.json { head :ok }
+      format.html { render layout: 'system' }
+      format.json { render json: @speaches }
     end
   end
-=end
 end
index 8f30dfa..d8276f8 100644 (file)
@@ -1,6 +1,7 @@
 class SystemController < ApplicationController
   before_filter :authenticate_admin!, :except => [:start]
-  layout false, :only => :start
+  
+  #layout :system
   
   def start
   
@@ -9,6 +10,15 @@ class SystemController < ApplicationController
   def index
   end
   
+  def browse
+  end
+  
+  def auth_token
+  end
+  
+  def approbe
+  end
+  
   def waiting_list
     @newadmins = Admin.find(:all, :conditions => ['activate = 0'])
   end
index c671774..8843d8d 100644 (file)
@@ -1,5 +1,6 @@
 class SystemPicturesController < ApplicationController
-  before_filter :authenticate_admin!, :except => [:index, :show]
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
 
   private
   
@@ -57,22 +58,25 @@ class SystemPicturesController < ApplicationController
     end
   end
 
-  # GET /system_pictures/new
-  # GET /system_pictures/new.json
-  def new
-    @system_picture = SystemPicture.new
+  def list
+    @system_pictures = SystemPicture.all
 
     respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @system_picture }
+      format.html { render layout: 'system' }
+      format.json { render json: @system_pictures }
     end
   end
 
-  # GET /system_pictures/1/edit
-  def edit
+  def browse
     @system_picture = SystemPicture.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @system_picture}
+    end
   end
 
+
   # POST /system_pictures
   # POST /system_pictures.json
   def create
index b4b502d..ab882cf 100644 (file)
@@ -1,9 +1,14 @@
 class Comic < ActiveRecord::Base
   has_many :panels, :dependent => :destroy
+  belongs_to :author
 
   def own? author
     return false unless author
     self.author_id == author.id
   end
   
+  def disp_editable
+    editable == 1 ? 'O' : 'X'
+  end
+  
 end
index f60b801..888d7b5 100644 (file)
@@ -1,5 +1,6 @@
 class Panel < ActiveRecord::Base
   belongs_to :comic
+  belongs_to :author
   has_many :panel_pictures, :dependent => :destroy
   has_many :balloons, :dependent => :destroy
   accepts_nested_attributes_for :panel_pictures, :allow_destroy => true
index 391c2db..53abc64 100644 (file)
@@ -78,7 +78,8 @@ class ResourcePicture < ActiveRecord::Base
     resource_picture = ResourcePicture.new(
       width: original_picture.width, height: original_picture.height, 
       ext: original_picture.ext, filesize: original_picture.filesize, 
-      original_picture_id: original_picture.id
+      original_picture_id: original_picture.id, artist_id: original_picture.artist_id, 
+      lisence_id: original_picture.lisence_id
     )
     res = if resource_picture.save
       if resource_picture.store(img)
index b562d4a..48141d4 100644 (file)
@@ -1,40 +1,14 @@
 <h1>Listing comics</h1>
 
-<table>
-  <tr>
-    <th>id</th>
-    <th>Title</th>
-    <th>width</th>
-    <th>height</th>
-    <th>visible</th>
-    <th>editable</th>
-    <th>author_id</th>
-    <th>updated_at</th>
-    <th></th>
-    <th></th>
-    <th></th>
-  </tr>
-
 <% @comics.each do |comic| %>
-  <tr>
-    <td><%= comic.id %></td>
-    <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>
-    <td><%= link_to 'Play', :action => :play, :id => comic.id %></td>
-    <td>
-      <% if author_signed_in? -%>
-        <% if comic.own? current_author -%>
-          <%= link_to 'Destroy', comic, confirm: 'Are you sure?', method: :delete %>
-        <% end -%>
-      <% end -%>
-    </td>
-  </tr>
+  <div>
+    <div>
+      <%= link_to h(comic.title), :action => :play, :id => comic.id %>
+      一般投稿:<%= comic.disp_editable %>
+    </div>
+    <div>
+      作家:<%= h comic.author.name %>
+      更新:<%= comic.updated_at %>
+    </div>
+  </div>
 <% end %>
-</table>
-
index fd90107..8084e33 100644 (file)
@@ -1,19 +1,25 @@
-<p id="notice"><%= notice %></p>
+<h1><%= h @comic.title %></h1>
+<% if author_signed_in? -%>
+  <% if @comic.own? current_author -%>
+    <div>
+      <p id="notice"><%= notice %></p>
+      <p>
+        <b>Title:</b>
+        <%= h @comic.title %>
+      </p>
+      <p>
+        <b>visible:</b>
+        <%= @comic.visible %>
+      </p>
+      <p>
+        <b>editable:</b>
+        <%= @comic.editable %>
+      </p>
+      <%= link_to 'Destroy', @comic, confirm: 'Are you sure?', method: :delete %>
+    </div>
+  <% end -%>
+<% end -%>
 
-<p>
-  <b>Title:</b>
-  <%= h @comic.title %>
-</p>
-
-<p>
-  <b>Default width:</b>
-  <%= @comic.width %>
-</p>
-
-<p>
-  <b>Default height:</b>
-  <%= @comic.height %>
-</p>
 <% @comic.panels.each do |panel| %>
   <% @panel = panel %>
   <%= render 'panels/standard' %>
index c07326a..696809e 100644 (file)
@@ -1,3 +1,29 @@
-<h1>PettanR</h1>
+<h1><%= link_to '新着', comics_path %></h1>
+
+<table>
+  <tr>
+    <th>Title</th>
+    <th>editable</th>
+    <th>author_id</th>
+    <th>updated_at</th>
+    <th></th>
+  </tr>
+
+<% @comics.each do |comic| %>
+  <tr>
+    <td><%= link_to h(comic.title), :action => :play, :id => comic.id %></td>
+    <td><%= comic.editable %></td>
+    <td><%= comic.author_id%></td>
+    <td><%= comic.updated_at %></td>
+    <td>
+      <% if author_signed_in? -%>
+        <% if comic.own? current_author -%>
+          <%= link_to 'Destroy', comic, confirm: 'Are you sure?', method: :delete %>
+        <% end -%>
+      <% end -%>
+    </td>
+  </tr>
+<% end %>
+</table>
+<h1>人気</h1>
 
-  
index 2760acb..7c642d1 100644 (file)
@@ -2,5 +2,5 @@
 
 <%= render 'form' %>
 
-<%= link_to 'Show', @common_lisence %> |
-<%= link_to 'Back', lisences_path %>
+<%= link_to 'Show', :controller => 'common_lisences', :action => :browse, :id => @common_lisence.id %> |
+<%= link_to 'Back', :action => :list %>
index d9a3454..739bf49 100644 (file)
@@ -2,4 +2,4 @@
 
 <%= render 'form' %>
 
-<%= link_to 'Back', common_lisences_path %>
+<%= link_to 'Back', :action => :list %>
index 0b9232f..22a644c 100644 (file)
@@ -8,6 +8,7 @@
 </head>
 <body>
 
+<a href="/">ぺったんR</a>
 <div>
 <% if author_signed_in? %>
   <%= link_to "my home", :controller => '/home' %>
  <p class="notice"><%= notice %></p>
  <p class="alert"><%= alert %></p>
 </div>
+<%= link_to "comics", comics_path %>
+<%= link_to "panels", panels_path %>
+<%= link_to "pictures", original_pictures_path %>
+<%= link_to "lisences", lisences_path %>
 <%= yield %>
 
 </body>
diff --git a/app/views/lisences/_form.html.erb b/app/views/lisences/_form.html.erb
deleted file mode 100644 (file)
index 29c8cab..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<%= form_for(@lisence) do |f| %>
-  <% if @lisence.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@lisence.errors.count, "error") %> prohibited this lisence from being saved:</h2>
-
-      <ul>
-      <% @lisence.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
-
-  <div class="actions">
-    <%= f.submit %>
-  </div>
-<% end %>
diff --git a/app/views/lisences/edit.html.erb b/app/views/lisences/edit.html.erb
deleted file mode 100644 (file)
index 1c041a6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<h1>Editing lisence</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @lisence %> |
-<%= link_to 'Back', lisences_path %>
diff --git a/app/views/lisences/new.html.erb b/app/views/lisences/new.html.erb
deleted file mode 100644 (file)
index 3205771..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<h1>New lisence</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', lisences_path %>
index 0143366..43c5fb2 100644 (file)
@@ -1,31 +1,12 @@
 <h1>Listing original_pictures</h1>
 
 <%= 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| %>
-  <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>
-      <% if author_signed_in? -%>
-        <% if original_picture.own? current_author -%>
-          <%= link_to 'Destroy', original_picture, confirm: 'Are you sure?', method: :delete %>
-        <% end -%>
-      <% end -%>
-    </td>
-  </tr>
+  <div>
+    <%= original_picture.filename %>
+    <img src="<%= original_picture.resource_picture.url('thumbnail') -%>">
+    <%= original_picture.width %>x<%= original_picture.height %>
+    <%= original_picture.filesize %>bytes
+    画:<%= h original_picture.artist.name %>
+  </div>
 <% end %>
-</table>
index 0910ddb..efe8b5e 100644 (file)
@@ -1,45 +1,24 @@
-<h1>Listing panels</h1>
-
-<table>
-  <tr>
-    <th>id</th>
-    <th>Comic</th>
-    <th>bg</th>
-    <th>Width</th>
-    <th>Height</th>
-    <th>Border</th>
-    <th>x</th>
-    <th>y</th>
-    <th>z</th>
-    <th>t</th>
-    <th>author_id</th>
-    <th>updated_at</th>
-    <th></th>
-    <th></th>
-  </tr>
-
+<h1>Listing panels 最近の投稿</h1>
 <% @panels.each do |panel| %>
-  <tr>
-    <td><%= panel.id %></td>
-    <td><%= panel.comic_id %></td>
-    <td><%= panel.resource_picture_id %></td>
-    <td><%= panel.width %></td>
-    <td><%= panel.height %></td>
-    <td><%= panel.border %></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>
-    <td>
-      <% if author_signed_in? -%>
-        <% if panel.own? current_author -%>
-          <%= link_to 'Destroy', panel, confirm: 'Are you sure?', method: :delete %>
-        <% end -%>
-      <% end -%>
-    </td>
-  </tr>
+  <div>
+    <%= link_to h(panel.comic.title), panel.comic %>t:<%= panel.t %>
+<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| %>
+    <div id="vPicture<%= panel_picture.id -%>" class="panel_picture" style="position:relative;  top:<%= panel_picture.y -%>px; left:<%= panel_picture.x -%>px; z-index:<%= panel_picture.z -%>; ">
+      <img style=" position:absolute; width:<%= panel_picture.width -%>px; height:<%= panel_picture.height -%>px; " src="<%= panel_picture.url -%>">
+    </div>
+  <% end %>
+  <% panel.balloons.each do |balloon| %>
+    <div id="vballoon<%= balloon.id -%>" class="balloon" style="position:relative;  top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= balloon.z -%>; ">
+      <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.y -%>px; left:<%= speach.x -%>px;width:<%= speach.width -%>px; height:<%= speach.height -%>px; top:1px; left:1px; z-index:1; ">
+          <%= h speach.content -%>
+        </div>
+      <% end %>
+    </div>
+  <% end %>
+</div>
+    <%= h panel.author.name %> <%= panel.updated_at %>
+  </div>
 <% end %>
-</table>
index 05a67a1..4c3d464 100644 (file)
@@ -1,22 +1,10 @@
 <h1>Listing resource_pictures</h1>
-
-<table>
-  <tr>
-    <th>Ext</th>
-    <th>Width</th>
-    <th>Height</th>
-    <th>filesize</th>
-  </tr>
-
 <% @resource_pictures.each do |resource_picture| %>
-  <tr>
-    <td><%= resource_picture.ext %></td>
-    <td><%= resource_picture.width %></td>
-    <td><%= resource_picture.height %></td>
-    <td><%= resource_picture.filesize %></td>
-    <td>
-      <%= link_to 'show', resource_picture %>
-    </td>
-  </tr>
+  <div>
+    <%= resource_picture.filename %>
+    <img src="<%= resource_picture.url('thumbnail') -%>">
+    <%= resource_picture.width %>x<%= resource_picture.height %>
+    <%= resource_picture.filesize %>bytes
+    画:<%= h resource_picture.original_picture.artist.name %>
+  </div>
 <% end %>
-</table>
index 165f69d..0543ff4 100644 (file)
@@ -1,22 +1,19 @@
-authentication_token:<%= current_admin.authentication_token %>
-
 <div>
  <p class="notice"><%= notice %></p>
  <p class="alert"><%= alert %></p>
-<%= link_to 'comics', comics_path %>
-<%= link_to 'panels', panels_path %>
-<%= link_to 'original_pictures', original_pictures_path %>
-<%= link_to 'resource_pictures', resource_pictures_path %>
-<%= link_to 'panel_pictures', panel_pictures_path %>
-<%= link_to 'balloons', balloons_path %>
-<%= link_to 'speaches', speaches_path %>
- : 
-<%= link_to 'speach_balloons', speach_balloons_path %>
-<%= link_to 'balloon_templates', balloon_templates_path %>
-<%= link_to 'speach_templates', speach_templates_path %>
- : 
-<%= 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>
+<div>
+  <%= link_to 'browse', :action => :browse %>
+</div>
+<div>
+  <%= link_to 'auth token', :action => :auth_token %>
+</div>
+<div>
+フキダシの管理
+</div>
+<div>
+コモンライセンスの管理
+</div>
+<div>
+システム画像の管理
 </div>
index 2567080..849d93b 100644 (file)
@@ -5,21 +5,182 @@ Pettanr::Application.routes.draw do
 
   match 'original_pictures/:id(.:format)/refresh' => 'original_pictures#refresh'
 
-  resources :artists, except: [:new, :edit]
-  resources :speaches, only: [:index]
-  resources :balloons, only: [:index]
-  resources :speach_templates, only: [:index]
-  resources :balloon_templates, only: [:index]
-  resources :speach_balloons, except: [:new, :edit]
-  resources :panel_pictures, only: [:index]
-  resources :resource_pictures, only: [:index, :show]
-  resources :original_pictures, except: [:new]
-  resources :panels, except: [:new, :edit]
-  resources :comics, except: [:new, :edit]
-  resources :lisences, only: [:index]
-  resources :original_lisences
-  resources :common_lisences
-  resources :system_pictures, except: [:new, :edit]
+  resources :artists do
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
+  resources :speaches do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+    member do
+    end
+  end
+  resources :balloons do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+    member do
+    end
+  end
+  resources :speach_templates do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+    member do
+    end
+  end
+  resources :balloon_templates do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+    member do
+    end
+  end
+  resources :speach_balloons do
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
+  resources :panel_pictures do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+    member do
+    end
+  end
+  resources :resource_pictures do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+    member do
+    end
+  end
+  resources :original_pictures do
+    collection do
+      get :index
+      get :show
+      get :new
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      get :edit
+      put :update
+      delete :destroy
+    end
+  end
+  resources :panels do
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
+  resources :comics do #, except: [:new, :edit]
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
+  resources :lisences do
+    collection do
+      get :index
+      get :show
+      get :list
+      get :browse
+    end
+  end
+  resources :original_lisences do
+    collection do
+      get :index
+      get :show
+      get :new
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      get :edit
+      put :update
+      delete :destroy
+    end
+  end
+  resources :common_lisences do
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
+  resources :system_pictures do
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
 
   # The priority is based upon order of creation:
   # first created -> highest priority.
@@ -86,5 +247,5 @@ Pettanr::Application.routes.draw do
 
   # 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