class ScrollsController < 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, :play]
+ before_filter :authenticate_reader, :only => [:top, :index, :show, :play, :by_author, :by_panel]
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]
def self.model
Scroll
end
def index
- public_list
+ filer_list
end
-
+
+ def by_author
+ filer_list
+ end
+
+ def by_panel
+ filer_list
+ end
+
+ def show_html_format format
+ format.html {
+ @scroll = @item
+ if @operators.author
+ @new_panel_items = assist_items('panel', 'private_list')
+ #@new_panel_filer = assist_filer 'panel', @new_panel_items
+ end
+ }
+ end
+
def show
- @item = Scroll.show(params[:id], @operators)
-
+ set_show
respond_to do |format|
- format.html {
- @scroll = @item
- if @operators.author
- @new_panels = Panel.mylist(@operators.author, 1, 5)
- end
- }
- format.json { render json: @item.to_json(Scroll.show_json_opt) }
- format_prof format
- format.atom
- format.rss
+ show_html_format format
+ show_prof_format format
+ show_json_format format
end
end
def play
- @scroll = Scroll.show(params[:id], [@user, @admin])
- cnt = ScrollPanel.count(:conditions => ['scroll_id = ?', @scroll.id]).to_i
- @offset = ScrollPanel.offset cnt, params[:offset]
- @panel_count = ScrollPanel.panel_count cnt, params[:count]
- @scroll_panels = ScrollPanel.play_list(@scroll, @author, @offset, @panel_count)
+ @item = self.class.model.show(params[:id], @operators)
+ action_name = params[:action]
+ @action = self.class.controller.open(action_name, params, @operators)
+ @items = @action.list.items @item
respond_to do |format|
format.html {
- @prev_offset = if @offset > 0
- if @offset - @panel_count < 0
- 0
- else
- @offset - @panel_count
- end
- else
- nil
- end
- @next_offset = if @offset + @panel_count > cnt
- nil
- else
- @offset + @panel_count
- end
- if @author
- @new_panels = Panel.mylist(@author, 1, 5)
+ @count = @action.list.count @item
+ @prev_offset = @action.list.prev_offset @item
+ @next_offset = @action.list.next_offset @item
+ if @operators.author
+ @new_panel_items = assist_items('panel', 'private_list')
+ @new_panel_filer = assist_filer 'panel', @new_panel_items
end
}
- format.json {render text: ScrollPanel.list_as_json_text(@scroll_panels, @author)}
- format.jsonp {
- render :json => "callback(" + @scroll_panels.to_json_list + ");"
- }
+ format.json { render json: @items.to_json(self.class.model.list_json_opt) }
end
end
def count
- @scroll = {:count => Scroll.visible_count}
- respond_to do |format|
- format.json { render json: @scroll.to_json }
- end
+ list_count
end
- def list
- @scrolls = Scroll.all
-
- respond_to do |format|
- format.html { render layout: 'system' }# index.html.erb
- format.json { render json: @scrolls }
- end
+ def count_by_author
+ list_count
end
-
- def browse
- @scroll = Scroll.find(params[:id])
-
- respond_to do |format|
- format.html { render layout: 'system' } # show.html.erb
- format.json { render json: @scroll }
- end
+
+ def count_by_panel
+ list_count
end
def new
- @scroll = Scroll.new
- @scroll.supply_default
- respond_to do |format|
- format.html # new.html.erb
- format.js
- format.json { render json: @scroll.to_json(Scroll.show_json_opt) }
- end
+ form_new
end
def edit
- @scroll = Scroll.edit(params[:id], @author)
+ @scroll = Scroll.edit(params[:id], @operators)
respond_to do |format|
format.html
format.js
end
def update
- @scroll = Scroll.edit(params[:id], @author)
+ @scroll = Scroll.edit(params[:id], @operators)
@scroll.attributes = params[:scroll]
- @scroll.overwrite @author
+ @scroll.overwrite @operators
respond_to do |format|
if @scroll.save
flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
end
def destroy
- @scroll = Scroll.edit(params[:id], @author)
+ @scroll = Scroll.edit(params[:id], @operators)
respond_to do |format|
if @scroll.destroy_with_scroll_panel
flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)