From: yasushiito Date: Fri, 13 Jan 2012 23:40:57 +0000 (+0900) Subject: list browser created X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=46ddebc32f7409dc749f83c710aba9a345381165;hp=8d0ff88e6f28087581d8a4b70d7bc0a2a714da91 list browser created --- diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 442890ac..a2fa524d 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -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 diff --git a/app/controllers/balloon_templates_controller.rb b/app/controllers/balloon_templates_controller.rb index 22728cea..faa1ca00 100644 --- a/app/controllers/balloon_templates_controller.rb +++ b/app/controllers/balloon_templates_controller.rb @@ -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 diff --git a/app/controllers/balloons_controller.rb b/app/controllers/balloons_controller.rb index 617e9b5d..69a92322 100644 --- a/app/controllers/balloons_controller.rb +++ b/app/controllers/balloons_controller.rb @@ -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 diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index 7200ab0a..8a5169c5 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -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 diff --git a/app/controllers/common_lisences_controller.rb b/app/controllers/common_lisences_controller.rb index 35ac50dc..927e460d 100644 --- a/app/controllers/common_lisences_controller.rb +++ b/app/controllers/common_lisences_controller.rb @@ -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" } diff --git a/app/controllers/lisences_controller.rb b/app/controllers/lisences_controller.rb index 941c838d..e40e463a 100644 --- a/app/controllers/lisences_controller.rb +++ b/app/controllers/lisences_controller.rb @@ -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 diff --git a/app/controllers/original_lisences_controller.rb b/app/controllers/original_lisences_controller.rb index b0b32b98..c1a2fd22 100644 --- a/app/controllers/original_lisences_controller.rb +++ b/app/controllers/original_lisences_controller.rb @@ -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 diff --git a/app/controllers/original_pictures_controller.rb b/app/controllers/original_pictures_controller.rb index 0b651ff9..27d8b017 100644 --- a/app/controllers/original_pictures_controller.rb +++ b/app/controllers/original_pictures_controller.rb @@ -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 diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index 94d32185..37594b7e 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -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 diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index c67cc58b..82475e99 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -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 diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index f4225611..0ab406b1 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -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 diff --git a/app/controllers/speach_balloons_controller.rb b/app/controllers/speach_balloons_controller.rb index 1eeba3d3..1072cc93 100644 --- a/app/controllers/speach_balloons_controller.rb +++ b/app/controllers/speach_balloons_controller.rb @@ -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 diff --git a/app/controllers/speach_templates_controller.rb b/app/controllers/speach_templates_controller.rb index d8bb57a9..ddc3011b 100644 --- a/app/controllers/speach_templates_controller.rb +++ b/app/controllers/speach_templates_controller.rb @@ -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 diff --git a/app/controllers/speaches_controller.rb b/app/controllers/speaches_controller.rb index 06675f80..1619319c 100644 --- a/app/controllers/speaches_controller.rb +++ b/app/controllers/speaches_controller.rb @@ -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 diff --git a/app/controllers/system_controller.rb b/app/controllers/system_controller.rb index 8f30dfa9..d8276f82 100644 --- a/app/controllers/system_controller.rb +++ b/app/controllers/system_controller.rb @@ -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 diff --git a/app/controllers/system_pictures_controller.rb b/app/controllers/system_pictures_controller.rb index c671774a..8843d8d0 100644 --- a/app/controllers/system_pictures_controller.rb +++ b/app/controllers/system_pictures_controller.rb @@ -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 diff --git a/app/models/comic.rb b/app/models/comic.rb index b4b502d6..ab882cf0 100644 --- a/app/models/comic.rb +++ b/app/models/comic.rb @@ -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 diff --git a/app/models/panel.rb b/app/models/panel.rb index f60b8017..888d7b5c 100644 --- a/app/models/panel.rb +++ b/app/models/panel.rb @@ -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 diff --git a/app/models/resource_picture.rb b/app/models/resource_picture.rb index 391c2dbf..53abc643 100644 --- a/app/models/resource_picture.rb +++ b/app/models/resource_picture.rb @@ -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) diff --git a/app/views/comics/index.html.erb b/app/views/comics/index.html.erb index b562d4a6..48141d42 100644 --- a/app/views/comics/index.html.erb +++ b/app/views/comics/index.html.erb @@ -1,40 +1,14 @@

Listing comics

