enjoy_cms 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +5 -0
  7. data/Gemfile.lock +249 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +137 -0
  10. data/Rakefile +1 -0
  11. data/app/assets/javascripts/enjoy_cms.coffee +6 -0
  12. data/app/assets/javascripts/enjoy_cms/flash.js.coffee +3 -0
  13. data/app/assets/javascripts/enjoy_cms/map.js.coffee +22 -0
  14. data/app/assets/javascripts/head.load.js +707 -0
  15. data/app/assets/javascripts/jquery.placeholder.js +157 -0
  16. data/app/assets/stylesheets/enjoy_cms.sass +5 -0
  17. data/app/assets/stylesheets/enjoy_cms/flash.sass +63 -0
  18. data/app/assets/stylesheets/enjoy_cms/normalize.scss +406 -0
  19. data/app/assets/stylesheets/enjoy_cms/powered.sass +18 -0
  20. data/app/controllers/concerns/enjoy/errors.rb +93 -0
  21. data/app/controllers/concerns/enjoy/fancybox.rb +14 -0
  22. data/app/controllers/concerns/enjoy/localizeable.rb +33 -0
  23. data/app/controllers/concerns/enjoy/nav_menu.rb +64 -0
  24. data/app/controllers/concerns/enjoy/no_cache.rb +12 -0
  25. data/app/controllers/concerns/enjoy/seo_pages.rb +83 -0
  26. data/app/controllers/enjoy/contacts_controller.rb +5 -0
  27. data/app/controllers/enjoy/home_controller.rb +6 -0
  28. data/app/controllers/enjoy/news_controller.rb +5 -0
  29. data/app/controllers/enjoy/pages_controller.rb +5 -0
  30. data/app/controllers/enjoy/search_controller.rb +6 -0
  31. data/app/helpers/enjoy/gzip_helper.rb +27 -0
  32. data/app/helpers/enjoy/powered_helper.rb +12 -0
  33. data/app/mailers/enjoy/contact_mailer.rb +17 -0
  34. data/app/models/concerns/enjoy/boolean_field.rb +17 -0
  35. data/app/models/concerns/enjoy/enableable.rb +8 -0
  36. data/app/models/concerns/enjoy/geocodeable.rb +4 -0
  37. data/app/models/concerns/enjoy/mappable.rb +95 -0
  38. data/app/models/concerns/enjoy/mongoid_paperclip.rb +37 -0
  39. data/app/models/concerns/enjoy/seoable.rb +36 -0
  40. data/app/models/concerns/enjoy/sitemap_data.rb +23 -0
  41. data/app/models/concerns/enjoy/sort_field.rb +20 -0
  42. data/app/models/concerns/enjoy/sortable.rb +8 -0
  43. data/app/models/enjoy/contact_message.rb +12 -0
  44. data/app/models/enjoy/embedded_element.rb +15 -0
  45. data/app/models/enjoy/embedded_gallery_image.rb +15 -0
  46. data/app/models/enjoy/gallery.rb +10 -0
  47. data/app/models/enjoy/gallery_image.rb +10 -0
  48. data/app/models/enjoy/menu.rb +12 -0
  49. data/app/models/enjoy/news.rb +12 -0
  50. data/app/models/enjoy/page.rb +12 -0
  51. data/app/models/enjoy/seo.rb +13 -0
  52. data/app/views/blocks/_favicon.html.slim +21 -0
  53. data/app/views/blocks/_footer.html.slim +1 -0
  54. data/app/views/blocks/_seo_block.html.slim +18 -0
  55. data/app/views/blocks/_seo_block_with_obj.html.slim +27 -0
  56. data/app/views/devise/registrations/edit.html.slim +21 -0
  57. data/app/views/devise/registrations/new.html.slim +21 -0
  58. data/app/views/devise/sessions/new.html.slim +22 -0
  59. data/app/views/devise/shared/_links.html.slim +11 -0
  60. data/app/views/enjoy/contact_mailer/new_message_email.html.slim +15 -0
  61. data/app/views/enjoy/contacts/index.html.slim +10 -0
  62. data/app/views/enjoy/contacts/new.html.slim +10 -0
  63. data/app/views/enjoy/contacts/sent.html.slim +4 -0
  64. data/app/views/enjoy/home/index.html.slim +1 -0
  65. data/app/views/enjoy/news/index.html.slim +9 -0
  66. data/app/views/enjoy/news/show.html.slim +8 -0
  67. data/app/views/enjoy/pages/show.html.slim +1 -0
  68. data/app/views/enjoy/search/index.html.slim +19 -0
  69. data/app/views/errors/_base.html.slim +3 -0
  70. data/app/views/errors/error_403.html.slim +1 -0
  71. data/app/views/errors/error_404.html.slim +1 -0
  72. data/app/views/errors/error_500.html.slim +1 -0
  73. data/app/views/layouts/application.html.slim +25 -0
  74. data/app/views/rails_admin/main/_check_boxes.html.slim +27 -0
  75. data/app/views/rails_admin/main/_enum_check_boxes.html.slim +5 -0
  76. data/app/views/rails_admin/main/_enum_radio_buttons.html.slim +5 -0
  77. data/app/views/rails_admin/main/_form_raw.html.slim +1 -0
  78. data/app/views/shared/_admin_link.html.slim +3 -0
  79. data/app/views/shared/_messages.html.slim +7 -0
  80. data/app/views/shared/_meta.html.slim +19 -0
  81. data/app/views/shared/_obj.html.slim +21 -0
  82. data/app/views/shared/_og.html.slim +4 -0
  83. data/app/views/simple_captcha/_simple_captcha.html.slim +12 -0
  84. data/config/initializers/simple_captcha.rb +29 -0
  85. data/config/locales/en.enjoy.yml +29 -0
  86. data/config/locales/en.enjoy_admin.yml +6 -0
  87. data/config/locales/ru.cancan.yml +4 -0
  88. data/config/locales/ru.devise.yml +65 -0
  89. data/config/locales/ru.enjoy.yml +39 -0
  90. data/config/locales/ru.enjoy_admin.yml +6 -0
  91. data/config/locales/ru.kaminari.yml +17 -0
  92. data/config/locales/ru.models.yml +103 -0
  93. data/config/locales/ru.mongoid.yml +450 -0
  94. data/config/locales/ru.rails_admin.yml +148 -0
  95. data/config/locales/ru.simple_captcha.yml +3 -0
  96. data/config/locales/ru.simple_form.yml +9 -0
  97. data/config/routes.rb +14 -0
  98. data/enjoy_cms.gemspec +53 -0
  99. data/lib/enjoy/admin.rb +350 -0
  100. data/lib/enjoy/admin/contact_message.rb +36 -0
  101. data/lib/enjoy/admin/embedded_element.rb +11 -0
  102. data/lib/enjoy/admin/embedded_gallery_image.rb +15 -0
  103. data/lib/enjoy/admin/gallery.rb +20 -0
  104. data/lib/enjoy/admin/gallery_image.rb +18 -0
  105. data/lib/enjoy/admin/menu.rb +27 -0
  106. data/lib/enjoy/admin/news.rb +57 -0
  107. data/lib/enjoy/admin/page.rb +81 -0
  108. data/lib/enjoy/admin/seo.rb +17 -0
  109. data/lib/enjoy/configuration.rb +73 -0
  110. data/lib/enjoy/controller.rb +31 -0
  111. data/lib/enjoy/controllers/contacts.rb +70 -0
  112. data/lib/enjoy/controllers/news.rb +36 -0
  113. data/lib/enjoy/controllers/pages.rb +22 -0
  114. data/lib/enjoy/controllers/search.rb +62 -0
  115. data/lib/enjoy/elastic_search.rb +31 -0
  116. data/lib/enjoy/engine.rb +46 -0
  117. data/lib/enjoy/migration.rb +34 -0
  118. data/lib/enjoy/model.rb +22 -0
  119. data/lib/enjoy/models/active_record/contact_message.rb +14 -0
  120. data/lib/enjoy/models/active_record/menu.rb +17 -0
  121. data/lib/enjoy/models/active_record/news.rb +26 -0
  122. data/lib/enjoy/models/active_record/page.rb +20 -0
  123. data/lib/enjoy/models/active_record/seo.rb +17 -0
  124. data/lib/enjoy/models/contact_message.rb +37 -0
  125. data/lib/enjoy/models/embedded_element.rb +12 -0
  126. data/lib/enjoy/models/embedded_gallery_image.rb +16 -0
  127. data/lib/enjoy/models/gallery.rb +29 -0
  128. data/lib/enjoy/models/gallery_image.rb +23 -0
  129. data/lib/enjoy/models/menu.rb +28 -0
  130. data/lib/enjoy/models/mongoid/contact_message.rb +20 -0
  131. data/lib/enjoy/models/mongoid/embedded_element.rb +13 -0
  132. data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +19 -0
  133. data/lib/enjoy/models/mongoid/gallery.rb +23 -0
  134. data/lib/enjoy/models/mongoid/gallery_image.rb +21 -0
  135. data/lib/enjoy/models/mongoid/menu.rb +15 -0
  136. data/lib/enjoy/models/mongoid/news.rb +29 -0
  137. data/lib/enjoy/models/mongoid/page.rb +25 -0
  138. data/lib/enjoy/models/mongoid/seo.rb +28 -0
  139. data/lib/enjoy/models/news.rb +58 -0
  140. data/lib/enjoy/models/page.rb +90 -0
  141. data/lib/enjoy/models/seo.rb +22 -0
  142. data/lib/enjoy/patch.rb +58 -0
  143. data/lib/enjoy/rails_admin_menu.rb +145 -0
  144. data/lib/enjoy/simple_form_patch.rb +12 -0
  145. data/lib/enjoy/tasks.rb +13 -0
  146. data/lib/enjoy/version.rb +3 -0
  147. data/lib/enjoy_cms.rb +109 -0
  148. data/lib/filename_to_slug.rb +34 -0
  149. data/lib/generators/enjoy/ability_generator.rb +14 -0
  150. data/lib/generators/enjoy/admin_generator.rb +21 -0
  151. data/lib/generators/enjoy/capify_generator.rb +39 -0
  152. data/lib/generators/enjoy/layout_generator.rb +14 -0
  153. data/lib/generators/enjoy/migration_generator.rb +18 -0
  154. data/lib/generators/enjoy/templates/Capfile +17 -0
  155. data/lib/generators/enjoy/templates/ability.erb +26 -0
  156. data/lib/generators/enjoy/templates/admin.erb +89 -0
  157. data/lib/generators/enjoy/templates/deploy.erb +47 -0
  158. data/lib/generators/enjoy/templates/dl.erb +30 -0
  159. data/lib/generators/enjoy/templates/migration_contact_messages.rb +15 -0
  160. data/lib/generators/enjoy/templates/migration_news.rb +26 -0
  161. data/lib/generators/enjoy/templates/migration_pages.rb +45 -0
  162. data/lib/generators/enjoy/templates/migration_seos.rb +14 -0
  163. data/lib/generators/enjoy/templates/production.erb +8 -0
  164. data/lib/generators/enjoy/templates/unicorn.erb +66 -0
  165. data/lib/generators/enjoy/utils.rb +21 -0
  166. data/lib/manual_slug.rb +10 -0
  167. data/lib/manual_slug/active_record.rb +32 -0
  168. data/lib/manual_slug/mongoid.rb +36 -0
  169. data/lib/rails_admin/custom_show_in_app.rb +43 -0
  170. data/release.sh +13 -0
  171. data/template.rb +824 -0
  172. metadata +579 -0
