hancock_cms 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +113 -0
  9. data/Rakefile +1 -0
  10. data/app/assets/images/devices/login-bg.jpg +0 -0
  11. data/app/assets/images/rails-admin/hancock_logo.svg +5 -0
  12. data/app/assets/javascripts/hancock/app/back_to_top.coffee +24 -0
  13. data/app/assets/javascripts/hancock/cms.coffee +11 -0
  14. data/app/assets/javascripts/hancock/cms/flash.coffee +3 -0
  15. data/app/assets/javascripts/hancock/cms/init.coffee +1 -0
  16. data/app/assets/javascripts/hancock/cms/map.coffee +22 -0
  17. data/app/assets/javascripts/hancock/rails_admin/cms.ui.coffee +43 -0
  18. data/app/assets/javascripts/hancock/rails_admin/custom/ui.coffee +0 -0
  19. data/app/assets/javascripts/head.load.js +707 -0
  20. data/app/assets/javascripts/jquery.placeholder.js +157 -0
  21. data/app/assets/javascripts/rails_admin/custom/ui.coffee +2 -0
  22. data/app/assets/stylesheets/hancock/cms.sass +9 -0
  23. data/app/assets/stylesheets/hancock/cms/devise.sass +157 -0
  24. data/app/assets/stylesheets/hancock/cms/flash.sass +69 -0
  25. data/app/assets/stylesheets/hancock/cms/mixins.sass +98 -0
  26. data/app/assets/stylesheets/hancock/cms/normalize.scss +407 -0
  27. data/app/assets/stylesheets/hancock/cms/powered.sass +18 -0
  28. data/app/assets/stylesheets/hancock/rails_admin/cms.theming.sass +703 -0
  29. data/app/assets/stylesheets/hancock/rails_admin/custom/theming.sass +1 -0
  30. data/app/assets/stylesheets/hancock/toplink/toplink.sass +24 -0
  31. data/app/assets/stylesheets/rails_admin/custom/theming.sass +4 -0
  32. data/app/controllers/concerns/hancock/current_user.rb +12 -0
  33. data/app/controllers/concerns/hancock/decorators/home.rb +12 -0
  34. data/app/controllers/concerns/hancock/decorators/registrations.rb +5 -0
  35. data/app/controllers/concerns/hancock/decorators/sessions.rb +5 -0
  36. data/app/controllers/concerns/hancock/errors.rb +94 -0
  37. data/app/controllers/concerns/hancock/fancybox.rb +14 -0
  38. data/app/controllers/concerns/hancock/no_cache.rb +12 -0
  39. data/app/controllers/hancock/home_controller.rb +10 -0
  40. data/app/controllers/hancock/registrations_controller.rb +23 -0
  41. data/app/controllers/hancock/sessions_controller.rb +24 -0
  42. data/app/helpers/hancock/gzip_helper.rb +27 -0
  43. data/app/helpers/hancock/home_helper.rb +2 -0
  44. data/app/helpers/hancock/powered_helper.rb +42 -0
  45. data/app/models/concerns/hancock/boolean_field.rb +21 -0
  46. data/app/models/concerns/hancock/cacheable.rb +33 -0
  47. data/app/models/concerns/hancock/decorators/embedded_element.rb +28 -0
  48. data/app/models/concerns/hancock/enableable.rb +8 -0
  49. data/app/models/concerns/hancock/geocodeable.rb +4 -0
  50. data/app/models/concerns/hancock/hash_field.rb +113 -0
  51. data/app/models/concerns/hancock/html_field.rb +33 -0
  52. data/app/models/concerns/hancock/mappable.rb +91 -0
  53. data/app/models/concerns/hancock/model_localizeable.rb +33 -0
  54. data/app/models/concerns/hancock/rails_admin_patch.rb +86 -0
  55. data/app/models/concerns/hancock/sort_field.rb +20 -0
  56. data/app/models/concerns/hancock/sortable.rb +8 -0
  57. data/app/models/hancock/embedded_element.rb +17 -0
  58. data/app/views/blocks/_favicon.html.slim +60 -0
  59. data/app/views/blocks/_footer.html.slim +1 -0
  60. data/app/views/blocks/_header.html.slim +3 -0
  61. data/app/views/devise/passwords/edit.html.slim +29 -0
  62. data/app/views/devise/passwords/new.html.slim +19 -0
  63. data/app/views/devise/registrations/edit.html.slim +31 -0
  64. data/app/views/devise/registrations/new.html.slim +39 -0
  65. data/app/views/devise/sessions/new.html.slim +39 -0
  66. data/app/views/devise/shared/_links.html.slim +11 -0
  67. data/app/views/hancock/errors/_base.html.slim +3 -0
  68. data/app/views/hancock/errors/error_403.html.slim +1 -0
  69. data/app/views/hancock/errors/error_404.html.slim +1 -0
  70. data/app/views/hancock/errors/error_500.html.slim +1 -0
  71. data/app/views/hancock/home/index.html.slim +1 -0
  72. data/app/views/hancock/simple_captcha/_simple_captcha.html.slim +13 -0
  73. data/app/views/hancock/toplink/_toplink.html.slim +2 -0
  74. data/app/views/layouts/application.html.slim +35 -0
  75. data/app/views/layouts/hancock/devise/confirmations.html.slim +22 -0
  76. data/app/views/layouts/hancock/devise/passwords.html.slim +22 -0
  77. data/app/views/layouts/hancock/devise/registrations.html.slim +22 -0
  78. data/app/views/layouts/hancock/devise/sessions.html.slim +22 -0
  79. data/app/views/layouts/hancock/devise/unlocks.html.slim +22 -0
  80. data/app/views/layouts/rails_admin/_footer.html.slim +2 -0
  81. data/app/views/layouts/rails_admin/_footer_navigation.html.slim +20 -0
  82. data/app/views/layouts/rails_admin/_navigation.html.slim +73 -0
  83. data/app/views/layouts/rails_admin/_secondary_navigation.html.slim +32 -0
  84. data/app/views/layouts/rails_admin/application.html.haml +68 -0
  85. data/app/views/layouts/rails_admin/pjax.html.haml +17 -0
  86. data/app/views/rails_admin/main/_check_boxes.html.slim +27 -0
  87. data/app/views/rails_admin/main/_enum_check_boxes.html.slim +5 -0
  88. data/app/views/rails_admin/main/_enum_radio_buttons.html.slim +5 -0
  89. data/app/views/rails_admin/main/_form_hancock_multiselect.html.slim +48 -0
  90. data/app/views/rails_admin/main/_form_raw.html.slim +1 -0
  91. data/app/views/rails_admin/main/_hancock_hash.html.slim +9 -0
  92. data/app/views/rails_admin/main/_hancock_hash_ml.html.slim +10 -0
  93. data/app/views/rails_admin/main/_hancock_html.html.slim +16 -0
  94. data/app/views/rails_admin/main/_hancock_html_ml.html.slim +53 -0
  95. data/app/views/shared/_admin_link.html.slim +3 -0
  96. data/app/views/shared/_messages.html.slim +7 -0
  97. data/config/initializers/embedded_findable.rb +57 -0
  98. data/config/initializers/hancock_cms.rb +11 -0
  99. data/config/initializers/simple_captcha.rb +70 -0
  100. data/config/locales/en.hancock.yml +29 -0
  101. data/config/locales/en.hancock_admin.yml +6 -0
  102. data/config/locales/ru.cancan.yml +4 -0
  103. data/config/locales/ru.devise.yml +65 -0
  104. data/config/locales/ru.hancock.yml +36 -0
  105. data/config/locales/ru.hancock_admin.yml +6 -0
  106. data/config/locales/ru.models.yml +82 -0
  107. data/config/locales/ru.mongoid.yml +450 -0
  108. data/config/locales/ru.rails_admin.yml +168 -0
  109. data/hancock_cms.gemspec +46 -0
  110. data/lib/filename_to_slug.rb +32 -0
  111. data/lib/generators/hancock/cms/ability_generator.rb +14 -0
  112. data/lib/generators/hancock/cms/admin_generator.rb +21 -0
  113. data/lib/generators/hancock/cms/application_generator.rb +14 -0
  114. data/lib/generators/hancock/cms/assets_generator.rb +35 -0
  115. data/lib/generators/hancock/cms/config_generator.rb +13 -0
  116. data/lib/generators/hancock/cms/controllers/decorators_generator.rb +27 -0
  117. data/lib/generators/hancock/cms/gemfile_generator.rb +13 -0
  118. data/lib/generators/hancock/cms/layout_generator.rb +14 -0
  119. data/lib/generators/hancock/cms/model_generator.rb +39 -0
  120. data/lib/generators/hancock/cms/models/embedded_element_generator.rb +56 -0
  121. data/lib/generators/hancock/cms/models/templates/embedded_element.erb +47 -0
  122. data/lib/generators/hancock/cms/paperclip_optimizer_generator.rb +13 -0
  123. data/lib/generators/hancock/cms/rack_generator.rb +12 -0
  124. data/lib/generators/hancock/cms/robots_generator.rb +14 -0
  125. data/lib/generators/hancock/cms/scripts_generator.rb +31 -0
  126. data/lib/generators/hancock/cms/templates/Gemfile.erb +69 -0
  127. data/lib/generators/hancock/cms/templates/ability.erb +49 -0
  128. data/lib/generators/hancock/cms/templates/admin.erb +74 -0
  129. data/lib/generators/hancock/cms/templates/application.erb +42 -0
  130. data/lib/generators/hancock/cms/templates/assets/javascripts/application.coffee.erb +5 -0
  131. data/lib/generators/hancock/cms/templates/assets/stylesheets/application.sass.erb +88 -0
  132. data/lib/generators/hancock/cms/templates/hancock_cms.erb +30 -0
  133. data/lib/generators/hancock/cms/templates/model.erb +42 -0
  134. data/lib/generators/hancock/cms/templates/paperclip_optimizer.erb +80 -0
  135. data/lib/generators/hancock/cms/templates/rack.erb +15 -0
  136. data/lib/generators/hancock/cms/templates/robots.txt.erb +5 -0
  137. data/lib/generators/hancock/cms/templates/scripts/assets_precompile.sh +3 -0
  138. data/lib/generators/hancock/cms/templates/scripts/bundle_production.sh +4 -0
  139. data/lib/generators/hancock/cms/templates/scripts/db_dump.sh.erb +3 -0
  140. data/lib/generators/hancock/cms/templates/scripts/db_restore.sh +3 -0
  141. data/lib/generators/hancock/cms/templates/scripts/full_assets_precompile.sh +4 -0
  142. data/lib/generators/hancock/cms/templates/scripts/restart_thru_kill.sh +3 -0
  143. data/lib/generators/hancock/cms/templates/scripts/send_hup.sh +3 -0
  144. data/lib/generators/hancock/cms/templates/scripts/send_usr2.sh +3 -0
  145. data/lib/generators/hancock/cms/templates/scripts/server.sh +5 -0
  146. data/lib/generators/hancock/cms/templates/scripts/server_alt.sh +5 -0
  147. data/lib/generators/hancock/cms/templates/unicorn.erb +57 -0
  148. data/lib/generators/hancock/cms/templates/unicorn.god.erb +59 -0
  149. data/lib/generators/hancock/cms/unicorn_god_generator.rb +15 -0
  150. data/lib/generators/hancock/cms/utils.rb +21 -0
  151. data/lib/hancock/admin.rb +60 -0
  152. data/lib/hancock/admin/embedded_element.rb +26 -0
  153. data/lib/hancock/configuration.rb +48 -0
  154. data/lib/hancock/controller.rb +30 -0
  155. data/lib/hancock/engine.rb +48 -0
  156. data/lib/hancock/migration.rb +15 -0
  157. data/lib/hancock/model.rb +53 -0
  158. data/lib/hancock/models/embedded_element.rb +12 -0
  159. data/lib/hancock/models/mongoid/embedded_element.rb +14 -0
  160. data/lib/hancock/plugin.rb +25 -0
  161. data/lib/hancock/plugin_configuration.rb +30 -0
  162. data/lib/hancock/rails_admin_ext/config.rb +129 -0
  163. data/lib/hancock/rails_admin_ext/hancock_hash.rb +84 -0
  164. data/lib/hancock/rails_admin_ext/hancock_html.rb +79 -0
  165. data/lib/hancock/rails_admin_ext/hancock_multiselect.rb +44 -0
  166. data/lib/hancock/rails_admin_ext/hancock_slugs.rb +35 -0
  167. data/lib/hancock/rails_admin_ext/patches/field_patch.rb +14 -0
  168. data/lib/hancock/rails_admin_ext/patches/group_patch.rb +41 -0
  169. data/lib/hancock/rails_admin_ext/patches/hancock_cms_group.rb +61 -0
  170. data/lib/hancock/rails_admin_ext/patches/new_controller_patch.rb +54 -0
  171. data/lib/hancock/routes.rb +20 -0
  172. data/lib/hancock/simple_form_patch.rb +12 -0
  173. data/lib/hancock/tasks.rb +13 -0
  174. data/lib/hancock/version.rb +3 -0
  175. data/lib/hancock_cms.rb +130 -0
  176. data/lib/manual_slug.rb +10 -0
  177. data/lib/manual_slug/active_record.rb +32 -0
  178. data/lib/manual_slug/mongoid.rb +40 -0
  179. data/lib/rails_admin/custom_show_in_app.rb +43 -0
  180. data/release.sh +12 -0
  181. data/template.rb +564 -0
  182. metadata +455 -0