- - - - - - - - - - - - - - - <% @comics.each do |comic| %> - - - - - - - - - - - - - +
+
+ <%= link_to h(comic.title), :action => :play, :id => comic.id %> + 一般投稿:<%= comic.disp_editable %> +
+
+ 作家:<%= h comic.author.name %> + 更新:<%= comic.updated_at %> +
+
<% end %> -
idTitlewidthheightvisibleeditableauthor_idupdated_at
<%= comic.id %><%= h comic.title %><%= comic.width %><%= comic.height %><%= comic.visible %><%= comic.editable %><%= comic.author_id%><%= comic.updated_at %><%= link_to 'Show', comic %><%= link_to 'Play', :action => :play, :id => comic.id %> - <% if author_signed_in? -%> - <% if comic.own? current_author -%> - <%= link_to 'Destroy', comic, confirm: 'Are you sure?', method: :delete %> - <% end -%> - <% end -%> -
- diff --git a/app/views/comics/play.html.erb b/app/views/comics/play.html.erb index fd90107b..8084e33c 100644 --- a/app/views/comics/play.html.erb +++ b/app/views/comics/play.html.erb @@ -1,19 +1,25 @@ -

<%= notice %>

+

<%= h @comic.title %>

+<% if author_signed_in? -%> + <% if @comic.own? current_author -%> +
+

<%= notice %>

+

+ Title: + <%= h @comic.title %> +

+

+ visible: + <%= @comic.visible %> +

+

+ editable: + <%= @comic.editable %> +

+ <%= link_to 'Destroy', @comic, confirm: 'Are you sure?', method: :delete %> +
+ <% end -%> +<% end -%> -

- Title: - <%= h @comic.title %> -

- -

- Default width: - <%= @comic.width %> -

- -

- Default height: - <%= @comic.height %> -

<% @comic.panels.each do |panel| %> <% @panel = panel %> <%= render 'panels/standard' %> diff --git a/app/views/comics/top.html.erb b/app/views/comics/top.html.erb index c07326a9..696809ee 100644 --- a/app/views/comics/top.html.erb +++ b/app/views/comics/top.html.erb @@ -1,3 +1,29 @@ -

PettanR

+

<%= link_to '新着', comics_path %>

+ + + + + + + + + + +<% @comics.each do |comic| %> + + + + + + + +<% end %> +
Titleeditableauthor_idupdated_at
<%= link_to h(comic.title), :action => :play, :id => comic.id %><%= comic.editable %><%= comic.author_id%><%= comic.updated_at %> + <% if author_signed_in? -%> + <% if comic.own? current_author -%> + <%= link_to 'Destroy', comic, confirm: 'Are you sure?', method: :delete %> + <% end -%> + <% end -%> +
+

人気

- diff --git a/app/views/common_lisences/edit.html.erb b/app/views/common_lisences/edit.html.erb index 2760acbf..7c642d1f 100644 --- a/app/views/common_lisences/edit.html.erb +++ b/app/views/common_lisences/edit.html.erb @@ -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 %> diff --git a/app/views/common_lisences/new.html.erb b/app/views/common_lisences/new.html.erb index d9a34545..739bf498 100644 --- a/app/views/common_lisences/new.html.erb +++ b/app/views/common_lisences/new.html.erb @@ -2,4 +2,4 @@ <%= render 'form' %> -<%= link_to 'Back', common_lisences_path %> +<%= link_to 'Back', :action => :list %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0b9232f7..22a644ca 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,6 +8,7 @@ +ぺったんR
<% if author_signed_in? %> <%= link_to "my home", :controller => '/home' %> @@ -28,6 +29,10 @@

<%= notice %>

<%= alert %>

+<%= link_to "comics", comics_path %> +<%= link_to "panels", panels_path %> +<%= link_to "pictures", original_pictures_path %> +<%= link_to "lisences", lisences_path %> <%= yield %> diff --git a/app/views/lisences/_form.html.erb b/app/views/lisences/_form.html.erb deleted file mode 100644 index 29c8caba..00000000 --- a/app/views/lisences/_form.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<%= form_for(@lisence) do |f| %> - <% if @lisence.errors.any? %> -
-

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

- - -
- <% end %> - -
- <%= f.submit %> -
-<% end %> diff --git a/app/views/lisences/edit.html.erb b/app/views/lisences/edit.html.erb deleted file mode 100644 index 1c041a66..00000000 --- a/app/views/lisences/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing lisence

