class AuthorsController < 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]
before_filter :authenticate_author, :only => [:edit, :update]
else
- before_filter :authenticate_reader, :only => [:index, :show, :scrolls, :scroll_panels, :comics, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors]
+ before_filter :authenticate_reader, :only => [:index, :show, :count]
before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
before_filter :authenticate_author, :only => [:edit, :update]
end
- before_filter :authenticate_admin!, :only => [:list, :browse]
def index
- @page = Author.page params[:page]
- @page_size = Author.page_size params[:page_size]
- @authors = Author.list(@page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = Author.list_paginate(@page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @authors, :model => Author,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render :json => @authors.to_json(Author.list_json_opt) }
- end
- end
-
- def show
- @item = Author.show(params[:id], [@user, @admin])
-
- respond_to do |format|
- format.html {
- @author = @item
- }
- format_prof format
- format.json { render :json => @item.to_json(Author.show_json_opt) }
- end
- end
-
- def scrolls
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.scroll_page_size params[:page_size]
- @scrolls = Scroll.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = Scroll.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @scrolls, :model => Scroll,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @scrolls.to_json(Scroll.list_json_opt) }
- end
- end
-
- def scroll_panels
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.scroll_page_size params[:page_size]
- @scroll_panels = ScrollPanel.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = ScrollPanel.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @scroll_panels, :model => ScrollPanel,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @scroll_panels.to_json(ScrollPanel.list_json_opt) }
- end
- end
-
- def comics
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.comic_page_size params[:page_size]
- @comics = Comic.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = Comic.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @comics, :model => Comic,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @comics.to_json(Comic.list_json_opt) }
- end
- end
-
- def stories
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.story_page_size params[:page_size]
- @stories = Story.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = Story.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @stories, :model => Story,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @stories.to_json(Story.list_json_opt) }
- end
- end
-
- def story_sheets
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.sheet_page_size params[:page_size]
- @story_sheets = StorySheet.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = StorySheet.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @story_sheets, :model => StorySheet,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @story_sheets.to_json(StorySheet.list_json_opt) }
- end
- end
-
- def sheets
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.sheet_page_size params[:page_size]
- @sheets = Sheet.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = Sheet.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @sheets, :model => Sheet,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @sheets.to_json(Sheet.list_json_opt) }
- end
- end
-
- def sheet_panels
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.sheet_page_size params[:page_size]
- @sheet_panels = SheetPanel.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = SheetPanel.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @sheet_panels, :model => SheetPanel,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @sheet_panels.to_json(SheetPanel.list_json_opt) }
- end
+ filer_list
end
- def panels
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
- @panels = Panel.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = Panel.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @panels, :model => Panel,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render text: Panel.list_as_json_text(@panels) }
- end
- end
-
- def panel_pictures
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.panel_picture_page_size params[:page_size]
- @panel_pictures = PanelPicture.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = PanelPicture.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @panel_pictures, :model => PanelPicture,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
- end
- end
-
- def speech_balloons
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.panel_picture_page_size params[:page_size]
- @speech_balloons = SpeechBalloon.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = SpeechBalloon.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @speech_balloons, :model => SpeechBalloon,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @speech_balloons.to_json(SpeechBalloon.list_json_opt) }
- end
+ def show_html_format format
+ format.html {
+ }
end
- def ground_pictures
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.ground_picture_page_size params[:page_size]
- @ground_pictures = GroundPicture.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html {
- @paginate = GroundPicture.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @ground_pictures, :model => GroundPicture,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
- end
- end
-
- def ground_colors
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.ground_color_page_size params[:page_size]
- @ground_colors = GroundColor.himlist(@au, @page, @page_size)
-
+ def show
+ set_show
respond_to do |format|
- format.html {
- @paginate = GroundColor.himlist_paginate(@au, @page, @page_size)
- render :template => 'system/filer', :locals => {
- :items => @ground_colors, :model => GroundColor,
- :roles => [@user, @admin], :pager => @paginate
- }
- }
- format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
+ show_html_format format
+ show_prof_format format
+ show_json_format format
end
end
def count
- @au = {:count => Author.visible_count}
- respond_to do |format|
- format.json { render json: @au.to_json }
- end
- end
-
- def list
- @authors = Author.all
-
- respond_to do |format|
- format.html { render layout: 'system' }
- end
- end
-
- def browse
- @au = Author.find(params[:id])
-
- respond_to do |format|
- format.html { render layout: 'system' }
- end
+ list_count
end
def new
- @au = Author.new
- @au.supply_default
-
- respond_to do |format|
- format.html # new.html.erb
- format.js
- format.json { render json: @au.to_json(Author.show_json_opt) }
- end
+ form_new
end
-
+
def edit
- @au = Author.edit(params[:id], @author)
+ form_edit
end
-
+
def create
- @au = Author.new()
- @au.supply_default
- @au.attributes = params[:author]
- @au.overwrite @user.id
- respond_to do |format|
- if @au.save
- flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
- format.html { redirect_to root_path }
- format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
- else
- flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
- format.html { render action: "new" }
- format.json { render json: @au.errors, status: :unprocessable_entity }
- end
- end
+ set_model
+ @item = @my_model_class.new
+ @item.supply_default
+ @item.attributes = params[@my_model_class.item_name]
+ @item.overwrite @operators
+ render_create root_path
end
-
+
def update
- @au = Author.edit(params[:id], @author)
- @au.attributes = params[:author]
- @au.overwrite @user.id
-
- respond_to do |format|
- if @au.save
- flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
- format.html { redirect_to '/home/configure' }
- format.json { head :ok }
- else
- flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
- format.html { render action: "edit" }
- format.json { render json: @au.errors, status: :unprocessable_entity }
- end
- end
+ set_edit
+ @item.attributes = params[@my_model_class.item_name]
+ @item.overwrite @operators
+ render_update '/home/configure'
end
end