class Object
Public Instance Methods
Source
# File app/admin_common.rb, line 62 def adminui_show_markdown(context, md_file) respond_to do |format| format.html do erb :markdown, :layout => :page_layout, :locals => { md_file: md_file, context: context } end format.json do content_type :json { context: context.to_h, markdown: md_file }.to_json end end end
Source
# File app/admin_common.rb, line 82 def adminui_show_none(context) respond_to do |format| format.html do erb :none, :layout => :page_layout, :locals => { context: context } end format.json do content_type :json { context: context.to_h }.to_json end end end
Source
# File app/admin_common.rb, line 49 def adminui_show_table(context, table, erb: :table, locals: {}, aux_tables: []) fmt = request.params.fetch('admintoolformat', '') adminui_show_table_format(context, table, fmt, erb: erb, locals: locals, aux_tables: aux_tables) unless fmt.empty? respond_to do |format| format.json do adminui_show_table_format(context, table, 'json', erb: erb, locals: locals, aux_tables: aux_tables) end format.html do adminui_show_table_format(context, table, 'html', erb: erb, locals: locals, aux_tables: aux_tables) end end end
Source
# File app/admin_common.rb, line 7 def adminui_show_table_format(context, table, format, erb: :table, locals: {}, aux_tables: []) halt 404, 'Not Found' if table.nil? case format when 'json' data = [] data << table.table_data unless table.table_data.nil? aux_tables.each do |aux_table| data << aux_table.table_data end content_type :json { context: context.to_h, table: data, status: table.status, status_message: table.status_message }.to_json when 'csv' data = table.to_csv aux_tables.each do |aux_table| data += "\n\n#{aux_table.to_csv}" end fname = "mrt-admin#{context.route.gsub('/', '-')}.#{Time.now.strftime('%Y%m%d-%H%M%S')}.csv" content_type 'text/csv', charset: 'utf-8' halt 200, { 'Content-Disposition' => "attachment; filename=\"#{fname}\"" }, data when 'text' data = table.to_csv aux_tables.each do |aux_table| data += "\n\n#{aux_table.to_csv}" end content_type :text, encoding: 'utf-8' halt 200, data else locals[:context] = context locals[:table] = table locals[:aux_tables] = aux_tables erb erb, :layout => :page_layout, :locals => locals end end