Commit c778e153 by Ivan Lan

Add views generator

parent de61bff9
json.partial! "attachments/single", attachment: attachment
json.partial! "attachments/single", attachment: attachment
json.extract! attachment, :id, :created_at, :updated_at, :file_file_name, :file_content_type, :file_file_size, :file_updated_at, :type, :creator_type, :creator_id, :url, :creator_name
json.current_page @attachments.current_page
json.total_pages @attachments.total_pages
json.total_count @attachments.count
json.attachments @attachments, partial: 'attachments/simple', as: :attachment
json.partial! "attachments/detail", attachment: @attachment
json.partial! "chunk_file/single", chunk_file: chunk_file
json.partial! "chunk_file/single", chunk_file: chunk_file
json.extract! chunk_file, :id, :created_at, :updated_at, :chunk_number, :chunk_size, :current_chunk_size, :total_size, :identifier, :filename, :total_chunks
if chunk_file.attachment
json.attachment chunk_file.attachment, partial: 'attachments/single', as: :attachment
end
json.current_page @chunk_files.current_page
json.total_pages @chunk_files.total_pages
json.total_count @chunk_files.count
json.chunk_files @chunk_files, partial: 'chunk_file/simple', as: :chunk_file
json.partial! "chunk_file/detail", chunk_file: @chunk_file
require 'whaleback/generators/migrations_generator' require 'rails/generators/migration'
\ No newline at end of file
module Whaleback
module Generators
class MigrationsGenerator < Rails::Generators::Base
include Rails::Generators::Migration
desc 'Copy whaleback migrations to your application.'
def self.next_migration_number(dir)
sleep 1
Time.now.utc.strftime("%Y%m%d%H%M%S")
end
source_root File.expand_path("../../../../db/migrate", __FILE__)
def copy_migrations
# Use sort() to order the migrations by seq
# Use [2..-1] to delete the seq
Dir[ File.join(self.class.source_root, '*.rb') ].sort.each { |f|
copy_migration File.basename(f, '.rb')
}
end
protected
def copy_migration(filename)
if self.class.migration_exists?("db/migrate", "#{filename[2..-1]}")
say_status("skipped", "Migration #{filename[2..-1]} already exists")
else
migration_template "#{filename}.rb", "db/migrate/#{filename[2..-1]}.rb"
end
end
end
end
end
module Whaleback
module Generators
class ViewsGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates/views", __FILE__)
desc "Copy whaleback example views to your application."
# hide!
def copy_views
directory self.class.source_root, 'app/views/'
end
end
end
end
...@@ -21,6 +21,10 @@ module Whaleback ...@@ -21,6 +21,10 @@ module Whaleback
after_save :write_file after_save :write_file
after_destroy :destroy_file after_destroy :destroy_file
def attachment
media
end
def folder def folder
File.join(ChunkFile::LocalPath, identifier) File.join(ChunkFile::LocalPath, identifier)
end end
......
require 'rails/generators/migration'
module Whaleback
module Generators
class MigrationsGenerator < Rails::Generators::Base
include Rails::Generators::Migration
desc 'Copy whaleback migrations to your application.'
def self.next_migration_number(dir)
sleep 1
Time.now.utc.strftime("%Y%m%d%H%M%S")
end
source_root File.expand_path("../../../../db/migrate", __FILE__)
def copy_migrations
# Use sort() to order the migrations by seq
# Use [2..-1] to delete the seq
Dir[ File.join(self.class.source_root, '*.rb') ].sort.each { |f|
copy_migration File.basename(f, '.rb')
}
end
protected
def copy_migration(filename)
if self.class.migration_exists?("db/migrate", "#{filename[2..-1]}")
say_status("skipped", "Migration #{filename[2..-1]} already exists")
else
migration_template "#{filename}.rb", "db/migrate/#{filename[2..-1]}.rb"
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment