X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fcomics_controller.rb;h=2b6005c0df67abd0e318030aa8bf447330af4fae;hb=6733d61c6f0551647a023be3006cb70901497c36;hp=7bd910eb5d0d70c51beae034ee47807c5bf4873e;hpb=783369b9535f6f7e96d1242aec09e06995f364bc;p=pettanr%2Fpettanr.git diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index 7bd910eb..2b6005c0 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -1,143 +1,99 @@ class ComicsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [:top, :index, :show] + before_filter :authenticate_reader, :only => [ + :index, :show, :play, :by_story, :by_author + ] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end - before_filter :authenticate_admin!, :only => [:list, :browse] - - @@model = Comic - @@controller = Pettanr::Application::manifest.controller_managers[@@model.item_name] - @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name] def index - @action = @@controller.open(params, @operators) - @items = @action.items - respond_to do |format| - format.html { - @filer = @action.filer - render :template => 'system/filer', :locals => { - :filer => @filer - } - } - format.json { render json: @items.to_json(@@model.list_json_opt) } - format.atom - format.rss - end + filer_list + end + + def by_story + filer_list + end + + def by_author + filer_list + end + + def show_html_format format + format.html { + @play_list = Locmare::ListGroup.list( + 'comic_stories', 'by_comic', @operators, + {:id => @item.id, :page_size => -1} # set no limit options + ) + } end - + def show - @item = Comic.show(params[:id], @operators) + set_show respond_to do |format| - format.html { - @comic = @item - } - format.prof { - @profiler = @@profiler_manager.open(@item, @operators) - render :template => 'system/prof', :locals => { - :profiler => @profiler - } - } - format.json { render json: @item.to_json(Comic.show_json_opt) } + show_html_format format + show_prof_format format + show_json_format format format.atom format.rss end end - - def count - @comic = {:count => Comic.visible_count} - respond_to do |format| - format.json { render json: @comic.to_json } - 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]) - + def play + set_play + @list.options.merge!({'page_size' => -1}) # no limit no pager + @list.reset + play_list respond_to do |format| - format.html { render layout: 'system' } # show.html.erb - format.json { render json: @comic } + format.html { + if @item.own? @operators + @new_story_items = assist_items('home', 'stories') + end + } + list_json_format @list, format end end def new - @comic = Comic.new - @comic.supply_default - respond_to do |format| - format.html # new.html.erb - format.js - format.json { render json: @comic.to_json(Comic.show_json_opt) } - end + form_new end - + def edit - @comic = Comic.edit(params[:id], @author) - respond_to do |format| - format.html - format.js - end + form_edit end - + def create - @comic = Comic.new - @comic.supply_default - @comic.attributes = params[:comic] - @comic.overwrite @author - - respond_to do |format| - if @comic.save - flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human) - format.html { redirect_to @comic } - format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human) - format.html { render action: "new" } - format.json { render json: @comic.errors, status: :unprocessable_entity } - end - end + set_model + @item = @my_model_class.new + @item.supply_default + @my_model_class.fold_extend_settings params[@my_model_class.item_name] + @item.attributes = params[@my_model_class.item_name] + @item.overwrite @operators + render_create end - + def update - @comic = Comic.edit(params[:id], @author) - @comic.attributes = params[:comic] - @comic.overwrite @author - respond_to do |format| - if @comic.save - flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human) - format.html { redirect_to @comic } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human) - format.html { render action: "edit" } - format.json { render json: @comic.errors, status: :unprocessable_entity } - end - end + set_edit + @my_model_class.fold_extend_settings params[@my_model_class.item_name] + @item.attributes = params[@my_model_class.item_name] + @item.overwrite @operators + render_update end - + def destroy - @comic = Comic.edit(params[:id], @author) + @item = Comic.edit(params[:id], @operators) respond_to do |format| - if @comic.destroy_with_story + if @item.destroy_with_leafs flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human) format.html { redirect_to '/home/comics' } format.json { head :ok } else flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human) - format.html { redirect_to @comic } - format.json { render json: @comic.errors, status: :unprocessable_entity } + format.html { redirect_to @item } + format.json { render json: @item.errors, status: :unprocessable_entity } end end end