@@ -0,0 +1,145 @@
1
+ module RailsAdmin
2
+ module Config
3
+ module Fields
4
+ module Types
5
+ class Menu < RailsAdmin::Config::Fields::Base
6
+ # Register field type for the type loader
7
+ RailsAdmin::Config::Fields::Types::register(self)
8
+ include RailsAdmin::Engine.routes.url_helpers
9
+
10
+ register_instance_option :pretty_value do
11
+ obj = bindings[:object]
12
+ ret = []
13
+ menus = Rails.cache.fetch 'menus', expires_in: 10.minutes do
14
+ if Enjoy.mongoid?
15
+ ::Menu.all.map { |m| {id: m.id.to_s, name: m.name } }
16
+ else
17
+ ::Menu.all.map { |m| {id: m.id, name: m.name } }
18
+ end
19
+ end
20
+ menus.each do |m|
21
+ if Enjoy.mongoid?
22
+ on = obj.menu_ids.include?(BSON::ObjectId.from_string(m[:id]))
23
+ else
24
+ on = obj.menu_ids.include?(m[:id].to_i)
25
+ end
26
+ ret << bindings[:view].link_to(
27
+ m[:name],
28
+ bindings[:view].toggle_menu_path(model_name: @abstract_model, id: obj.id, menu: m[:id], on: !on),
29
+ #method: :post,
30
+ title: m[:name],
31
+ class: "btn btn-mini #{on ? "btn-success" : "btn-danger"}",
32
+ style: 'margin-bottom: 5px;',
33
+ onclick: 'var $t = $(this); $.ajax({type: "POST", url: $t.attr("href"), data: {ajax:true}, success: function(r) { $t.attr("href", r.href); $t.attr("class", r.class); }, error: function(e) { alert(e.responseText); }}); return false;'
34
+ )
35
+ end
36
+ ('<div style="white-space: normal;">' + ret.join(' ') + '</div>').html_safe
37
+ end
38
+
39
+ register_instance_option :formatted_value do
40
+ pretty_value
41
+ end
42
+
43
+ register_instance_option :export_value do
44
+ nil
45
+ end
46
+
47
+ register_instance_option :partial do
48
+ :form_raw
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ module RailsAdmin
57
+ module Config
58
+ module Actions
59
+ class ToggleMenu < Base
60
+ RailsAdmin::Config::Actions.register(self)
61
+
62
+ # Is the action acting on the root level (Example: /admin/contact)
63
+ register_instance_option :root? do
64
+ false
65
+ end
66
+
67
+ register_instance_option :collection? do
68
+ false
69
+ end
70
+
71
+ # Is the action on an object scope (Example: /admin/team/1/edit)
72
+ register_instance_option :member? do
73
+ true
74
+ end
75
+
76
+ register_instance_option :controller do
77
+ proc do
78
+ ajax_link = Proc.new do |am, obj, menu, on|
79
+ render json: {
80
+ href: toggle_menu_path(model_name: am, id: obj.id, menu: menu.id, on: !on),
81
+ class: "btn btn-mini #{on ? "btn-success" : "btn-danger"}",
82
+ }
83
+ end
84
+ if params['id'].present?
85
+ begin
86
+ @object = @abstract_model.model.find(params['id'])
87
+ @menu = ::Menu.find(params[:menu])
88
+ if params[:on] == 'true'
89
+ @object.menus << @menu
90
+ else
91
+ @object.menus.delete(@menu)
92
+ end
93
+
94
+ if @object.save
95
+ if params['ajax'].present?
96
+ if params[:on] == 'true'
97
+ ajax_link.call(@abstract_model, @object, @menu, true)
98
+ else
99
+ ajax_link.call(@abstract_model, @object, @menu, false)
100
+ end
101
+ else
102
+ if params[:on] == 'true'
103
+ flash[:success] = I18n.t('rs.m.enabled', menu: @menu.name)
104
+ else
105
+ flash[:success] = I18n.t('rs.m.disabled', menu: @menu.name)
106
+ end
107
+ end
108
+ else
109
+ if params['ajax'].present?
110
+ render text: @object.errors.full_messages.join(', '), layout: false, status: 422
111
+ else
112
+ flash[:error] = @object.errors.full_messages.join(', ')
113
+ end
114
+ end
115
+ rescue Exception => e
116
+ if params['ajax'].present?
117
+ render text: I18n.t('rs.m.error', err: e.to_s), status: 422
118
+ else
119
+ flash[:error] = I18n.t('rs.m.error', err: e.to_s)
120
+ end
121
+ end
122
+ else
123
+ if params['ajax'].present?
124
+ render text: I18n.t('rs.m.no_id'), status: 422
125
+ else
126
+ flash[:error] = I18n.t('rs.m.no_id')
127
+ end
128
+
129
+ end
130
+
131
+ redirect_to :back unless params['ajax'].present?
132
+ end
133
+ end
134
+
135
+ register_instance_option :link_icon do
136
+ 'icon-move'
137
+ end
138
+
139
+ register_instance_option :http_methods do
140
+ [:post]
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,12 @@
1
+ # https://github.com/rs-pro/russian/blob/master/lib/russian/active_model_ext/custom_error_message.rb
2
+ require 'simple_form/components/errors'
3
+ module SimpleForm
4
+ module Components
5
+ module Errors
6
+ protected
7
+ def errors_on_attribute
8
+ object.errors[attribute_name].map {|m| m.sub(/^\^/, '')}
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # require this file to load the tasks
2
+ require 'rake'
3
+
4
+ # Require generator at runtime. If we don't do this the ActionView helpers are included
5
+ # before the Rails environment can be loaded by other Rake tasks, which causes problems
6
+ # for those tasks when rendering using ActionView.
7
+ namespace :rs do
8
+ # Require generator only. When installed as a plugin the require will fail, so in
9
+ # that case, load the environment first.
10
+ task :require do
11
+ Rake::Task['environment'].invoke
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Enjoy
2
+ VERSION = "0.1.0.beta1"
3
+ end
data/lib/enjoy_cms.rb ADDED
@@ -0,0 +1,109 @@
1
+ unless defined?(Enjoy) && Enjoy.respond_to?(:orm) && [:active_record, :mongoid].include?(Enjoy.orm)
2
+ puts "please use Enjoy_mongoid or Enjoy_activerecord and not enjoy directly"
3
+ exit 1
4
+ end
5
+
6
+ require 'enjoy/version'
7
+ require 'devise'
8
+
9
+ require 'simple_form'
10
+ require 'enjoy/simple_form_patch'
11
+
12
+ require 'glebtv-simple_captcha'
13
+ require 'validates_email_format_of'
14
+ require 'smart_excerpt'
15
+ require 'filename_to_slug'
16
+ require 'rails_admin'
17
+ require 'rails_admin_nested_set'
18
+ require 'rails_admin_toggleable'
19
+ # require 'rails_admin_settings'
20
+
21
+ require 'x-real-ip'
22
+
23
+ require 'ckeditor'
24
+
25
+ require 'sitemap_generator'
26
+ require 'kaminari'
27
+ require 'addressable/uri'
28
+ require 'turbolinks'
29
+ require 'simple-navigation'
30
+ require 'ack_rails_admin_jcrop'
31
+
32
+ # require 'enjoy/seo_helpers'
33
+ require 'enjoy/configuration'
34
+ require 'enjoy/patch'
35
+ require 'enjoy/admin'
36
+ require 'enjoy/elastic_search'
37
+ require 'enjoy/model'
38
+ require 'enjoy/rails_admin_menu'
39
+ require 'enjoy/engine'
40
+ require 'enjoy/controller'
41
+
42
+ require 'manual_slug'
43
+
44
+
45
+ module Enjoy
46
+ class << self
47
+ def mongoid?
48
+ Enjoy.orm == :mongoid
49
+ end
50
+ def active_record?
51
+ Enjoy.orm == :active_record
52
+ end
53
+ def model_namespace
54
+ "Enjoy::Models::#{Enjoy.orm.to_s.camelize}"
55
+ end
56
+ def orm_specific(name)
57
+ "#{model_namespace}::#{name}".constantize
58
+ end
59
+ end
60
+
61
+ autoload :Migration, 'enjoy/migration'
62
+
63
+ # module Mongoid
64
+ # autoload :Paperclip 'enjoy/mongoid/paperlcip'
65
+ # end
66
+
67
+ module Models
68
+ autoload :Seo, 'enjoy/models/seo'
69
+ autoload :Menu, 'enjoy/models/menu'
70
+ autoload :Page, 'enjoy/models/page'
71
+ autoload :News, 'enjoy/models/news'
72
+ autoload :ContactMessage, 'enjoy/models/contact_message'
73
+
74
+ autoload :Enjoy, 'enjoy/models/embedded_element'
75
+
76
+ autoload :EmbeddedGalleryImage, 'enjoy/models/embedded_gallery_image'
77
+ autoload :GalleryImage, 'enjoy/models/gallery_image'
78
+ autoload :Gallery, 'enjoy/models/gallery'
79
+
80
+ module Mongoid
81
+ autoload :Seo, 'enjoy/models/mongoid/seo'
82
+ autoload :Menu, 'enjoy/models/mongoid/menu'
83
+ autoload :Page, 'enjoy/models/mongoid/page'
84
+ autoload :News, 'enjoy/models/mongoid/news'
85
+ autoload :ContactMessage, 'enjoy/models/mongoid/contact_message'
86
+
87
+ autoload :Enjoy, 'enjoy/models/mongoid/embedded_element'
88
+
89
+ autoload :EmbeddedGalleryImage, 'enjoy/models/mongoid/embedded_gallery_image'
90
+ autoload :GalleryImage, 'enjoy/models/mongoid/gallery_image'
91
+ autoload :Gallery, 'enjoy/models/mongoid/gallery'
92
+ end
93
+
94
+ module ActiveRecord
95
+ autoload :Seo, 'enjoy/models/active_record/seo'
96
+ autoload :Menu, 'enjoy/models/active_record/menu'
97
+ autoload :Page, 'enjoy/models/active_record/page'
98
+ autoload :News, 'enjoy/models/active_record/news'
99
+ autoload :ContactMessage, 'enjoy/models/active_record/contact_message'
100
+ end
101
+ end
102
+
103
+ module Controllers
104
+ autoload :Contacts, 'enjoy/controllers/contacts'
105
+ autoload :News, 'enjoy/controllers/news'
106
+ autoload :Pages, 'enjoy/controllers/pages'
107
+ autoload :Search, 'enjoy/controllers/search'
108
+ end
109
+ end
@@ -0,0 +1,34 @@
1
+ require 'stringex'
2
+ require 'digest/md5'
3
+
4
+ class String
5
+ def filename_to_slug
6
+ s = self.to_url
7
+ if s.blank?
8
+ return Digest::MD5.hexdigest(self)
9
+ end
10
+ s
11
+ end
12
+ end
13
+
14
+ module FilenameToSlug
15
+ extend ActiveSupport::Concern
16
+ included do
17
+ before_post_process :filename_to_slug
18
+ end
19
+
20
+ def filename_to_slug
21
+ if self.class.attachment_definitions
22
+ self.class.attachment_definitions.each do |k,v|
23
+ if self.send(k).file?
24
+ full_file_name = self.send("#{k}_file_name")
25
+ extension = File.extname(full_file_name)[1..-1]
26
+ file_name = full_file_name[0..full_file_name.size-extension.size-1]
27
+ self.send("#{k}").instance_write(:file_name, "#{file_name.filename_to_slug}.#{extension.filename_to_slug}")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+
@@ -0,0 +1,14 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module Enjoy
5
+ class AbilityGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+ include Generators::Utils::InstanceMethods
8
+
9
+ desc 'Enjoy CanCan Ability config generator'
10
+ def ability
11
+ template 'ability.erb', 'app/models/ability.rb'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ # shamelessly stolen from https://github.com/sferik/rails_admin/blob/master/lib/generators/rails_admin/utils.rb
2
+
3
+ require 'rails/generators'
4
+ require File.expand_path('../utils', __FILE__)
5
+
6
+ module Enjoy
7
+ class AdminGenerator < Rails::Generators::Base
8
+ source_root File.expand_path('../templates', __FILE__)
9
+ include Generators::Utils::InstanceMethods
10
+
11
+ #argument :_namespace, type: :string, required: false, desc: 'RailsAdmin url namespace'
12
+ desc 'Enjoy RailsAdmin config generator'
13
+
14
+ def install
15
+ #namespace = ask_for('Where do you want to mount rails_admin?', 'admin', _namespace)
16
+ namespace = 'admin'
17
+ route("mount RailsAdmin::Engine => '/#{namespace}', as: 'rails_admin'")
18
+ template 'admin.erb', 'config/initializers/rails_admin.rb'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,39 @@
1
+ require 'rails/generators'
2
+
3
+ module Enjoy
4
+ class CapifyGenerator < Rails::Generators::Base
5
+ argument :kind, type: :string
6
+ argument :port, type: :string
7
+ argument :domain, type: :string
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+
11
+ def app_name
12
+ Rails.application.class.name.split("::")[0]
13
+ end
14
+
15
+ def deploy_to
16
+ if kind == 'data'
17
+ "/data/#{app_name.downcase}/app"
18
+ else
19
+ "/home/#{app_name.downcase}/www/#{app_name.downcase}"
20
+ end
21
+ end
22
+ def tmp_path
23
+ if kind == 'data'
24
+ "/data/#{app_name.downcase}/tmp_dump"
25
+ else
26
+ "/home/#{app_name.downcase}/www/#{app_name.downcase}/tmp_dump"
27
+ end
28
+ end
29
+
30
+ desc 'Enjoy capistrano setup generator'
31
+ def install
32
+ copy_file "Capfile", "Capfile"
33
+ template "unicorn.erb", "config/unicorn/production.rb"
34
+ template "deploy.erb", "config/deploy.rb"
35
+ template "production.erb", "config/deploy/production.rb"
36
+ template "dl.erb", "lib/tasks/dl.thor"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module Enjoy
5
+ class LayoutGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../../..", __FILE__)
7
+ include Generators::Utils::InstanceMethods
8
+
9
+ desc 'Enjoy Layout generator'
10
+ def layout
11
+ template('app/views/layouts/application.html.slim', 'app/views/layouts/application.html.slim')
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/active_record'
3
+
4
+ module Enjoy
5
+ class MigrationGenerator < Rails::Generators::Base
6
+ include ActiveRecord::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ desc 'Enjoy migration generator'
10
+ def install
11
+ if Enjoy.active_record?
12
+ # %w(contact_messages news pages seos).each do |table_name|
13
+ # migration_template "migration_#{table_name}.rb", "db/migrate/enjoy_create_#{table_name}.rb"
14
+ # end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # Load DSL and Setup Up Stages
2
+ require 'capistrano/setup'
3
+
4
+ # Includes default deployment tasks
5
+ require 'capistrano/deploy'
6
+
7
+ require 'rvm1/capistrano3'
8
+ require 'capistrano/bundler'
9
+ require 'capistrano/rails/assets'
10
+ #require "whenever/capistrano"
11
+
12
+ require 'capistrano/unicorn'
13
+
14
+ # require 'capistrano/rails/console'
15
+
16
+ # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
17
+ Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }