adminos 1.0.0.pre.rc.2 → 1.0.0.pre.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -3
  3. data/README.md +26 -0
  4. data/adminos.gemspec +2 -2
  5. data/app/inputs/cropp_input.rb +13 -1
  6. data/app/inputs/filter_inputs/boolean_input.rb +18 -0
  7. data/app/inputs/filter_inputs/date_range_input.rb +36 -0
  8. data/app/inputs/filter_inputs/numeric_input.rb +40 -0
  9. data/app/inputs/filter_inputs/string_input.rb +40 -0
  10. data/lib/adminos.rb +23 -3
  11. data/lib/adminos/configuration.rb +9 -0
  12. data/lib/adminos/controllers/filters.rb +20 -0
  13. data/lib/adminos/controllers/resource.rb +18 -11
  14. data/lib/adminos/extensions/simple_form.rb +12 -0
  15. data/lib/adminos/features/search/elastic.rb +46 -0
  16. data/lib/adminos/features/search/pg_search.rb +49 -0
  17. data/lib/adminos/filters/forms.rb +55 -0
  18. data/lib/adminos/form_builder.rb +11 -0
  19. data/lib/adminos/helpers/models/searchable.rb +9 -0
  20. data/lib/adminos/helpers/view.rb +35 -0
  21. data/lib/generators/adminos/adminos_generator.rb +10 -7
  22. data/lib/generators/adminos/feedback_generator.rb +39 -0
  23. data/lib/generators/adminos/i18n_generator.rb +16 -4
  24. data/lib/generators/adminos/install_generator.rb +22 -0
  25. data/lib/generators/adminos/profile_generator.rb +34 -0
  26. data/lib/generators/adminos/search_generator.rb +38 -0
  27. data/lib/generators/adminos/two_factor_auth_generator.rb +81 -0
  28. data/lib/generators/templates/adminos/fields.slim +1 -1
  29. data/lib/generators/templates/adminos/locales/locale_fields.slim +7 -4
  30. data/lib/generators/templates/adminos/locales/model.rb.erb +2 -3
  31. data/lib/generators/templates/ci/.gitlab-ci.yml +1 -1
  32. data/lib/generators/templates/feedback/auto/app/controllers/admin/feedbacks_controller.rb +17 -0
  33. data/lib/generators/templates/feedback/auto/app/controllers/feedbacks_controller.rb +11 -0
  34. data/lib/generators/templates/feedback/auto/app/models/feedback.rb +6 -0
  35. data/lib/generators/templates/feedback/auto/app/views/admin/feedbacks/_fields.slim +5 -0
  36. data/lib/generators/templates/feedback/auto/app/views/admin/feedbacks/index.slim +28 -0
  37. data/lib/generators/templates/feedback/feedbacks_migration.rb +13 -0
  38. data/lib/generators/templates/field/locales/locale_fields.slim +1 -1
  39. data/lib/generators/templates/field/locales/model.rb.erb +2 -3
  40. data/lib/generators/templates/i18n/Gemfile +6 -1
  41. data/lib/generators/templates/i18n/auto/app/validators/locale_validator.rb +5 -1
  42. data/lib/generators/templates/i18n/auto/app/views/admin/base/_pills.slim +1 -5
  43. data/lib/generators/templates/i18n/auto/app/views/admin/pages/_locale_fields.slim +5 -5
  44. data/lib/generators/templates/i18n/auto/config/initializers/mobility.rb +92 -0
  45. data/lib/generators/templates/i18n/page.rb +2 -2
  46. data/lib/generators/templates/install/Gemfile +3 -5
  47. data/lib/generators/templates/install/README.md +22 -0
  48. data/lib/generators/templates/install/auto/Capfile +12 -2
  49. data/lib/generators/templates/install/auto/app/views/admin/base/_form.slim +1 -1
  50. data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_header.slim +2 -0
  51. data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_new.slim +1 -1
  52. data/lib/generators/templates/install/auto/config/deploy/staging.rb +15 -10
  53. data/lib/generators/templates/install/auto/config/deploy/{shared → templates}/database.yml.erb +1 -1
  54. data/lib/generators/templates/install/auto/config/deploy/templates/nginx_conf.erb +96 -0
  55. data/lib/generators/templates/install/auto/config/deploy/templates/puma.rb.erb +52 -0
  56. data/lib/generators/templates/install/auto/config/environments/staging.rb +1 -1
  57. data/lib/generators/templates/install/auto/config/initializers/adminos.rb +3 -0
  58. data/lib/generators/templates/install/auto/config/locales/adminos.ru.yml +18 -0
  59. data/lib/generators/templates/install/auto/config/schedule.rb +0 -0
  60. data/lib/generators/templates/install/auto/config/systemd/puma.service.erb +19 -0
  61. data/lib/generators/templates/install/auto/config/systemd/sidekiq.service.erb +21 -0
  62. data/lib/generators/templates/install/auto/lib/capistrano/{template.rb → smart_templates.rb} +17 -3
  63. data/lib/generators/templates/install/auto/lib/capistrano/tasks/setup_config.cap +27 -20
  64. data/lib/generators/templates/install/deploy.rb.erb +13 -12
  65. data/lib/generators/templates/profile/auto/app/controllers/admin/profiles_controller.rb +26 -0
  66. data/lib/generators/templates/profile/auto/app/views/admin/profiles/edit.slim +17 -0
  67. data/lib/generators/templates/two_facto_auth/Gemfile +1 -0
  68. data/lib/generators/templates/two_facto_auth/auto/app/controllers/concerns/authenticates_with_two_factor.rb +36 -0
  69. data/lib/generators/templates/two_facto_auth/auto/app/controllers/users/sessions_controller.rb +5 -0
  70. data/lib/generators/templates/two_facto_auth/auto/app/views/admin/profiles/_2fa.slim +24 -0
  71. data/lib/generators/templates/two_facto_auth/auto/app/views/devise/sessions/two_factor.slim +15 -0
  72. data/spec/lib/generators/adminos/feedback_generator_rspec.rb +50 -0
  73. data/spec/lib/generators/adminos/install_generator_rspec.rb +6 -7
  74. data/spec/lib/generators/adminos/profile_generator_rspec.rb +33 -0
  75. data/spec/lib/generators/adminos/search_generator.rb +20 -0
  76. data/spec/lib/generators/adminos/two_factor_auth_generator_rspec.rb +61 -0
  77. data/spec/spec_helper.rb +4 -0
  78. data/spec/support/shared/generator.rb +1 -1
  79. metadata +55 -22
  80. data/bin/rspec +0 -29
  81. data/lib/adminos/extensions/globalize_actiontext.rb +0 -28
  82. data/lib/adminos/extensions/globalize_fields.rb +0 -19
  83. data/lib/generators/templates/adminos/locales/migration.rb.erb +0 -18
  84. data/lib/generators/templates/field/locales/migration.rb.erb +0 -13
  85. data/lib/generators/templates/i18n/add_translation_table_to_page.rb +0 -15
  86. data/lib/generators/templates/i18n/auto/config/initializers/globalize_fields.rb +0 -1
  87. data/lib/generators/templates/install/auto/config/deploy/shared/nginx.conf.erb +0 -28
  88. data/lib/generators/templates/install/auto/config/deploy/shared/unicorn.rb.erb +0 -35
  89. data/lib/generators/templates/install/auto/lib/capistrano/substitute_strings.rb +0 -12
  90. data/package-lock.json +0 -3
