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, :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]
28 @item = Scroll.show(params[:id], @operators)
30 respond_to do |format|
33 @new_panel_items = assist_items('panel', 'private_list')
34 @new_panel_filer = assist_filer 'panel', @new_panel_items
37 format.json { render json: @item.to_json(Scroll.show_json_opt) }
45 @item = self.class.model.show(params[:id], @operators)
46 action_name = params[:action]
47 @action = self.class.controller.open(action_name, params, @operators)
48 @items = @action.list.items @item
49 respond_to do |format|
51 @count = @action.list.count @item
52 @prev_offset = @action.list.prev_offset @item
53 @next_offset = @action.list.next_offset @item
55 @new_panel_items = assist_items('panel', 'private_list')
56 @new_panel_filer = assist_filer 'panel', @new_panel_items
59 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
64 @scroll = {:count => Scroll.visible_count}
65 respond_to do |format|
66 format.json { render json: @scroll.to_json }
70 def scroll_panels_count
88 @scroll.supply_default
89 respond_to do |format|
92 format.json { render json: @scroll.to_json(Scroll.show_json_opt) }
97 @scroll = Scroll.edit(params[:id], @operators)
98 respond_to do |format|
106 @scroll.supply_default
107 @scroll.attributes = params[:scroll]
108 @scroll.overwrite @operators
110 respond_to do |format|
112 flash[:notice] = I18n.t('flash.notice.created', :model => Scroll.model_name.human)
113 format.html { redirect_to @scroll }
114 format.json { render json: @scroll.to_json(Scroll.show_json_opt), status: :created, location: @scroll }
116 flash[:notice] = I18n.t('flash.notice.not_created', :model => Scroll.model_name.human)
117 format.html { render action: "new" }
118 format.json { render json: @scroll.errors, status: :unprocessable_entity }
124 @scroll = Scroll.edit(params[:id], @operators)
125 @scroll.attributes = params[:scroll]
126 @scroll.overwrite @operators
127 respond_to do |format|
129 flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
130 format.html { redirect_to @scroll }
131 format.json { head :ok }
133 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Scroll.model_name.human)
134 format.html { render action: "edit" }
135 format.json { render json: @scroll.errors, status: :unprocessable_entity }
141 @scroll = Scroll.edit(params[:id], @operators)
142 respond_to do |format|
143 if @scroll.destroy_with_scroll_panel
144 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
145 format.html { redirect_to '/home/scrolls' }
146 format.json { head :ok }
148 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
149 format.html { redirect_to @scroll }
150 format.json { render json: @scroll.errors, status: :unprocessable_entity }