@@ -0,0 +1,168 @@
1
+ # Russian. Updated 2012-07-18
2
+
3
+ ru:
4
+ admin:
5
+ js:
6
+ true: Да
7
+ false: Нет
8
+ is_present: Существует
9
+ is_blank: Пустое
10
+ date: Дата ...
11
+ between_and_: Между ... и ...
12
+ today: Сегодня
13
+ yesterday: Вчера
14
+ this_week: На этой неделе
15
+ last_week: На прошлой неделе
16
+ number: Номер ...
17
+ contains: Содержит
18
+ is_exactly: В точности
19
+ starts_with: Начинается с
20
+ ends_with: Кончается на
21
+ too_many_objects: "Слишком много объектов, используйте фильтры и поиск"
22
+ no_objects: Ничего не найдено
23
+ loading: Загрузка...
24
+ toggle_navigation: Скрыть/Показать навигацию
25
+ home:
26
+ name: "Главная"
27
+ pagination:
28
+ previous: "« Предыдущая"
29
+ next: "Следующая »"
30
+ truncate: "…"
31
+ misc:
32
+ filter_date_format: "dd.mm.yyyy"
33
+ search: "Поиск"
34
+ filter: "Фильтрация"
35
+ refresh: "Обновить"
36
+ show_all: "Показать все"
37
+ add_filter: "Добавить фильтр..."
38
+ bulk_menu_title: "Выбранные элементы..."
39
+ remove: "Убрать"
40
+ add_new: "Добавить новый"
41
+ chosen: "Выбрать %{name}"
42
+ chose_all: "Выбрать все"
43
+ clear_all: "Убрать выделение"
44
+ up: "Вверх"
45
+ down: "Вниз"
46
+ navigation: "Навигация"
47
+ log_out: "Выйти"
48
+ ago: "назад"
49
+ flash:
50
+ successful: "%{name} был %{action}"
51
+ error: "Не получилось %{action} %{name}"
52
+ noaction: "Никаких изменений не выполнено"
53
+ model_not_found: "Модель '%{model}' не найден"
54
+ object_not_found: "Объект %{model} с id '%{id}' не найден"
55
+ table_headers:
56
+ items: "Элементы"
57
+ model_name: "Название модели"
58
+ last_used: "Последний раз использовалось"
59
+ records: "Записи"
60
+ username: "Пользователь"
61
+ changes: "Изменения"
62
+ created_at: "Дата/Время"
63
+ item: "Элемент"
64
+ message: "Сообщение"
65
+ actions:
66
+ nestable:
67
+ title: "Сортировка %{model_label}"
68
+ menu: "Сортировать"
69
+ breadcrumb: "Сортировка"
70
+ link: "Сортировать"
71
+ bulk_link: "Сортировка выбранных %{model_label_plural}"
72
+ done: "Сохранено"
73
+ success: "Успешно"
74
+ error: "Ошибка"
75
+ social_auth:
76
+ menu: Авторизовать
77
+
78
+ dashboard:
79
+ title: "Управление сайтом"
80
+ menu: "Контрольная панель"
81
+ breadcrumb: "панель"
82
+ index:
83
+ title: "Список %{model_label_plural}"
84
+ menu: "Список"
85
+ breadcrumb: "%{model_label_plural}"
86
+ show:
87
+ title: "Детали %{model_label} '%{object_label}'"
88
+ menu: "Просмотр"
89
+ breadcrumb: "%{object_label}"
90
+ show_in_app:
91
+ menu: "Показать в приложении"
92
+ new:
93
+ title: "Новый %{model_label}"
94
+ menu: "Создание"
95
+ breadcrumb: "новый"
96
+ link: "Добавить новый %{model_label}"
97
+ done: "создано"
98
+ edit:
99
+ title: "Редактирование %{model_label} '%{object_label}'"
100
+ menu: "Редактирование"
101
+ breadcrumb: "редактирование"
102
+ link: "Редактировать %{model_label}"
103
+ done: "сохранено"
104
+ delete:
105
+ title: "Удаление %{model_label} '%{object_label}'"
106
+ menu: "Удаление"
107
+ breadcrumb: "удаление"
108
+ link: "Удалить '%{object_label}'"
109
+ done: "удалено"
110
+ bulk_delete:
111
+ title: "Удалить много %{model_label_plural}"
112
+ menu: "Мульти-удаление"
113
+ breadcrumb: "мульти-удаление"
114
+ bulk_link: "Удалить выбранные %{model_label_plural}"
115
+ export:
116
+ title: "Экспорт %{model_label}"
117
+ menu: "Экспорт"
118
+ breadcrumb: "экспорт"
119
+ link: "Экспорт найденных %{model_label_plural}"
120
+ bulk_link: "Экспорт выбраных %{model_label_plural}"
121
+ done: "экспортировано"
122
+ history_index:
123
+ title: "История для %{model_label_plural}"
124
+ menu: "История"
125
+ breadcrumb: "история"
126
+ history_show:
127
+ title: "История для %{model_label} '%{object_label}'"
128
+ menu: "История"
129
+ breadcrumb: "история"
130
+ show_in_app:
131
+ title: 'В приложении'
132
+ menu: "Показать на сайте"
133
+ form:
134
+ cancel: "Отмена"
135
+ basic_info: "Основное"
136
+ required: "Требуемое"
137
+ optional: "Необязательное"
138
+ one_char: "символ"
139
+ char_length_up_to: "длина не более"
140
+ char_length_of: "длина"
141
+ save: "Сохранить"
142
+ save_and_add_another: "Сохранить и добавить ещё"
143
+ save_and_edit: "Сохранить и остаться"
144
+ all_of_the_following_related_items_will_be_deleted: "Следующие объекты будут удалены:"
145
+ are_you_sure_you_want_to_delete_the_object: "Вы уверены что хотите удалить %{model_name}"
146
+ confirmation: "Да, уверен"
147
+ delete_confirmation: "Подтвердить удаление"
148
+ bulk_delete: "Следующие объекты будут удалены, что может сломать связи с другими объектами:"
149
+ new_model: "Новый"
150
+ export:
151
+ confirmation: "Экспортировать как %{name}"
152
+ select: "Выберите поля для экспорта"
153
+ fields_from: "Поля из %{name}"
154
+ fields_from_associated: "Поля из ассоциированной %{name}"
155
+ display: "Показать %{name}: %{type}"
156
+ options_for: "Настройки для %{name}"
157
+ empty_value_for_associated_objects: "<пусто>"
158
+ click_to_reverse_selection: 'Обратить выделение'
159
+ csv:
160
+ header_for_root_methods: "%{name}" # 'model' is available
161
+ header_for_association_methods: "%{name} [%{association}]"
162
+ encoding_to: "Декодировать как"
163
+ encoding_to_help: "Выберите результирующую кодировку. Оставьте пустой, чтобы оставить исходную кодировку нетронутой: (%{name})"
164
+ skip_header: "Без заголовка"
165
+ skip_header_help: "Не выводить заголовок (без описаний полей)"
166
+ default_col_sep: ","
167
+ col_sep: "Разделитель столбцов"
168
+ col_sep_help: "Оставьте пустым, чтобы было по умолчанию ('%{value}')" # value is default_col_sep
@@ -0,0 +1,46 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'hancock/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'hancock_cms'
7
+ spec.version = Hancock::VERSION
8
+ spec.authors = ['Alexander Kiseliev']
9
+ spec.email = ["dev@redrocks.pro"]
10
+ spec.description = %q{HancockCMS }
11
+ spec.summary = %q{Please DO NOT use this gem directly, use hancock_cms_mongoid or hancock_cms_activerecord instead!}
12
+ spec.homepage = 'https://github.com/red-rocks/hancock_cms'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/).reject {|f| f.start_with?('mongoid') || f.start_with?('activerecord') }
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler'
21
+ spec.add_development_dependency 'rake'
22
+
23
+ spec.add_dependency 'rails', ['>= 4.2', "< 5.0"]
24
+
25
+ spec.add_dependency 'jquery-rails'
26
+ spec.add_dependency 'simple_form'
27
+ # spec.add_dependency 'glebtv-simple_captcha'
28
+ # spec.add_dependency 'galetahub-simple_captcha'
29
+ spec.add_dependency 'coffee-rails'
30
+ spec.add_dependency 'devise'
31
+
32
+ spec.add_dependency 'ckeditor'
33
+ spec.add_dependency 'geocoder'
34
+
35
+ spec.add_dependency 'rails_admin', '~> 0.8.1'
36
+ spec.add_dependency 'rails_admin_nested_set'
37
+ spec.add_dependency 'rails_admin_toggleable'
38
+
39
+ spec.add_dependency 'ack_rails_admin_settings'
40
+
41
+ spec.add_dependency 'kaminari'
42
+
43
+ spec.add_dependency 'codemirror-rails'
44
+
45
+ spec.add_dependency 'scrollbar-rails'
46
+ end
@@ -0,0 +1,32 @@
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
@@ -0,0 +1,14 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module Hancock::Cms
5
+ class AbilityGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+ include Generators::Utils::InstanceMethods
8
+
9
+ desc 'Hancock CMS CanCan Ability config generator'
10
+ def install
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 Hancock::Cms
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 'Hancock CMS 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,14 @@
1
+ require 'rails/generators'
2
+
3
+ module Hancock::Cms
4
+ class ApplicationGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ argument :app_name, type: :string
8
+
9
+ desc 'Hancock CMS application.rb generator'
10
+ def install
11
+ template "application.erb", "config/application.rb"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ require 'rails/generators'
2
+
3
+ module Hancock::Cms
4
+ class AssetsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates/assets', __FILE__)
6
+
7
+ desc 'Hancock CMS assets generator'
8
+ def install
9
+ assets_files.each do |f|
10
+ template "#{f}.erb", "app/assets/#{f}"
11
+ end
12
+ end
13
+
14
+
15
+ def rails_admin_theming_sass_path
16
+ "stylesheets/hancock/rails_admin/custom/theming.sass"
17
+ end
18
+
19
+ def application_sass_path
20
+ "stylesheets/application.sass"
21
+ end
22
+
23
+ def application_coffee_path
24
+ "javascripts/application.coffee"
25
+ end
26
+
27
+ def assets_files
28
+ [
29
+ rails_admin_theming_sass_path,
30
+ application_sass_path,
31
+ application_coffee_path
32
+ ]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Hancock::Cms
4
+ class ConfigGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ desc 'Hancock CMS Config generator'
8
+ def install
9
+ template 'hancock_cms.erb', "config/initializers/hancock_cms.rb"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require 'rails/generators'
2
+
3
+ module Hancock::Cms
4
+ module Controllers
5
+ class DecoratorsGenerator < Rails::Generators::Base
6
+
7
+ source_root File.expand_path('../../../../../../app/controllers/concerns/hancock/decorators', __FILE__)
8
+ argument :controllers, type: :array, default: []
9
+
10
+ desc 'Hancock::Cms Controllers decorators generator'
11
+ def decorators
12
+ copied = false
13
+ (controllers == ['all'] ? permitted_controllers : controllers & permitted_controllers).each do |c|
14
+ copied = true
15
+ copy_file "#{c}.rb", "app/controllers/concerns/hancock/decorators/#{c}.rb"
16
+ end
17
+ puts "U need to set controller`s name. One of this: #{permitted_controllers.join(", ")} or `all`." unless copied
18
+ end
19
+
20
+ private
21
+ def permitted_controllers
22
+ ['home', 'sessions', 'registrations']
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Hancock::Cms
4
+ class GemfileGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ desc 'Hancock CMS Gemfile generator'
8
+ def install
9
+ template 'Gemfile.erb', "Gemfile"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module Hancock::Cms
5
+ class LayoutGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../../..", __FILE__)
7
+ include Generators::Utils::InstanceMethods
8
+
9
+ desc 'Hancock CMS 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,39 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module Hancock::Cms
5
+ class ModelGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+ argument :class_name_arg, type: :string, default: ""
8
+
9
+ desc 'Hancock::CMS Model generator'
10
+ def install
11
+ template 'model.erb', "app/models/#{file_name}.rb"
12
+ end
13
+
14
+ private
15
+ def class_name
16
+ class_name_arg.blank? ? "SetClassForModel" : class_name_arg
17
+ end
18
+
19
+ def capitalized_class_name
20
+ class_name.capitalize
21
+ end
22
+
23
+ def camelcased_class_name
24
+ class_name.camelcase
25
+ end
26
+
27
+ def file_name
28
+ underscored_class_name
29
+ end
30
+
31
+ def underscored_class_name
32
+ camelcased_class_name.underscore
33
+ end
34
+
35
+ def underscored_pluralized_class_name
36
+ underscored_class_name.pluralize
37
+ end
38
+ end
39
+ end