data/bin/rspec DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rspec' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rspec-core", "rspec")
@@ -1,28 +0,0 @@
1
- module GlobalizeActiontext
2
- module ActionText
3
- def setup_translates!(options)
4
- super
5
-
6
- self.after_initialize do
7
- reflect_has_one = self.class.reflect_on_all_associations(:has_one)
8
- rich_text_attributes = reflect_has_one.map(&:name).map { |name| name.to_s.gsub('rich_text_', '') }.compact
9
-
10
- self.class.translation_class.class_eval do
11
- rich_text_attributes.each do |rich_text_attribute|
12
- attribute rich_text_attribute
13
- has_rich_text rich_text_attribute
14
- define_method "#{rich_text_attribute}=" do |value|
15
- send(rich_text_attribute).body = value
16
-
17
- return unless public_send(rich_text_attribute).changed?
18
-
19
- attribute_will_change! rich_text_attribute
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
-
28
- ActiveRecord::Base.singleton_class.prepend(GlobalizeActiontext::ActionText)
@@ -1,19 +0,0 @@
1
- module ActionView
2
- module Helpers
3
- class FormBuilder
4
- def globalize_fields_for(locale, *args, &proc)
5
- raise ArgumentError, "Missing block" unless block_given?
6
- @globalize_index = @globalize_index ? @globalize_index + 1 : 1
7
- object_name = "#{@object_name}[translations_attributes][#{@globalize_index}]"
8
- object = @object.translation_for locale
9
- @template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
10
- @template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
11
- if @template.respond_to? :simple_fields_for
12
- @template.simple_fields_for(object_name, object, *args, &proc)
13
- else
14
- @template.fields_for(object_name, object, *args, &proc)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- class AddTranslationTableTo<%= file_name.camelize %> < ActiveRecord::Migration[5.2]
2
- def up
3
- <%= file_name.camelize %>.create_translation_table!({
4
- name: :string,<%= "\n nav_name: :string," if options.type == 'section' %>
5
- <% attributes.each do |attribute| -%>
6
- <%= "#{attribute.name}: :#{attribute.type},\n" if attribute.locale -%>
7
- <% end -%>
8
- meta_description: :text,
9
- meta_title: :string
10
- }, {
11
- migrate_data: true
12
- })
13
- end
14
-
15
- def down
16
- <%= file_name.camelize %>.drop_translation_table! migrate_data: true
17
- end
18
- end
@@ -1,13 +0,0 @@
1
- class AddTranslationFields<%= attributes.select(&:locale).map(&:name).join('_').camelize %>To<%= file_name.camelize %> < ActiveRecord::Migration[5.1]
2
- def up
3
- <% attributes.select(&:locale).each do |attribute| -%>
4
- <%= file_name.camelize %>.add_translation_fields! <%= attribute.name %>: :<%= attribute.type %>
5
- <% end -%>
6
- end
7
-
8
- def down
9
- <% attributes.select(&:locale).each do |attribute| -%>
10
- remove_column :<%= file_name %>_translations, :<%= attribute.name %>
11
- <% end -%>
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- class AddTranslationTableToPage < ActiveRecord::Migration[5.1]
2
- def up
3
- Page.create_translation_table!({
4
- name: :string,
5
- nav_name: :string,
6
- body: :text,
7
- meta_description: :text,
8
- meta_title: :string
9
- }, migrate_data: true)
10
- end
11
-
12
- def down
13
- Page.drop_translation_table! migrate_data: true
14
- end
15
- end
@@ -1 +0,0 @@
1
- require 'adminos/extensions/globalize_fields'
@@ -1,28 +0,0 @@
1
- upstream unicorn {
2
- server unix:<%= shared_path %>/tmp/sockets/unicorn.sock fail_timeout=0;
3
- }
4
-
5
- server {
6
- server_name <%= fetch(:server_name) %>;
7
- listen 80;
8
- root <%= fetch(:deploy_to) %>/current/public;
9
-
10
- location ^~ /assets/ {
11
- gzip_static on;
12
- expires max;
13
- add_header Cache-Control public;
14
- }
15
-
16
- try_files $uri/index.html $uri @unicorn;
17
- location @unicorn {
18
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
- proxy_set_header Host $http_host;
20
- proxy_redirect off;
21
- proxy_pass http://unicorn;
22
- }
23
-
24
- error_page 500 502 503 504 /500.html;
25
- client_max_body_size 4G;
26
- keepalive_timeout 10;
27
- }
28
-
@@ -1,35 +0,0 @@
1
- worker_processes <%= fetch(:unicorn_worker_processes) %>
2
- user "<%= fetch(:deploy_user) %>", "<%= fetch(:deploy_user) %>"
3
- working_directory "<%= current_path %>"
4
- listen "<%= shared_path %>/tmp/sockets/unicorn.sock"
5
-
6
- timeout 80
7
-
8
- preload_app true
9
-
10
- pid "<%= shared_path %>/tmp/pids/unicorn.pid"
11
-
12
- stderr_path "<%= shared_path %>/log/unicorn.stderr.log"
13
- stdout_path "<%= shared_path %>/log/unicorn.stdout.log"
14
-
15
- GC.respond_to?(:copy_on_write_friendly=) and
16
- GC.copy_on_write_friendly = true
17
-
18
- before_fork do |server, worker|
19
- old_pid = "#{server.config[:pid]}.oldbin"
20
- if File.exists?(old_pid) && server.pid != old_pid
21
- begin
22
- Process.kill("QUIT", File.read(old_pid).to_i)
23
- rescue Errno::ENOENT, Errno::ESRCH
24
- end
25
- end
26
- end
27
-
28
- after_fork do |server, worker|
29
- defined?(ActiveRecord::Base) and
30
- ActiveRecord::Base.establish_connection
31
- end
32
-
33
- before_exec do |server|
34
- ENV['BUNDLE_GEMFILE'] = "<%= current_path %>/Gemfile"
35
- end
@@ -1,12 +0,0 @@
1
- # we often want to refer to variables which
2
- # are defined in subsequent stage files. This
3
- # let's us use the {{var}} to represent fetch(:var)
4
- # in strings which are only evaluated at runtime.
5
-
6
- def sub_strings(input_string)
7
- output_string = input_string
8
- input_string.scan(/{{(\w*)}}/).each do |var|
9
- output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym))
10
- end
11
- output_string
12
- end
@@ -1,3 +0,0 @@
1
- {
2
- "lockfileVersion": 1
3
- }