- -<%= 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 index 32057713..00000000 --- a/app/views/lisences/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New lisence

- -<%= render 'form' %> - -<%= link_to 'Back', lisences_path %> diff --git a/app/views/original_pictures/index.html.erb b/app/views/original_pictures/index.html.erb index 01433661..43c5fb27 100644 --- a/app/views/original_pictures/index.html.erb +++ b/app/views/original_pictures/index.html.erb @@ -1,31 +1,12 @@

Listing original_pictures

<%= render 'uploader' %> - - - - - - - - - - <% @original_pictures.each do |original_picture| %> - - - - - - - - - +
+ <%= original_picture.filename %> + + <%= original_picture.width %>x<%= original_picture.height %> + <%= original_picture.filesize %>bytes + 画:<%= h original_picture.artist.name %> +
<% end %> -
ExtWidthHeightfilesizeartist
<%= original_picture.ext %><%= original_picture.width %><%= original_picture.height %><%= original_picture.filesize %><%= original_picture.artist_id %><%= link_to 'Show', original_picture %> - <% if author_signed_in? -%> - <% if original_picture.own? current_author -%> - <%= link_to 'Destroy', original_picture, confirm: 'Are you sure?', method: :delete %> - <% end -%> - <% end -%> -
diff --git a/app/views/panels/index.html.erb b/app/views/panels/index.html.erb index 0910ddbf..efe8b5e2 100644 --- a/app/views/panels/index.html.erb +++ b/app/views/panels/index.html.erb @@ -1,45 +1,24 @@ -

Listing panels

- - - - - - - - - - - - - - - - - - - +

Listing panels 最近の投稿

<% @panels.each do |panel| %> - - - - - - - - - - - - - - - - +
+ <%= link_to h(panel.comic.title), panel.comic %>t:<%= panel.t %> +
+ <% panel.panel_pictures.each do |panel_picture| %> +
+ +
+ <% end %> + <% panel.balloons.each do |balloon| %> +
+ + <% balloon.speaches.each do |speach| %> +
+ <%= h speach.content -%> +
+ <% end %> +
+ <% end %> +
+ <%= h panel.author.name %> <%= panel.updated_at %> +
<% end %> -
idComicbgWidthHeightBorderxyztauthor_idupdated_at
<%= panel.id %><%= panel.comic_id %><%= panel.resource_picture_id %><%= panel.width %><%= panel.height %><%= panel.border %><%= panel.x %><%= panel.y %><%= panel.z %><%= panel.t %><%= panel.author_id %><%= panel.updated_at %><%= link_to 'Show', panel %> - <% if author_signed_in? -%> - <% if panel.own? current_author -%> - <%= link_to 'Destroy', panel, confirm: 'Are you sure?', method: :delete %> - <% end -%> - <% end -%> -
diff --git a/app/views/resource_pictures/index.html.erb b/app/views/resource_pictures/index.html.erb index 05a67a1c..4c3d4646 100644 --- a/app/views/resource_pictures/index.html.erb +++ b/app/views/resource_pictures/index.html.erb @@ -1,22 +1,10 @@

Listing resource_pictures

- - - - - - - - - <% @resource_pictures.each do |resource_picture| %> - - - - - - - +
+ <%= resource_picture.filename %> + + <%= resource_picture.width %>x<%= resource_picture.height %> + <%= resource_picture.filesize %>bytes + 画:<%= h resource_picture.original_picture.artist.name %> +
<% end %> -
ExtWidthHeightfilesize
<%= resource_picture.ext %><%= resource_picture.width %><%= resource_picture.height %><%= resource_picture.filesize %> - <%= link_to 'show', resource_picture %> -
diff --git a/app/views/system/index.html.erb b/app/views/system/index.html.erb index 165f69d7..0543ff42 100644 --- a/app/views/system/index.html.erb +++ b/app/views/system/index.html.erb @@ -1,22 +1,19 @@ -authentication_token:<%= current_admin.authentication_token %> -

<%= notice %>

<%= alert %>

-<%= 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 %> +
+
+ <%= link_to 'browse', :action => :browse %> +
+
+ <%= link_to 'auth token', :action => :auth_token %> +
+
+フキダシの管理 +
+
+コモンライセンスの管理 +
+
+システム画像の管理
diff --git a/config/routes.rb b/config/routes.rb index 2567080b..849d93b6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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