godmode 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +119 -0
- data/Rakefile +1 -0
- data/godmode.gemspec +23 -0
- data/lib/generators/godmode/USAGE +0 -0
- data/lib/generators/godmode/category_generator.rb +39 -0
- data/lib/generators/godmode/devise_generator.rb +0 -0
- data/lib/generators/godmode/env_generator.rb +16 -0
- data/lib/generators/godmode/flex_layout_generator.rb +18 -0
- data/lib/generators/godmode/fog_generator.rb +32 -0
- data/lib/generators/godmode/gallery_generator.rb +25 -0
- data/lib/generators/godmode/install_generator.rb +17 -0
- data/lib/generators/godmode/migration_helpers.rb +13 -0
- data/lib/generators/godmode/orm_helpers.rb +42 -0
- data/lib/generators/godmode/rails_admin_generator.rb +19 -0
- data/lib/generators/godmode/relation_generator.rb +0 -0
- data/lib/generators/godmode/scaffold_generator.rb +31 -0
- data/lib/generators/godmode/templates/category/ancestry/admin_config.rb +27 -0
- data/lib/generators/godmode/templates/category/ancestry/migration.rb +16 -0
- data/lib/generators/godmode/templates/category/ancestry/model.rb +12 -0
- data/lib/generators/godmode/templates/category/ancestry/rails_admin.rb +9 -0
- data/lib/generators/godmode/templates/category/awesome_nested_set/admin_config.rb +28 -0
- data/lib/generators/godmode/templates/category/awesome_nested_set/migration.rb +18 -0
- data/lib/generators/godmode/templates/category/awesome_nested_set/model.rb +12 -0
- data/lib/generators/godmode/templates/category/awesome_nested_set/rails_admin.rb +9 -0
- data/lib/generators/godmode/templates/env/.env +1 -0
- data/lib/generators/godmode/templates/flex_layout/columns_2.scss +23 -0
- data/lib/generators/godmode/templates/fog/initalizer.rb +9 -0
- data/lib/generators/godmode/templates/gallery_image/fog.rb +9 -0
- data/lib/generators/godmode/templates/gallery_image/image_uploader.rb +19 -0
- data/lib/generators/godmode/templates/rails_admin/en.yml +219 -0
- data/lib/generators/godmode/templates/rails_admin/initializer.rb +30 -0
- data/lib/generators/godmode/templates/scaffold/admin_config.rb +21 -0
- data/lib/generators/godmode/templates/scaffold/controller.rb +32 -0
- data/lib/generators/godmode/templates/scaffold/model.rb +10 -0
- data/lib/generators/godmode/uploader_generator.rb +0 -0
- data/lib/godmode.rb +5 -0
- data/lib/godmode/version.rb +3 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f76da6e2e3b5a2d35e7d0e6ecd355605806e7af
|
4
|
+
data.tar.gz: b2a7c19732f3d3085529500ab664df7a8e080e2f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa177b63d1c9a6f10e6cc5f39553d8d50181eb41ecc8c628fa4246a6c6fc489c334284624f275a158e350ac904d9292fa320ffc694cfdc82956fa38ac7bb64d3
|
7
|
+
data.tar.gz: 6c069e097aba715716dd09014240d1ff14a519f17ec5acf7059269a50e9b527272656e75f9532b1fe76c1f968bdcf776cae0bc00470253bf0cd3892f974510e0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 redCashion
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# Godmode
|
2
|
+
---
|
3
|
+
|
4
|
+
,/
|
5
|
+
,'/
|
6
|
+
,' /
|
7
|
+
,' /_____,
|
8
|
+
.'____ ,'
|
9
|
+
/ ,'
|
10
|
+
/ ,'
|
11
|
+
/,'
|
12
|
+
/'
|
13
|
+
|
14
|
+
|
15
|
+
GoDmoDe: A generator driven development
|
16
|
+
An application generation framework.
|
17
|
+
|
18
|
+
# Description
|
19
|
+
---
|
20
|
+
|
21
|
+
### You know what's annoying?
|
22
|
+
|
23
|
+
gdd make
|
24
|
+
gdd gem
|
25
|
+
gdd relate
|
26
|
+
|
27
|
+
Rewriting a user model for the 10th time, using a combination of copy and paste of old projects or just rewriting the code from memory. As developers I'm convinced that we are not doing enough to automate the code that makes up 80% of functionality for modern web apps. From scheduling, to categories, to social links, to images, to location, there are functionality and interactions that come up again, and again, and again, and again. So let's:
|
28
|
+
|
29
|
+
### write code to write your code!
|
30
|
+
|
31
|
+
#### Have respect for your time, for your client's money, and for your sanity: automate!
|
32
|
+
|
33
|
+
With this in mind, I've created an application generator using a constrained set of tools to enable great interoperability between pieces. The goal is to use interactive command line tools to create models with all of their related parts. For example:
|
34
|
+
|
35
|
+
### mang gen:user
|
36
|
+
|
37
|
+
* Models: user, role, user_roles
|
38
|
+
* Views: [Authbox](http://) angular.js widget
|
39
|
+
* Custom [devise](http://) controllers
|
40
|
+
* Emails sent through [sendgrid](http://)
|
41
|
+
* Admin
|
42
|
+
|
43
|
+
### mang gen:category
|
44
|
+
|
45
|
+
* Subcategory nesting using [awesome_nested_tree](http://)
|
46
|
+
* Category management in administration using [rails_admin_nestable](http://)
|
47
|
+
* Category breadcrumbs using [Zurb Foundation](http://)
|
48
|
+
|
49
|
+
### Follow
|
50
|
+
|
51
|
+
* Models: polymorphic Follow model
|
52
|
+
* Concerns: Followable
|
53
|
+
* Helpers: follow button
|
54
|
+
|
55
|
+
### GalleryImage
|
56
|
+
|
57
|
+
* Uploaders: carrierwave ImageUploader model
|
58
|
+
* Models: polymorphic GalleryImage model
|
59
|
+
* Views
|
60
|
+
* Form Helper for adding multiple images
|
61
|
+
* Fluidbox for viewing galleries
|
62
|
+
* Remote storage on S3 using Fog
|
63
|
+
* Admin
|
64
|
+
|
65
|
+
### Address
|
66
|
+
|
67
|
+
* Models: polymorphic Address model
|
68
|
+
* Concerns: Addressable
|
69
|
+
* Geolocation using Geo
|
70
|
+
* rails_admin_geo
|
71
|
+
|
72
|
+
### Layout
|
73
|
+
|
74
|
+
* flexbox driven css
|
75
|
+
|
76
|
+
### Social Buttons
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
# Documentation
|
82
|
+
---
|
83
|
+
|
84
|
+
## The Stack
|
85
|
+
|
86
|
+
| Purpose | Gem |
|
87
|
+
| ------------- |------------|
|
88
|
+
| Framework | [rails](https://github.com/rails/rails) |
|
89
|
+
| Database | [pg](https://bitbucket.org/ged/ruby-pg/wiki/Home) |
|
90
|
+
| User Auth | [devise](https://github.com/plataformatec/devise), [cancan](https://github.com/ryanb/cancan) |
|
91
|
+
| Views | angular.js, zurb foundation 5 |
|
92
|
+
| Controllers| [decent_exposure](https://github.com/voxdolo/decent_exposure)|
|
93
|
+
| Models | [squeel](https://github.com/activerecord-hackery/squeel), [pacecar](https://github.com/thoughtbot/pacecar) |
|
94
|
+
| Administration | [rails_admin](https://github.com/sferik/rails_admin) |
|
95
|
+
| Image Manipulation | [carrierwave](https://github.com/carrierwaveuploader/carrierwave), [fog](https://github.com/fog/fog) |
|
96
|
+
| Categories | [awesome_nested_set](https://github.com/collectiveidea/awesome_nested_set) |
|
97
|
+
| SMTP | Sendgrid |
|
98
|
+
| Geolocation | [geo](https://github.com/AppGeo/geo) |
|
99
|
+
| Testing | [rspec](https://github.com/rspec/rspec) |
|
100
|
+
| Debugging | [jazz_hands](https://github.com/nixme/jazz_hands), [better_errors](https://github.com/charliesome/better_errors), [quiet_assets](https://github.com/evrone/quiet_assets) |
|
101
|
+
|
102
|
+
|
103
|
+
## Usage
|
104
|
+
---
|
105
|
+
|
106
|
+
### mang new:project_name
|
107
|
+
|
108
|
+
### mang init
|
109
|
+
|
110
|
+
Will install missing gems
|
111
|
+
|
112
|
+
### mang scaffold:model_name
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
# Installation
|
117
|
+
---
|
118
|
+
|
119
|
+
$ gem install mang
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/godmode.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'godmode/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "godmode"
|
8
|
+
spec.version = Godmode::VERSION
|
9
|
+
spec.authors = ["Jeremy Smith"]
|
10
|
+
spec.email = ["jeremy@superplussed.com"]
|
11
|
+
spec.description = %q{A rails generator framework}
|
12
|
+
spec.summary = %q{A rails generator framework}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'generators/godmode/orm_helpers'
|
2
|
+
|
3
|
+
module Godmode
|
4
|
+
module Generators
|
5
|
+
class CategoryGenerator < Rails::Generators::Base
|
6
|
+
include Godmode::Generators::OrmHelpers
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
desc "Insert category model using awesome_nested_set."
|
11
|
+
|
12
|
+
desc "create category model using awesome_nested_set"
|
13
|
+
class_option "tree_gem", :type => :string, :default => 'awesome_nested_set'
|
14
|
+
|
15
|
+
desc "create admin interface using rails_admin"
|
16
|
+
class_option "admin", :type => :boolean, :default => true
|
17
|
+
|
18
|
+
def generate_templates
|
19
|
+
gem options.tree_gem
|
20
|
+
template "category/#{options.tree_gem}/model.rb", "app/models/category.rb"
|
21
|
+
migration "category/awesome_nested_set/migration.rb", "create_awesome_nested_set_category"
|
22
|
+
if options.admin
|
23
|
+
template "category/#{options.tree_gem}/rails_admin.rb", "config/initializers/rails_admin_#{options.tree_gem}.rb"
|
24
|
+
template "category/#{options.tree_gem}/admin_config.rb", "app/models/admin_config/category.rb"
|
25
|
+
if options.tree_gem == 'ancestry'
|
26
|
+
gem 'rails_admin_nestable'
|
27
|
+
elsif options.tree_gem == 'awesome_nested_set'
|
28
|
+
gem 'rails_admin_nested_set'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.next_migration_number(path)
|
34
|
+
@migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Godmode
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class EnvGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
desc "Insert css for flexbox column based layout."
|
7
|
+
def install
|
8
|
+
gem 'dotenv-rails', :groups => [:development, :test]
|
9
|
+
template "env/.env", "env"
|
10
|
+
var = ask "What is the environment variable?"
|
11
|
+
value = ask "What is the value?"
|
12
|
+
inject_into_file "env", "aaa"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Godmode
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class FlexLayoutGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc "Insert css for flexbox column based layout."
|
8
|
+
|
9
|
+
def update_application_css
|
10
|
+
inject_into_file 'app/assets/stylesheets/application.css.scss', " *= require flex_layout_2_columns\n", :after => "*= require_self\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_templates
|
14
|
+
template "flex_layout/columns_2.scss", "app/assets/stylesheets/flex_layout_2_columns.scss"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Godmode
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class FogGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :name, type: :string
|
7
|
+
|
8
|
+
desc "Include rails_admin file."
|
9
|
+
class_option "admin", :type => :boolean, :default => true
|
10
|
+
|
11
|
+
|
12
|
+
def generate_templates
|
13
|
+
template "scaffold/model.rb", "app/models/#{file_name}.rb"
|
14
|
+
if options.admin
|
15
|
+
template "scaffold/admin_config.rb", "app/models/admin_config/#{file_name}.rb"
|
16
|
+
end
|
17
|
+
template "scaffold/controller.rb", "app/controllers/#{file_name.pluralize}_controller.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def file_name
|
23
|
+
name.singularize.underscore
|
24
|
+
end
|
25
|
+
|
26
|
+
def class_name
|
27
|
+
name.singularize.camelize
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'generators/godmode/orm_helpers'
|
2
|
+
|
3
|
+
module Godmode
|
4
|
+
module Generators
|
5
|
+
class CategoryGenerator < Rails::Generators::Base
|
6
|
+
include Godmode::Generators::OrmHelpers
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
desc "Insert gallery_image model using carrierwave and fog."
|
11
|
+
|
12
|
+
def generate_templates
|
13
|
+
gem 'carrierwave'
|
14
|
+
gem 'fog'
|
15
|
+
gem 'rmagick'
|
16
|
+
generate "godmode:scaffold", "gallery_image"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.next_migration_number(path)
|
20
|
+
@migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/godmode/orm_helpers'
|
2
|
+
|
3
|
+
module Godmode
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
def all
|
8
|
+
generate "godmode:rails_admin", "install"
|
9
|
+
gem "pacecar"
|
10
|
+
gem "decent_exposure"
|
11
|
+
gem "squeel"
|
12
|
+
gem 'jazz_hands', group: "development"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Godmode
|
2
|
+
module Generators
|
3
|
+
module OrmHelpers
|
4
|
+
def needs_attr_accessible?
|
5
|
+
rails_3? && !strong_parameters_enabled?
|
6
|
+
end
|
7
|
+
|
8
|
+
def rails_3?
|
9
|
+
Rails::VERSION::MAJOR == 3
|
10
|
+
end
|
11
|
+
|
12
|
+
def strong_parameters_enabled?
|
13
|
+
defined?(ActionController::StrongParameters)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def migration src, dest
|
19
|
+
unless migration_exists? dest
|
20
|
+
migration_template src, "db/migrate/gdd_#{dest}.rb"
|
21
|
+
rake "db:migrate"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def model_exists?
|
26
|
+
File.exists?(File.join(destination_root, model_path))
|
27
|
+
end
|
28
|
+
|
29
|
+
def migration_exists?(name)
|
30
|
+
Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_gdd_#{name}.rb$/).first
|
31
|
+
end
|
32
|
+
|
33
|
+
def migration_path
|
34
|
+
@migration_path ||= File.join("db", "migrate")
|
35
|
+
end
|
36
|
+
|
37
|
+
def model_path
|
38
|
+
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Godmode
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class RailsAdminGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :name, type: :string
|
7
|
+
|
8
|
+
desc "Install RailsAdmin"
|
9
|
+
def install
|
10
|
+
gem "rails_admin"
|
11
|
+
gem "rails_admin_link_to_edit"
|
12
|
+
gem "rails_admin_toggleable"
|
13
|
+
template "rails_admin/initializer.rb", "config/initializers/rails_admin.rb"
|
14
|
+
template "rails_admin/en.yml", "config/locals/rails_admin.en.yml"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Godmode
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class ScaffoldGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :name, type: :string
|
7
|
+
|
8
|
+
desc "Include rails_admin file."
|
9
|
+
class_option "admin", :type => :boolean, :default => true
|
10
|
+
|
11
|
+
def generate_templates
|
12
|
+
template "scaffold/model.rb", "app/models/#{file_name}.rb"
|
13
|
+
if options.admin
|
14
|
+
template "scaffold/admin_config.rb", "app/models/admin_config/#{file_name}.rb"
|
15
|
+
end
|
16
|
+
template "scaffold/controller.rb", "app/controllers/#{file_name.pluralize}_controller.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def file_name
|
22
|
+
name.singularize.underscore
|
23
|
+
end
|
24
|
+
|
25
|
+
def class_name
|
26
|
+
name.singularize.camelize
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module AdminConfig::Category
|
2
|
+
def admin_block
|
3
|
+
Proc.new {
|
4
|
+
rails_admin do
|
5
|
+
nestable_tree({
|
6
|
+
position_field: :position,
|
7
|
+
max_depth: 5
|
8
|
+
})
|
9
|
+
list do
|
10
|
+
field :id, :link_to_edit do
|
11
|
+
sort_reverse true
|
12
|
+
end
|
13
|
+
field :name
|
14
|
+
end
|
15
|
+
edit do
|
16
|
+
field :name
|
17
|
+
end
|
18
|
+
show do
|
19
|
+
group "Category" do
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class GodmodeCreateAncestryCategory < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
drop_table :categories
|
5
|
+
create_table :categories do |t|
|
6
|
+
t.string :name
|
7
|
+
t.string :ancestry
|
8
|
+
t.integer :position
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :categories, :ancestry
|
13
|
+
add_index :categories, :position
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module AdminConfig::Category
|
2
|
+
def admin_block
|
3
|
+
Proc.new {
|
4
|
+
rails_admin do
|
5
|
+
nested_set({
|
6
|
+
max_depth: 5
|
7
|
+
})
|
8
|
+
list do
|
9
|
+
field :id, :link_to_edit do
|
10
|
+
sort_reverse true
|
11
|
+
end
|
12
|
+
field :name
|
13
|
+
field :parent
|
14
|
+
end
|
15
|
+
edit do
|
16
|
+
field :name
|
17
|
+
field :parent
|
18
|
+
end
|
19
|
+
show do
|
20
|
+
group "Category" do
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class GodmodeCreateAwesomeNestedSetCategory < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
drop_table :categories
|
5
|
+
create_table :categories do |t|
|
6
|
+
t.string :name
|
7
|
+
t.integer :parent_id
|
8
|
+
t.integer :lft
|
9
|
+
t.integer :rgt
|
10
|
+
t.integer :depth
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
add_index :categories, :parent_id
|
15
|
+
add_index :categories, :rgt
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
test=val
|
@@ -0,0 +1,23 @@
|
|
1
|
+
body {
|
2
|
+
display: flex;
|
3
|
+
min-height: 100vh;
|
4
|
+
flex-direction: column;
|
5
|
+
.flex-main {
|
6
|
+
display: flex;
|
7
|
+
flex: 1;
|
8
|
+
.flex-fixed-column {
|
9
|
+
flex: 0 0 300px;
|
10
|
+
order: -2;
|
11
|
+
}
|
12
|
+
.flex-seperator {
|
13
|
+
flex: 0 0 1px;
|
14
|
+
order: -1;
|
15
|
+
background: #333;
|
16
|
+
margin: 0 20px;
|
17
|
+
}
|
18
|
+
.flex-content {
|
19
|
+
width: 100%;
|
20
|
+
flex: 1;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
CarrierWave.configure do |config|
|
2
|
+
config.fog_credentials = {
|
3
|
+
:provider => 'AWS',
|
4
|
+
:aws_access_key_id => '<%= aws_access_key_id %>',
|
5
|
+
:aws_secret_access_key => '<%= aws_secret_access_key %>'
|
6
|
+
}
|
7
|
+
config.fog_directory = '<%= fog_directory %>'
|
8
|
+
config.fog_public = true
|
9
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
2
|
+
include CarrierWave::RMagick
|
3
|
+
include Sprockets::Rails::Helper
|
4
|
+
|
5
|
+
storage :fog
|
6
|
+
|
7
|
+
version :thumb do
|
8
|
+
process :resize_to_fit => [100, 100]
|
9
|
+
end
|
10
|
+
|
11
|
+
def store_dir
|
12
|
+
"uploads/#{class_name(model).to_s.underscore}/#{mounted_as}/#{model.id}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def class_name model
|
16
|
+
model.class.superclass.name == "ActiveRecord::Base" ? model.class : model.class.superclass
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,219 @@
|
|
1
|
+
en:
|
2
|
+
admin:
|
3
|
+
toggle:
|
4
|
+
disabled: 'Successfully toggled'
|
5
|
+
enabled: 'Successfully toggled'
|
6
|
+
error: 'There was an error'
|
7
|
+
home:
|
8
|
+
name: "need4more.com"
|
9
|
+
pagination:
|
10
|
+
previous: "« Prev"
|
11
|
+
next: "Next »"
|
12
|
+
truncate: "…"
|
13
|
+
|
14
|
+
misc:
|
15
|
+
filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
|
16
|
+
search: "Search"
|
17
|
+
filter: "Filter"
|
18
|
+
refresh: "Refresh"
|
19
|
+
show_all: "Show all"
|
20
|
+
add_filter: "Add filter"
|
21
|
+
bulk_menu_title: "Selected"
|
22
|
+
remove: "Remove"
|
23
|
+
add_new: "New"
|
24
|
+
chosen: "Chosen %{name}"
|
25
|
+
chose_all: "Choose all"
|
26
|
+
clear_all: "Clear all"
|
27
|
+
up: "Up"
|
28
|
+
down: "Down"
|
29
|
+
navigation: "Navigation"
|
30
|
+
navigation_static_label: "Links"
|
31
|
+
log_out: "Log out"
|
32
|
+
ago: "ago"
|
33
|
+
flash:
|
34
|
+
successful: "%{name} successfully %{action}"
|
35
|
+
error: "%{name} failed to be %{action}"
|
36
|
+
noaction: "No actions were taken"
|
37
|
+
model_not_found: "Model '%{model}' could not be found"
|
38
|
+
object_not_found: "%{model} with id '%{id}' could not be found"
|
39
|
+
table_headers:
|
40
|
+
model_name: "Model name"
|
41
|
+
last_used: "Last used"
|
42
|
+
records: "Records"
|
43
|
+
username: "User"
|
44
|
+
changes: "Changes"
|
45
|
+
created_at: "Date/Time"
|
46
|
+
item: "Item"
|
47
|
+
message: "Message"
|
48
|
+
actions:
|
49
|
+
scrape:
|
50
|
+
title: "Scrape %{model_label} '%{object_label}'"
|
51
|
+
menu: "Scrape"
|
52
|
+
breadcrumb: "Scrape"
|
53
|
+
link: "Scrape '%{object_label}'"
|
54
|
+
done: "scraped"
|
55
|
+
render_to_html:
|
56
|
+
title: "Render %{model_label} '%{object_label}'"
|
57
|
+
menu: "Render"
|
58
|
+
breadcrumb: "Render"
|
59
|
+
link: "Render"
|
60
|
+
bulk_link: "Render"
|
61
|
+
done: "Rendered"
|
62
|
+
multi_upload:
|
63
|
+
title: "Multi Upload %{model_label} '%{object_label}'"
|
64
|
+
menu: "MultiUpload"
|
65
|
+
breadcrumb: "MultiUpload"
|
66
|
+
link: "MultiUpload"
|
67
|
+
bulk_link: "MultiUpload"
|
68
|
+
done: "Uploaded"
|
69
|
+
dashboard:
|
70
|
+
title: "Dashboard"
|
71
|
+
menu: "Dashboard"
|
72
|
+
breadcrumb: "Dashboard"
|
73
|
+
reports:
|
74
|
+
title: "Reports"
|
75
|
+
menu: "Reports"
|
76
|
+
breadcrumb: "Reports"
|
77
|
+
calendar:
|
78
|
+
title: "Calendar"
|
79
|
+
menu: "Calendar"
|
80
|
+
breadcrumb: "Calendar"
|
81
|
+
advisor_tools:
|
82
|
+
title: "Advisor Tools"
|
83
|
+
menu: "Advisor Tools"
|
84
|
+
breadcrumb: "Advisor Tools"
|
85
|
+
links:
|
86
|
+
title: "Links"
|
87
|
+
menu: "Links"
|
88
|
+
breadcrumb: "Links"
|
89
|
+
index:
|
90
|
+
title: "List of %{model_label_plural}"
|
91
|
+
menu: "List"
|
92
|
+
breadcrumb: "%{model_label_plural}"
|
93
|
+
show:
|
94
|
+
title: "Details for %{model_label} '%{object_label}'"
|
95
|
+
menu: "Show"
|
96
|
+
breadcrumb: "%{object_label}"
|
97
|
+
show_in_app:
|
98
|
+
menu: "View on Site"
|
99
|
+
multi_uploaded:
|
100
|
+
title: "Multiple Upload for %{model_label}"
|
101
|
+
menu: "MultiUpload"
|
102
|
+
breadcrumb: "MultiUpload"
|
103
|
+
link: "Multi Upload"
|
104
|
+
done: "uploaded"
|
105
|
+
new:
|
106
|
+
title: "New %{model_label}"
|
107
|
+
menu: "New"
|
108
|
+
breadcrumb: "New"
|
109
|
+
link: "Add"
|
110
|
+
done: "created"
|
111
|
+
edit:
|
112
|
+
title: "Edit %{model_label} '%{object_label}'"
|
113
|
+
menu: "Edit"
|
114
|
+
breadcrumb: "Edit"
|
115
|
+
link: "Edit"
|
116
|
+
done: "updated"
|
117
|
+
delete:
|
118
|
+
title: "Delete %{model_label} '%{object_label}'"
|
119
|
+
menu: "Delete"
|
120
|
+
breadcrumb: "Delete"
|
121
|
+
link: "Delete '%{object_label}'"
|
122
|
+
done: "deleted"
|
123
|
+
withdraw:
|
124
|
+
title: "Withdraw '%{object_label}'"
|
125
|
+
menu: "Withdraw"
|
126
|
+
breadcrumb: "Withdraw"
|
127
|
+
link: "Withdraw '%{object_label}'"
|
128
|
+
done: "Withdrew"
|
129
|
+
resend:
|
130
|
+
title: "Resend '%{object_label}'"
|
131
|
+
menu: "Resend"
|
132
|
+
breadcrumb: "Resend"
|
133
|
+
link: "Resend '%{object_label}'"
|
134
|
+
done: "Resent"
|
135
|
+
create_notification:
|
136
|
+
title: "Create Notification for '%{object_label}'"
|
137
|
+
menu: "Create Notification"
|
138
|
+
breadcrumb: "Create Notification"
|
139
|
+
link: "Create Notification '%{object_label}'"
|
140
|
+
done: "Notification Created"
|
141
|
+
create_notification_batch:
|
142
|
+
title: "Create Notification Batch for '%{object_label}'"
|
143
|
+
menu: "Create Notification Batch"
|
144
|
+
breadcrumb: "Create Notification Batch"
|
145
|
+
link: "Create Notification Batch '%{object_label}'"
|
146
|
+
done: "Notification Batch Created"
|
147
|
+
reverse_charge:
|
148
|
+
title: "Reverse Charge '%{object_label}'"
|
149
|
+
menu: "Reverse Charge"
|
150
|
+
breadcrumb: "Reverse Charge"
|
151
|
+
link: "Reverse Charge '%{object_label}'"
|
152
|
+
done: "Charge Reversed"
|
153
|
+
switch_user:
|
154
|
+
title: "Switch User '%{object_label}'"
|
155
|
+
menu: "Switch User"
|
156
|
+
breadcrumb: "Switch User"
|
157
|
+
link: "Switch User '%{object_label}'"
|
158
|
+
done: "User Switched"
|
159
|
+
check_in:
|
160
|
+
title: "Check In '%{object_label}'"
|
161
|
+
menu: "Check In"
|
162
|
+
breadcrumb: "Check In"
|
163
|
+
link: "Check In '%{object_label}'"
|
164
|
+
done: "checked in"
|
165
|
+
bulk_delete:
|
166
|
+
title: "Delete %{model_label_plural}"
|
167
|
+
menu: "Multiple delete"
|
168
|
+
breadcrumb: "Multiple delete"
|
169
|
+
bulk_link: "Delete selected %{model_label_plural}"
|
170
|
+
export:
|
171
|
+
title: "Export %{model_label_plural}"
|
172
|
+
menu: "Export"
|
173
|
+
breadcrumb: "Export"
|
174
|
+
link: "Export"
|
175
|
+
bulk_link: "Export selected %{model_label_plural}"
|
176
|
+
done: "exported"
|
177
|
+
history_index:
|
178
|
+
title: "History for %{model_label_plural}"
|
179
|
+
menu: "History"
|
180
|
+
breadcrumb: "History"
|
181
|
+
history_show:
|
182
|
+
title: "History for %{model_label} '%{object_label}'"
|
183
|
+
menu: "History"
|
184
|
+
breadcrumb: "History"
|
185
|
+
form:
|
186
|
+
cancel: "Cancel"
|
187
|
+
basic_info: "Basic info"
|
188
|
+
required: "Required"
|
189
|
+
optional: "Optional"
|
190
|
+
one_char: "character"
|
191
|
+
char_length_up_to: "length up to"
|
192
|
+
char_length_of: "length of"
|
193
|
+
save: "Save"
|
194
|
+
save_and_add_another: "Save / Add"
|
195
|
+
save_and_edit: "Save / Edit"
|
196
|
+
all_of_the_following_related_items_will_be_deleted: "? The following related items may be deleted or orphaned:"
|
197
|
+
are_you_sure_you_want_to_delete_the_object: "Are you sure you want to delete this %{model_name}"
|
198
|
+
confirmation: "Yes, I'm sure"
|
199
|
+
bulk_delete: "The following objects will be deleted, which may delete or orphan some of their related dependencies:"
|
200
|
+
new_model: "%{name} (new)"
|
201
|
+
export:
|
202
|
+
confirmation: "Export to %{name}"
|
203
|
+
select: "Select fields to export"
|
204
|
+
fields_from: "Fields from %{name}"
|
205
|
+
fields_from_associated: "Fields from associated %{name}"
|
206
|
+
display: "Display %{name}: %{type}"
|
207
|
+
options_for: "Options for %{name}"
|
208
|
+
empty_value_for_associated_objects: "<empty>"
|
209
|
+
click_to_reverse_selection: 'Click to reverse selection'
|
210
|
+
csv:
|
211
|
+
header_for_root_methods: "%{name}" # 'model' is available
|
212
|
+
header_for_association_methods: "%{name} [%{association}]"
|
213
|
+
encoding_to: "Encode to"
|
214
|
+
encoding_to_help: "Choose output encoding. Leave empty to let current input encoding untouched: (%{name})"
|
215
|
+
skip_header: "No header"
|
216
|
+
skip_header_help: "Do not output a header (no fields description)"
|
217
|
+
default_col_sep: ","
|
218
|
+
col_sep: "Column separator"
|
219
|
+
col_sep_help: "Leave blank for default ('%{value}')" # value is default_col_sep
|
@@ -0,0 +1,30 @@
|
|
1
|
+
RailsAdmin.config do |config|
|
2
|
+
|
3
|
+
config.yell_for_non_accessible_fields = false
|
4
|
+
config.main_app_name = ['Admin']
|
5
|
+
config.main_app_name.push(Rails.env) unless Rails.env == "production"
|
6
|
+
config.current_user_method { current_user }
|
7
|
+
config.authorize_with :cancan
|
8
|
+
config.audit_with :history, User
|
9
|
+
config.total_columns_width = 1400
|
10
|
+
config.compact_show_view = false
|
11
|
+
|
12
|
+
config.actions do
|
13
|
+
config.actions do
|
14
|
+
dashboard do
|
15
|
+
statistics false
|
16
|
+
pjax false
|
17
|
+
end
|
18
|
+
index
|
19
|
+
show
|
20
|
+
edit
|
21
|
+
new
|
22
|
+
export
|
23
|
+
history_index
|
24
|
+
bulk_delete
|
25
|
+
# member actions
|
26
|
+
delete
|
27
|
+
toggle
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AdminConfig::<%= class_name %>
|
2
|
+
def admin_block
|
3
|
+
Proc.new {
|
4
|
+
rails_admin do
|
5
|
+
list do
|
6
|
+
field :id, :link_to_edit do
|
7
|
+
sort_reverse true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
edit do
|
11
|
+
end
|
12
|
+
show do
|
13
|
+
group "<%= class_name %>" do
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class <%= class_name.pluralize %>Controller < ApplicationController
|
2
|
+
expose(:<%= file_name %>, attributes: :<%= file_name %>_params)
|
3
|
+
expose(:<%= file_name.pluralize %>)
|
4
|
+
|
5
|
+
def create
|
6
|
+
if <%= file_name %>.save
|
7
|
+
redirect_to(<%= file_name %>)
|
8
|
+
else
|
9
|
+
render :new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
if <%= file_name %>.save
|
15
|
+
redirect_to(<%= file_name %>)
|
16
|
+
else
|
17
|
+
render :show
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy
|
22
|
+
<%= file_name %>.destroy
|
23
|
+
redirect_to <%= file_name.pluralize %>_path
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def <%= file_name %>_params
|
29
|
+
params.require(:<%= file_name %>).permit()
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
File without changes
|
data/lib/godmode.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: godmode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A rails generator framework
|
42
|
+
email:
|
43
|
+
- jeremy@superplussed.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- godmode.gemspec
|
54
|
+
- lib/generators/godmode/USAGE
|
55
|
+
- lib/generators/godmode/category_generator.rb
|
56
|
+
- lib/generators/godmode/devise_generator.rb
|
57
|
+
- lib/generators/godmode/env_generator.rb
|
58
|
+
- lib/generators/godmode/flex_layout_generator.rb
|
59
|
+
- lib/generators/godmode/fog_generator.rb
|
60
|
+
- lib/generators/godmode/gallery_generator.rb
|
61
|
+
- lib/generators/godmode/install_generator.rb
|
62
|
+
- lib/generators/godmode/migration_helpers.rb
|
63
|
+
- lib/generators/godmode/orm_helpers.rb
|
64
|
+
- lib/generators/godmode/rails_admin_generator.rb
|
65
|
+
- lib/generators/godmode/relation_generator.rb
|
66
|
+
- lib/generators/godmode/scaffold_generator.rb
|
67
|
+
- lib/generators/godmode/templates/category/ancestry/admin_config.rb
|
68
|
+
- lib/generators/godmode/templates/category/ancestry/migration.rb
|
69
|
+
- lib/generators/godmode/templates/category/ancestry/model.rb
|
70
|
+
- lib/generators/godmode/templates/category/ancestry/rails_admin.rb
|
71
|
+
- lib/generators/godmode/templates/category/awesome_nested_set/admin_config.rb
|
72
|
+
- lib/generators/godmode/templates/category/awesome_nested_set/migration.rb
|
73
|
+
- lib/generators/godmode/templates/category/awesome_nested_set/model.rb
|
74
|
+
- lib/generators/godmode/templates/category/awesome_nested_set/rails_admin.rb
|
75
|
+
- lib/generators/godmode/templates/env/.env
|
76
|
+
- lib/generators/godmode/templates/flex_layout/columns_2.scss
|
77
|
+
- lib/generators/godmode/templates/fog/initalizer.rb
|
78
|
+
- lib/generators/godmode/templates/gallery_image/fog.rb
|
79
|
+
- lib/generators/godmode/templates/gallery_image/image_uploader.rb
|
80
|
+
- lib/generators/godmode/templates/rails_admin/en.yml
|
81
|
+
- lib/generators/godmode/templates/rails_admin/initializer.rb
|
82
|
+
- lib/generators/godmode/templates/scaffold/admin_config.rb
|
83
|
+
- lib/generators/godmode/templates/scaffold/controller.rb
|
84
|
+
- lib/generators/godmode/templates/scaffold/model.rb
|
85
|
+
- lib/generators/godmode/uploader_generator.rb
|
86
|
+
- lib/godmode.rb
|
87
|
+
- lib/godmode/version.rb
|
88
|
+
homepage: ''
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: A rails generator framework
|
112
|
+
test_files: []
|