1 class ScrollsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_reader, :only => [:top, :index, :show, :play, :scroll_panels, :panels, :by_author, :by_panel]
7 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
36 @item = Scroll.show(params[:id], @operators)
38 respond_to do |format|
41 @new_panel_items = assist_items('panel', 'private_list')
42 @new_panel_filer = assist_filer 'panel', @new_panel_items
45 format.json { render json: @item.to_json(Scroll.show_json_opt) }
53 @item = self.class.model.show(params[:id], @operators)
54 action_name = params[:action]
55 @action = self.class.controller.open(action_name, params, @operators)
56 @items = @action.list.items @item
57 respond_to do |format|
59 @count = @action.list.count @item
60 @prev_offset = @action.list.prev_offset @item
61 @next_offset = @action.list.next_offset @item
63 @new_panel_items = assist_items('panel', 'private_list')
64 @new_panel_filer = assist_filer 'panel', @new_panel_items
67 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
72 @scroll = {:count => Scroll.visible_count}
73 respond_to do |format|
74 format.json { render json: @scroll.to_json }
80 @scroll.supply_default
81 respond_to do |format|
84 format.json { render json: @scroll.to_json(Scroll.show_json_opt) }
89 @scroll = Scroll.edit(params[:id], @operators)
90 respond_to do |format|
98 @scroll.supply_default
99 @scroll.attributes = params[:scroll]
100 @scroll.overwrite @operators
102 respond_to do |format|
104 flash[:notice] = I18n.t('flash.notice.created', :model => Scroll.model_name.human)
105 format.html { redirect_to @scroll }
106 format.json { render json: @scroll.to_json(Scroll.show_json_opt), status: :created, location: @scroll }
108 flash[:notice] = I18n.t('flash.notice.not_created', :model => Scroll.model_name.human)
109 format.html { render action: "new" }
110 format.json { render json: @scroll.errors, status: :unprocessable_entity }
116 @scroll = Scroll.edit(params[:id], @operators)
117 @scroll.attributes = params[:scroll]
118 @scroll.overwrite @operators
119 respond_to do |format|
121 flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
122 format.html { redirect_to @scroll }
123 format.json { head :ok }
125 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Scroll.model_name.human)
126 format.html { render action: "edit" }
127 format.json { render json: @scroll.errors, status: :unprocessable_entity }
133 @scroll = Scroll.edit(params[:id], @operators)
134 respond_to do |format|
135 if @scroll.destroy_with_scroll_panel
136 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
137 format.html { redirect_to '/home/scrolls' }
138 format.json { head :ok }
140 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
141 format.html { redirect_to @scroll }
142 format.json { render json: @scroll.errors, status: :unprocessable_entity }