Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
whaleback
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
whaleback
Commits
c778e153
Commit
c778e153
authored
Nov 17, 2019
by
Ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add views generator
parent
de61bff9
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
74 additions
and
37 deletions
+74
-37
_detail.json.jbuilder
...erators/templates/views/attachments/_detail.json.jbuilder
+1
-0
_simple.json.jbuilder
...erators/templates/views/attachments/_simple.json.jbuilder
+1
-0
_single.json.jbuilder
...erators/templates/views/attachments/_single.json.jbuilder
+1
-0
index.json.jbuilder
...enerators/templates/views/attachments/index.json.jbuilder
+5
-0
show.json.jbuilder
...generators/templates/views/attachments/show.json.jbuilder
+1
-0
_detail.json.jbuilder
...nerators/templates/views/chunk_file/_detail.json.jbuilder
+1
-0
_simple.json.jbuilder
...nerators/templates/views/chunk_file/_simple.json.jbuilder
+1
-0
_single.json.jbuilder
...nerators/templates/views/chunk_file/_single.json.jbuilder
+4
-0
index.json.jbuilder
...generators/templates/views/chunk_file/index.json.jbuilder
+5
-0
show.json.jbuilder
lib/generators/templates/views/chunk_file/show.json.jbuilder
+1
-0
migrations_generator.rb
lib/generators/whaleback/migrations_generator.rb
+35
-2
views_generator.rb
lib/generators/whaleback/views_generator.rb
+14
-0
chunk_file.rb
lib/whaleback/chunk_file.rb
+4
-0
migrations_generator.rb
lib/whaleback/generators/migrations_generator.rb
+0
-35
No files found.
lib/generators/templates/views/attachments/_detail.json.jbuilder
0 → 100644
View file @
c778e153
json.partial! "attachments/single", attachment: attachment
lib/generators/templates/views/attachments/_simple.json.jbuilder
0 → 100644
View file @
c778e153
json.partial! "attachments/single", attachment: attachment
lib/generators/templates/views/attachments/_single.json.jbuilder
0 → 100644
View file @
c778e153
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
lib/generators/templates/views/attachments/index.json.jbuilder
0 → 100644
View file @
c778e153
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
lib/generators/templates/views/attachments/show.json.jbuilder
0 → 100644
View file @
c778e153
json.partial! "attachments/detail", attachment: @attachment
lib/generators/templates/views/chunk_file/_detail.json.jbuilder
0 → 100644
View file @
c778e153
json.partial! "chunk_file/single", chunk_file: chunk_file
lib/generators/templates/views/chunk_file/_simple.json.jbuilder
0 → 100644
View file @
c778e153
json.partial! "chunk_file/single", chunk_file: chunk_file
lib/generators/templates/views/chunk_file/_single.json.jbuilder
0 → 100644
View file @
c778e153
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
lib/generators/templates/views/chunk_file/index.json.jbuilder
0 → 100644
View file @
c778e153
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
lib/generators/templates/views/chunk_file/show.json.jbuilder
0 → 100644
View file @
c778e153
json.partial! "chunk_file/detail", chunk_file: @chunk_file
lib/generators/whaleback/migrations_generator.rb
View file @
c778e153
require
'whaleback/generators/migrations_generator'
\ No newline at end of file
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
lib/generators/whaleback/views_generator.rb
0 → 100644
View file @
c778e153
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
lib/whaleback/chunk_file.rb
View file @
c778e153
...
...
@@ -21,6 +21,10 @@ module Whaleback
after_save
:write_file
after_destroy
:destroy_file
def
attachment
media
end
def
folder
File
.
join
(
ChunkFile
::
LocalPath
,
identifier
)
end
...
...
lib/whaleback/generators/migrations_generator.rb
deleted
100644 → 0
View file @
de61bff9
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment