adminos 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +25 -0
- data/.gitlab-ci.yml +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +120 -0
- data/.rubocop_todo.yml +58 -0
- data/Gemfile +25 -0
- data/Guardfile +70 -0
- data/LICENSE.txt +22 -0
- data/README.md +88 -0
- data/Rakefile +20 -0
- data/adminos.gemspec +37 -0
- data/adminos.png +0 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/apple-touch-icon.png +0 -0
- data/app/assets/images/favicon-16x16.png +0 -0
- data/app/assets/images/favicon-32x32.png +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/safari-pinned-tab.svg +23 -0
- data/app/inputs/cropp_input.rb +45 -0
- data/bin/bundle +105 -0
- data/bin/gem +39 -0
- data/bin/rspec +29 -0
- data/exe/adminos +5 -0
- data/lib/adminos/cli.rb +71 -0
- data/lib/adminos/controllers/admin_extension.rb +34 -0
- data/lib/adminos/controllers/helpers.rb +24 -0
- data/lib/adminos/controllers/resource.rb +169 -0
- data/lib/adminos/extensions/globalize_actiontext.rb +28 -0
- data/lib/adminos/extensions/globalize_fields.rb +19 -0
- data/lib/adminos/extensions/nested_set.rb +27 -0
- data/lib/adminos/extensions/string.rb +5 -0
- data/lib/adminos/generators/gemfile_merge.rb +85 -0
- data/lib/adminos/generators/utilities.rb +87 -0
- data/lib/adminos/helpers/admin.rb +190 -0
- data/lib/adminos/helpers/bootstrap.rb +64 -0
- data/lib/adminos/helpers/models/apply_sortable_order.rb +10 -0
- data/lib/adminos/helpers/models/array_attrs.rb +17 -0
- data/lib/adminos/helpers/models/cropped.rb +20 -0
- data/lib/adminos/helpers/models/dom_id.rb +16 -0
- data/lib/adminos/helpers/models/flag_attrs.rb +43 -0
- data/lib/adminos/helpers/models/if_blank_set_to_nil_params.rb +19 -0
- data/lib/adminos/helpers/models/move_to.rb +17 -0
- data/lib/adminos/helpers/models/nested_set/duplication.rb +31 -0
- data/lib/adminos/helpers/models/nested_set/materialize_path.rb +50 -0
- data/lib/adminos/helpers/models/nested_set/place_to.rb +35 -0
- data/lib/adminos/helpers/models/nested_set/safe_destroy.rb +34 -0
- data/lib/adminos/helpers/models/recognizable.rb +28 -0
- data/lib/adminos/helpers/models/slugged.rb +20 -0
- data/lib/adminos/helpers/models/soft_destroy.rb +61 -0
- data/lib/adminos/helpers/models/wysiwyg.rb +105 -0
- data/lib/adminos/helpers/view.rb +137 -0
- data/lib/adminos/operations/check_environment.rb +18 -0
- data/lib/adminos/operations/extract_environment.rb +42 -0
- data/lib/adminos/operations/load_environment.rb +30 -0
- data/lib/adminos/stateful_link/action_any_of.rb +76 -0
- data/lib/adminos/stateful_link/helper.rb +31 -0
- data/lib/adminos.rb +42 -0
- data/lib/adminos_template.rb +15 -0
- data/lib/generators/adminos/adminos_generator.rb +164 -0
- data/lib/generators/adminos/ci_generator.rb +124 -0
- data/lib/generators/adminos/field_generator.rb +105 -0
- data/lib/generators/adminos/i18n_generator.rb +76 -0
- data/lib/generators/adminos/install_generator.rb +238 -0
- data/lib/generators/templates/adminos/adminos.ru.yml +15 -0
- data/lib/generators/templates/adminos/fields.slim +21 -0
- data/lib/generators/templates/adminos/locales/general_fields.slim +7 -0
- data/lib/generators/templates/adminos/locales/locale_fields.slim +10 -0
- data/lib/generators/templates/adminos/locales/migration.rb.erb +18 -0
- data/lib/generators/templates/adminos/locales/model.rb.erb +6 -0
- data/lib/generators/templates/adminos/sidebar.slim +2 -0
- data/lib/generators/templates/adminos/sorts/body.slim +3 -0
- data/lib/generators/templates/adminos/sorts/headers.slim +3 -0
- data/lib/generators/templates/adminos/types/default/controller.rb.erb +18 -0
- data/lib/generators/templates/adminos/types/default/migration.rb +5 -0
- data/lib/generators/templates/adminos/types/default/model.rb +20 -0
- data/lib/generators/templates/adminos/types/default/model_includes.rb +4 -0
- data/lib/generators/templates/adminos/types/default/views/index.slim +14 -0
- data/lib/generators/templates/adminos/types/section/controller.rb.erb +10 -0
- data/lib/generators/templates/adminos/types/section/migration.rb +12 -0
- data/lib/generators/templates/adminos/types/section/model.rb +62 -0
- data/lib/generators/templates/adminos/types/section/model_includes.rb +7 -0
- data/lib/generators/templates/adminos/types/section/views/_object.slim +24 -0
- data/lib/generators/templates/adminos/types/section/views/_objects.slim +6 -0
- data/lib/generators/templates/adminos/types/section/views/index.slim +7 -0
- data/lib/generators/templates/adminos/types/sortable/controller.rb.erb +10 -0
- data/lib/generators/templates/adminos/types/sortable/migration.rb +9 -0
- data/lib/generators/templates/adminos/types/sortable/model.rb +35 -0
- data/lib/generators/templates/adminos/types/sortable/model_includes.rb +6 -0
- data/lib/generators/templates/adminos/types/sortable/views/_object.slim +17 -0
- data/lib/generators/templates/adminos/types/sortable/views/_objects.slim +6 -0
- data/lib/generators/templates/adminos/types/sortable/views/index.slim +7 -0
- data/lib/generators/templates/adminos/types/table/controller.rb.erb +19 -0
- data/lib/generators/templates/adminos/types/table/views/index.slim +31 -0
- data/lib/generators/templates/ci/.gitlab-ci.yml +40 -0
- data/lib/generators/templates/ci/audit/Gemfile +3 -0
- data/lib/generators/templates/ci/lint/Gemfile +3 -0
- data/lib/generators/templates/ci/lint/rubocop.yml +116 -0
- data/lib/generators/templates/ci/rakelib/audit.rake +13 -0
- data/lib/generators/templates/ci/rakelib/lint.rake +13 -0
- data/lib/generators/templates/ci/spec/Gemfile +9 -0
- data/lib/generators/templates/field/locales/locale_fields.slim +4 -0
- data/lib/generators/templates/field/locales/migration.rb.erb +13 -0
- data/lib/generators/templates/field/locales/model.rb.erb +6 -0
- data/lib/generators/templates/i18n/Gemfile +1 -0
- data/lib/generators/templates/i18n/add_translation_table_to_page.rb +15 -0
- data/lib/generators/templates/i18n/auto/app/validators/locale_validator.rb +23 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/base/_fields.slim +1 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/base/_pills.slim +19 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/pages/_general_fields.slim +8 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/pages/_locale_fields.slim +13 -0
- data/lib/generators/templates/i18n/auto/config/initializers/globalize_fields.rb +1 -0
- data/lib/generators/templates/i18n/controller.rb +12 -0
- data/lib/generators/templates/i18n/devise/devise.ru.yml +60 -0
- data/lib/generators/templates/i18n/devise/views/_links.erb +25 -0
- data/lib/generators/templates/i18n/devise/views/confirmations/new.slim +8 -0
- data/lib/generators/templates/i18n/devise/views/mailer/confirmation_instructions.slim +4 -0
- data/lib/generators/templates/i18n/devise/views/mailer/reset_password_instructions.slim +5 -0
- data/lib/generators/templates/i18n/devise/views/mailer/unlock_instructions.slim +4 -0
- data/lib/generators/templates/i18n/devise/views/passwords/edit.slim +7 -0
- data/lib/generators/templates/i18n/devise/views/passwords/new.slim +5 -0
- data/lib/generators/templates/i18n/devise/views/registrations/edit.slim +25 -0
- data/lib/generators/templates/i18n/devise/views/registrations/new.slim +7 -0
- data/lib/generators/templates/i18n/devise/views/sessions/new.slim +22 -0
- data/lib/generators/templates/i18n/devise/views/unlocks/new.slim +11 -0
- data/lib/generators/templates/i18n/locales.slim +3 -0
- data/lib/generators/templates/i18n/page.rb +5 -0
- data/lib/generators/templates/install/.gitignore +11 -0
- data/lib/generators/templates/install/Gemfile +57 -0
- data/lib/generators/templates/install/Procfile +1 -0
- data/lib/generators/templates/install/_sidebar.slim.erb +44 -0
- data/lib/generators/templates/install/add_authentications/authentication.rb +7 -0
- data/lib/generators/templates/install/add_authentications/authentications_controller.rb +95 -0
- data/lib/generators/templates/install/add_authentications/authentications_migration.rb +12 -0
- data/lib/generators/templates/install/add_authentications/views/authentications/_form.slim +5 -0
- data/lib/generators/templates/install/add_authentications/views/authentications/_modal.slim +7 -0
- data/lib/generators/templates/install/add_pages/page.rb +116 -0
- data/lib/generators/templates/install/add_pages/pages_controller.rb +6 -0
- data/lib/generators/templates/install/add_pages/pages_migration.rb +25 -0
- data/lib/generators/templates/install/add_pages/views/pages/show.slim +4 -0
- data/lib/generators/templates/install/admin.slim +36 -0
- data/lib/generators/templates/install/admin_panel/pages/admin_pages_controller.rb +9 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_fields.slim +26 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_object.slim +25 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_objects.slim +6 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/index.slim +7 -0
- data/lib/generators/templates/install/admin_panel/users/admin_users_controller.rb +29 -0
- data/lib/generators/templates/install/admin_panel/users/views/admin_users/_fields.slim +4 -0
- data/lib/generators/templates/install/admin_panel/users/views/admin_users/index.slim +33 -0
- data/lib/generators/templates/install/admin_panel/versions/admin_versions_controller.rb +29 -0
- data/lib/generators/templates/install/admin_panel/versions/views/admin_versions/index.slim +47 -0
- data/lib/generators/templates/install/admin_panel/versions/views/admin_versions/show.slim +18 -0
- data/lib/generators/templates/install/application.slim.erb +31 -0
- data/lib/generators/templates/install/auto/.editorconfig +14 -0
- data/lib/generators/templates/install/auto/.env.staging +2 -0
- data/lib/generators/templates/install/auto/Capfile +14 -0
- data/lib/generators/templates/install/auto/Guardfile +18 -0
- data/lib/generators/templates/install/auto/Procfile +1 -0
- data/lib/generators/templates/install/auto/Procfile.local +2 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/admin/application.js +3 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/admin/cocoon_fields.js +43 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/application.js +1 -0
- data/lib/generators/templates/install/auto/app/assets/stylesheets/admin/application.scss +1 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/base_controller.rb +16 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/helps_controller.rb +4 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/settings_controller.rb +26 -0
- data/lib/generators/templates/install/auto/app/controllers/application_controller.rb +50 -0
- data/lib/generators/templates/install/auto/app/controllers/index_controller.rb +2 -0
- data/lib/generators/templates/install/auto/app/helpers/nested_helper.rb +75 -0
- data/lib/generators/templates/install/auto/app/helpers/versions_helper.rb +33 -0
- data/lib/generators/templates/install/auto/app/inputs/carrierwave_input.rb +52 -0
- data/lib/generators/templates/install/auto/app/inputs/checkbox_input.rb +13 -0
- data/lib/generators/templates/install/auto/app/inputs/rich_text_input.rb +9 -0
- data/lib/generators/templates/install/auto/app/mailers/notifier.rb +9 -0
- data/lib/generators/templates/install/auto/app/models/settings.rb +27 -0
- data/lib/generators/templates/install/auto/app/services/export_xlsx.rb +76 -0
- data/lib/generators/templates/install/auto/app/views/active_storage/blobs/_blob.html.erb +17 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_form.slim +33 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_object.slim +27 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_objects.slim +19 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/drop.js.erb +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/edit.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/index.slim +14 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/new.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/helps/index.slim +29 -0
- data/lib/generators/templates/install/auto/app/views/admin/settings/edit.slim +27 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_first_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_gap.slim +7 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_last_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_next_page.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_paginator.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_prev_page.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_first_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_gap.slim +8 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_last_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_next_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_paginator.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_prev_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/layouts/admin/base.slim +17 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_back_button.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_footer.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_search_form.slim +6 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_topbar.slim +11 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_alert_close.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_contacts_page_link_tag.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_link_button_to.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_method_ajax_request_link_to.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_method_link_to.slim +12 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_navigation_menu.html.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_print_tag.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_search_tag_for.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_show_breadcrumbs.slim +7 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_show_flash_alert.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_sortable_column.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_span_link_to.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_sub_navigation.slim +14 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_batch_actions_tag.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_button_new.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_header.slim +4 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_locked_sign.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_nav_published_sign.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_children.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_duplication.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_edit.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_new.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_page_header.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_published_sign.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_show_breadcrumbs.slim +6 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_top_menu_item.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_unpublished_sign.slim +1 -0
- data/lib/generators/templates/install/auto/browserslist +3 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/database.yml.erb +10 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/nginx.conf.erb +28 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/unicorn.rb.erb +35 -0
- data/lib/generators/templates/install/auto/config/deploy/staging.rb +12 -0
- data/lib/generators/templates/install/auto/config/environments/staging.rb +84 -0
- data/lib/generators/templates/install/auto/config/initializers/awesome_nested_set.rb +1 -0
- data/lib/generators/templates/install/auto/config/initializers/content_security_policy.rb +26 -0
- data/lib/generators/templates/install/auto/config/initializers/friendly_id.rb +1 -0
- data/lib/generators/templates/install/auto/config/initializers/kaminari_config.rb +15 -0
- data/lib/generators/templates/install/auto/config/initializers/simple_form.rb +238 -0
- data/lib/generators/templates/install/auto/config/initializers/slim.rb +2 -0
- data/lib/generators/templates/install/auto/config/locales/adminos.en.yml +164 -0
- data/lib/generators/templates/install/auto/config/locales/adminos.ru.yml +292 -0
- data/lib/generators/templates/install/auto/lib/capistrano/substitute_strings.rb +12 -0
- data/lib/generators/templates/install/auto/lib/capistrano/tasks/setup_config.cap +39 -0
- data/lib/generators/templates/install/auto/lib/capistrano/template.rb +33 -0
- data/lib/generators/templates/install/auto/public/404.html +26 -0
- data/lib/generators/templates/install/auto/public/500.html +25 -0
- data/lib/generators/templates/install/database.yml +19 -0
- data/lib/generators/templates/install/deploy.rb.erb +21 -0
- data/lib/generators/templates/install/install_devise/ability.rb +49 -0
- data/lib/generators/templates/install/install_devise/application.rb +7 -0
- data/lib/generators/templates/install/install_devise/prepare_users.rb +1 -0
- data/lib/generators/templates/install/install_devise/user.rb +21 -0
- data/lib/generators/templates/install/prepare_settings.rb +4 -0
- data/lib/generators/templates/install/routes/pages.rb +18 -0
- data/lib/generators/templates/install/routes.rb.erb +53 -0
- data/lib/generators/templates/install/settings_migration.rb +16 -0
- data/lib/generators/templates/install/webpack/custom.js +36 -0
- data/lib/generators/templates/install/webpack/environment.js +4 -0
- data/lib/generators/templates/install/webpack/javascript/admin/js/index.js +2 -0
- data/lib/generators/templates/install/webpack/javascript/admin/styles/admin.scss +2 -0
- data/lib/generators/templates/install/webpack/javascript/packs/admin.js +2 -0
- data/package-lock.json +3 -0
- data/spec/config/database.yml +2 -0
- data/spec/db/schema.rb +0 -0
- data/spec/lib/adminos/helpers/models/apply_sortable_order.rb +26 -0
- data/spec/lib/adminos/helpers/models/array_attrs_spec.rb +38 -0
- data/spec/lib/adminos/helpers/models/dom_id_spec.rb +41 -0
- data/spec/lib/adminos/helpers/models/flag_attrs_spec.rb +115 -0
- data/spec/lib/adminos/helpers/models/if_blank_set_to_nil_params_spec.rb +36 -0
- data/spec/lib/adminos/helpers/models/recognizable_spec.rb +40 -0
- data/spec/lib/adminos/helpers/models/slugged.rb +40 -0
- data/spec/lib/generators/adminos/adminos_generator_spec.rb +106 -0
- data/spec/lib/generators/adminos/ci_generator_spec.rb +88 -0
- data/spec/lib/generators/adminos/i18n_generator_spec.rb +31 -0
- data/spec/lib/generators/adminos/install_generator_rspec.rb +322 -0
- data/spec/spec_helper.rb +122 -0
- data/spec/support/ammeter.rb +14 -0
- data/spec/support/database.rb +29 -0
- data/spec/support/generators.rb +99 -0
- data/spec/support/post.rb +8 -0
- data/spec/support/shared/generator.rb +35 -0
- metadata +632 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d81796250feb6e1aa2d2fd09cdef36acd168b8c92f05af8dc6854db9b8106529
|
4
|
+
data.tar.gz: 421a234d3f208e98c497f941b591dcec9c5141801bec1605db40434108fa1ea2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c813a2d485a528460f3507f61fa404d610e035547b2c6bae80af35ed432e84a6d7d282ad45826cefcdecf2d1edb3af2135810426de909ecf786e660f7de61c0
|
7
|
+
data.tar.gz: ff2d6772b3b57eee01438148bb9a6c503df2a3a9d7302b08dea521b6ce8ca6437bf456d2a12824698f34f46630b72bd453b68de4970049d7ac0216cfd1570f92
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/dummy
|
17
|
+
test/dummy_with_locale
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
.DS_Store
|
21
|
+
.idea
|
22
|
+
spec/examples.txt
|
23
|
+
coverage
|
24
|
+
dummy_test
|
25
|
+
.ruby-version
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
before_script:
|
2
|
+
- ruby -v
|
3
|
+
- rvm install 2.5.1
|
4
|
+
- rvm use 2.5.1
|
5
|
+
- gem install bundler
|
6
|
+
- bundle
|
7
|
+
|
8
|
+
test:
|
9
|
+
script: rspec
|
10
|
+
artifacts:
|
11
|
+
paths:
|
12
|
+
- coverage
|
13
|
+
|
14
|
+
lint:
|
15
|
+
script: rake lint
|
16
|
+
allow_failure: true
|
17
|
+
artifacts:
|
18
|
+
untracked: true
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
6
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
7
|
+
DisabledByDefault: true
|
8
|
+
Exclude:
|
9
|
+
- tmp/
|
10
|
+
- bin
|
11
|
+
- lib/generators/templates/install/
|
12
|
+
|
13
|
+
# Prefer &&/|| over and/or.
|
14
|
+
Style/AndOr:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
# Do not use braces for hash literals when they are the last argument of a
|
18
|
+
# method call.
|
19
|
+
Style/BracesAroundHashParameters:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
# Align `when` with `case`.
|
23
|
+
Layout/CaseIndentation:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
# Align comments with method definitions.
|
27
|
+
Layout/CommentIndentation:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
# No extra empty lines.
|
31
|
+
Layout/EmptyLines:
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
# In a regular class definition, no empty lines around the body.
|
35
|
+
Layout/EmptyLinesAroundClassBody:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
# In a regular method definition, no empty lines around the body.
|
39
|
+
Layout/EmptyLinesAroundMethodBody:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
# In a regular module definition, no empty lines around the body.
|
43
|
+
Layout/EmptyLinesAroundModuleBody:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
47
|
+
Style/HashSyntax:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
51
|
+
# extra level of indentation.
|
52
|
+
Layout/IndentationConsistency:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
# Two spaces, no tabs (for indentation).
|
56
|
+
Layout/IndentationWidth:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Layout/SpaceAfterColon:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
Layout/SpaceAfterComma:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
Layout/SpaceAroundKeyword:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Layout/SpaceAroundOperators:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
Layout/SpaceBeforeFirstArg:
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
# Defining a method with parameters needs parentheses.
|
78
|
+
Style/MethodDefParentheses:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
# Use `foo {}` not `foo{}`.
|
82
|
+
Layout/SpaceBeforeBlockBraces:
|
83
|
+
Enabled: true
|
84
|
+
|
85
|
+
# Use `foo { bar }` not `foo {bar}`.
|
86
|
+
Layout/SpaceInsideBlockBraces:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
90
|
+
Layout/SpaceInsideHashLiteralBraces:
|
91
|
+
Enabled: true
|
92
|
+
|
93
|
+
Layout/SpaceInsideParens:
|
94
|
+
Enabled: true
|
95
|
+
|
96
|
+
# Detect hard tabs, no hard tabs.
|
97
|
+
Layout/Tab:
|
98
|
+
Enabled: true
|
99
|
+
|
100
|
+
# Blank lines should not have any spaces.
|
101
|
+
Layout/TrailingBlankLines:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
# No trailing whitespace.
|
105
|
+
Layout/TrailingWhitespace:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
# Use quotes for string literals when they are enough.
|
109
|
+
Style/UnneededPercentQ:
|
110
|
+
Enabled: true
|
111
|
+
|
112
|
+
# Align `end` with the matching keyword or starting expression except for
|
113
|
+
# assignments, where it should be aligned with the LHS.
|
114
|
+
Layout/EndAlignment:
|
115
|
+
Enabled: true
|
116
|
+
EnforcedStyleAlignWith: variable
|
117
|
+
|
118
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
119
|
+
Lint/RequireParentheses:
|
120
|
+
Enabled: true
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-09-11 11:57:46 +0300 using RuboCop version 0.59.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Layout/EmptyLines:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/generators/templates/install/admin_panel/users/admin_users_controller.rb'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
# Cop supports --auto-correct.
|
17
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
18
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
19
|
+
Layout/EndAlignment:
|
20
|
+
Exclude:
|
21
|
+
- 'lib/generators/templates/install/install_devise/ability.rb'
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: EnforcedStyle.
|
26
|
+
# SupportedStyles: normal, rails
|
27
|
+
Layout/IndentationConsistency:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/adminos/controllers/resource.rb'
|
30
|
+
|
31
|
+
# Offense count: 2
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
34
|
+
Layout/IndentationWidth:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/adminos/controllers/resource.rb'
|
37
|
+
- 'lib/generators/templates/install/install_devise/ability.rb'
|
38
|
+
|
39
|
+
# Offense count: 2
|
40
|
+
# Cop supports --auto-correct.
|
41
|
+
# Configuration parameters: EnforcedStyle.
|
42
|
+
# SupportedStyles: space, no_space
|
43
|
+
Layout/SpaceInsideParens:
|
44
|
+
Exclude:
|
45
|
+
- 'lib/generators/templates/install/routes/pages.rb'
|
46
|
+
|
47
|
+
# Offense count: 1
|
48
|
+
# Cop supports --auto-correct.
|
49
|
+
# Configuration parameters: AllowInHeredoc.
|
50
|
+
Layout/TrailingWhitespace:
|
51
|
+
Exclude:
|
52
|
+
- 'lib/generators/templates/install/install_devise/user.rb'
|
53
|
+
|
54
|
+
# Offense count: 217
|
55
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
56
|
+
# URISchemes: http, https
|
57
|
+
Metrics/LineLength:
|
58
|
+
Max: 249
|
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
gem 'rubocop', require: false
|
5
|
+
gem 'tty-command'
|
6
|
+
gem 'pry'
|
7
|
+
|
8
|
+
gem 'geminabox', '~> 1.1'
|
9
|
+
gem 'activerecord'
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem 'guard-bundler'
|
13
|
+
gem 'guard-rspec'
|
14
|
+
gem 'guard-rubocop'
|
15
|
+
|
16
|
+
gem 'terminal-notifier'
|
17
|
+
gem 'terminal-notifier-guard'
|
18
|
+
end
|
19
|
+
|
20
|
+
gem 'guard-minitest', '~> 2.4'
|
21
|
+
gem 'globalize'
|
22
|
+
gem 'friendly_id'
|
23
|
+
gem 'activerecord-nulldb-adapter', git: 'git://github.com/nulldb/nulldb.git'
|
24
|
+
gem 'sqlite3'
|
25
|
+
gem 'database_cleaner'
|
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# @see https://github.com/guard/guard#readme
|
2
|
+
|
3
|
+
notification :terminal_notifier
|
4
|
+
|
5
|
+
guard :bundler do
|
6
|
+
require 'guard/bundler'
|
7
|
+
require 'guard/bundler/verify'
|
8
|
+
helper = Guard::Bundler::Verify.new
|
9
|
+
|
10
|
+
files = ['Gemfile']
|
11
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
12
|
+
|
13
|
+
# Assume files are symlinked from somewhere
|
14
|
+
files.each { |file| watch(helper.real_path(file)) }
|
15
|
+
end
|
16
|
+
|
17
|
+
guard :rspec, cmd: "bin/rspec" do
|
18
|
+
require "guard/rspec/dsl"
|
19
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
20
|
+
|
21
|
+
# RSpec files
|
22
|
+
rspec = dsl.rspec
|
23
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
24
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
25
|
+
watch(rspec.spec_files)
|
26
|
+
|
27
|
+
# Ruby files
|
28
|
+
ruby = dsl.ruby
|
29
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
30
|
+
|
31
|
+
# Rails files
|
32
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
33
|
+
dsl.watch_spec_files_for(rails.app_files)
|
34
|
+
dsl.watch_spec_files_for(rails.views)
|
35
|
+
|
36
|
+
watch(rails.controllers) do |m|
|
37
|
+
[
|
38
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
39
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
40
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Rails config changes
|
45
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
46
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
47
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
48
|
+
|
49
|
+
# Capybara features specs
|
50
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
51
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
52
|
+
|
53
|
+
# Turnip features and steps
|
54
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
55
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
56
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
guard :rubocop do
|
61
|
+
watch(%r{.+\.rb$})
|
62
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
63
|
+
end
|
64
|
+
|
65
|
+
guard :minitest do
|
66
|
+
# with Minitest::Unit
|
67
|
+
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
68
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
69
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
70
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 TODO: Write your name
|
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,88 @@
|
|
1
|
+
![Adminos Logo](https://raw.github.com/molinos/adminos/master/adminos.png)
|
2
|
+
|
3
|
+
# Adminos
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install initial adminos-structured files with
|
8
|
+
|
9
|
+
$ rails g adminos:install
|
10
|
+
|
11
|
+
To add locales to installation:
|
12
|
+
|
13
|
+
$ rails g adminos:install --locales=en,cn
|
14
|
+
|
15
|
+
Russian language is added and made the default one by default.
|
16
|
+
|
17
|
+
## Model generation
|
18
|
+
|
19
|
+
Generate adminos model with
|
20
|
+
|
21
|
+
$ rails g adminos Model field:string body:text --type=sortable
|
22
|
+
|
23
|
+
Name, slug, published, meta_description and meta_title fields are always added.
|
24
|
+
|
25
|
+
Available model types are: default(if no type is present), section, sortable and table.
|
26
|
+
|
27
|
+
For section type, in you model must defined MAX_DEPTH constant (3 by default).
|
28
|
+
|
29
|
+
Add sorting to field:
|
30
|
+
|
31
|
+
$ rails g adminos Model field:string:sort --type=table
|
32
|
+
|
33
|
+
Type table is required for sorting to function properly. Sorting by name is added by default.
|
34
|
+
|
35
|
+
Add search form:
|
36
|
+
|
37
|
+
$ rails g adminos Model body:text --search=name,body
|
38
|
+
|
39
|
+
Specify the fields to search in. It is performed using pg_search gem and directed towards quick word-based search solution, but can be customized further.
|
40
|
+
|
41
|
+
If the model will be in multiple locales, you can specify which fields to translate:
|
42
|
+
|
43
|
+
$ rails g adminos Model field:string:locale body:text:locale
|
44
|
+
|
45
|
+
To translate default fields in case no locale specific custom fields are present, add --locale option:
|
46
|
+
|
47
|
+
$ rails g adminos Model --locale
|
48
|
+
|
49
|
+
If no need in SEO fields, switch it off using `--no-seo`.
|
50
|
+
|
51
|
+
$ rails g adminos Model --no-seo
|
52
|
+
|
53
|
+
## Features
|
54
|
+
### Cropped
|
55
|
+
model
|
56
|
+
```ruby
|
57
|
+
class User < ApplicationRecord
|
58
|
+
include Adminos::Cropped
|
59
|
+
|
60
|
+
has_one_attached :avatar
|
61
|
+
has_one_attached :photo
|
62
|
+
|
63
|
+
cropped :avatar
|
64
|
+
cropped :photo
|
65
|
+
end
|
66
|
+
```
|
67
|
+
view
|
68
|
+
```slim
|
69
|
+
# admin
|
70
|
+
# aspect_ratio default 16/9
|
71
|
+
= f.input :avatar, as: :cropp, input_html: { aspect_ratio: 2/3 }
|
72
|
+
= f.input :photo, as: :cropp
|
73
|
+
|
74
|
+
# public
|
75
|
+
= image_tag object.avatar_cropped
|
76
|
+
= image_tag object.photo_cropped
|
77
|
+
```
|
78
|
+
|
79
|
+
## Deploy the application
|
80
|
+
|
81
|
+
#### Prepare config files.
|
82
|
+
|
83
|
+
$ cap staging deploy:check
|
84
|
+
$ cap staging deploy
|
85
|
+
|
86
|
+
#### Tests
|
87
|
+
|
88
|
+
$ rspec
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.pattern = 'test/generators/*_test.rb'
|
9
|
+
t.verbose = true
|
10
|
+
t.warning = false
|
11
|
+
end
|
12
|
+
task default: :test
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
task defualt: :spec
|
16
|
+
|
17
|
+
RuboCop::RakeTask.new
|
18
|
+
task lint: :rubocop
|
19
|
+
|
20
|
+
task default: :lint
|
data/adminos.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'adminos'
|
3
|
+
gem.version = '1.0.0-rc.1'
|
4
|
+
gem.authors = ['RavWar', 'milushov', 'abuhtoyarov', 'SiebenSieben']
|
5
|
+
gem.email = ['studio@molinos.ru']
|
6
|
+
gem.homepage = 'https://gitlab.molinos.ru/global/adminos'
|
7
|
+
gem.summary = 'Adminos'
|
8
|
+
gem.description = 'A framework for creating admin dashboards'
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($/)
|
11
|
+
gem.test_files = gem.files.grep %r{^spec/}
|
12
|
+
gem.require_paths = %w(lib)
|
13
|
+
gem.bindir = 'exe'
|
14
|
+
gem.executables = `git ls-files -- #{gem.bindir}/*`.split($/).map { |f| File.basename(f) }
|
15
|
+
|
16
|
+
gem.add_dependency 'path'
|
17
|
+
gem.add_dependency 'jquery-fileupload-rails'
|
18
|
+
gem.add_dependency 'railties', '~> 5.1'
|
19
|
+
gem.add_dependency 'dotenv-rails'
|
20
|
+
gem.add_dependency 'slim-rails'
|
21
|
+
gem.add_dependency 'friendly_id'
|
22
|
+
gem.add_dependency 'babosa'
|
23
|
+
gem.add_dependency 'simple_form'
|
24
|
+
gem.add_dependency 'kaminari'
|
25
|
+
gem.add_dependency 'russian'
|
26
|
+
gem.add_dependency 'devise'
|
27
|
+
gem.add_dependency 'cancancan'
|
28
|
+
gem.add_dependency 'cocoon'
|
29
|
+
gem.add_dependency 'awesome_nested_set'
|
30
|
+
|
31
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
32
|
+
gem.add_development_dependency 'm'
|
33
|
+
gem.add_development_dependency 'rails'
|
34
|
+
gem.add_development_dependency 'rake'
|
35
|
+
gem.add_development_dependency 'ammeter'
|
36
|
+
gem.add_development_dependency 'simplecov'
|
37
|
+
end
|
data/adminos.png
ADDED
Binary file
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
3
|
+
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
4
|
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
5
|
+
width="700.000000pt" height="700.000000pt" viewBox="0 0 700.000000 700.000000"
|
6
|
+
preserveAspectRatio="xMidYMid meet">
|
7
|
+
<metadata>
|
8
|
+
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
9
|
+
</metadata>
|
10
|
+
<g transform="translate(0.000000,700.000000) scale(0.100000,-0.100000)"
|
11
|
+
fill="#000000" stroke="none">
|
12
|
+
<path d="M0 3500 l0 -3500 3500 0 3500 0 0 3500 0 3500 -3500 0 -3500 0 0
|
13
|
+
-3500z m4390 268 l768 -1689 -115 3 -115 3 -223 495 -223 495 -458 2 -459 3
|
14
|
+
-255 -500 -255 -500 -604 0 c-570 0 -603 1 -597 18 4 9 387 753 850 1652 464
|
15
|
+
899 856 1659 871 1689 24 48 29 52 37 36 6 -10 356 -778 778 -1707z"/>
|
16
|
+
<path d="M3180 4224 c-232 -445 -438 -837 -457 -871 l-35 -63 374 0 373 0 249
|
17
|
+
493 249 492 -157 365 c-87 201 -161 371 -165 379 -5 8 -160 -277 -431 -795z"/>
|
18
|
+
<path d="M3852 3667 c-100 -203 -181 -372 -179 -374 2 -2 163 -2 358 -1 l355
|
19
|
+
3 -171 367 c-94 202 -173 369 -175 371 -3 2 -87 -162 -188 -366z"/>
|
20
|
+
<path d="M2456 2813 c-77 -148 -170 -328 -208 -400 l-70 -133 374 0 373 0 198
|
21
|
+
395 c108 217 197 397 197 400 0 3 -163 5 -363 5 l-362 0 -139 -267z"/>
|
22
|
+
</g>
|
23
|
+
</svg>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class CroppInput < SimpleForm::Inputs::Base
|
2
|
+
def input(wrapper_options = nil)
|
3
|
+
out = []
|
4
|
+
out << %{<div class="f-file">}
|
5
|
+
out << %{ <label class="f-file__selection js-file">}
|
6
|
+
out << %{ <span class="f-file__button">Выбрать</span>}
|
7
|
+
out << @builder.file_field(attribute_name, input_html_options)
|
8
|
+
out << @builder.hidden_field(object.send("#{attribute_name}_attr_coord"))
|
9
|
+
out << %{ <span class="f-file__selected"></span>}
|
10
|
+
out << %{ </label>}
|
11
|
+
out << %{</div>}
|
12
|
+
out << preview
|
13
|
+
|
14
|
+
out.join.html_safe
|
15
|
+
end
|
16
|
+
|
17
|
+
def preview
|
18
|
+
return unless object.send(attribute_name).attached?
|
19
|
+
out = []
|
20
|
+
aspect_ratio = input_html_options.delete(:aspect_ratio) || 16/9
|
21
|
+
out << %{<div class="row"><div class="col-md-8"><div class="img-container">}
|
22
|
+
|
23
|
+
out << template.image_tag(object.send(attribute_name), data: { aspect_ratio: aspect_ratio, preview: ".#{attribute_name}_preview", toggle: 'cropp', coord: object.send("#{attribute_name}_attr_coord") })
|
24
|
+
|
25
|
+
out << %{</div></div><div class="col-md-4">}
|
26
|
+
out << %{<div class="docs-preview clearfix">}
|
27
|
+
out << %{<div class="img-preview preview-lg #{attribute_name}_preview"></div>}
|
28
|
+
out << cropped
|
29
|
+
|
30
|
+
out << %{</div></div></div>}
|
31
|
+
out.join
|
32
|
+
end
|
33
|
+
|
34
|
+
def cropped
|
35
|
+
return if object.send("#{attribute_name}_attr_coord").blank?
|
36
|
+
|
37
|
+
out = []
|
38
|
+
out << %{<div class="preview-cropped"><figure class="figure">}
|
39
|
+
|
40
|
+
out << template.image_tag(object.send("#{attribute_name}_cropped"))
|
41
|
+
|
42
|
+
out << %{<figcaption class="figure-caption text-center">Cropped image</figcaption></figure></div>}
|
43
|
+
out.join
|
44
|
+
end
|
45
|
+
end
|