rails_com 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -165
- data/README.md +45 -22
- data/Rakefile +2 -1
- data/app/apis/ali_dns.rb +66 -0
- data/app/assets/images/avatar.png +0 -0
- data/app/channels/com/session_channel.rb +16 -0
- data/app/channels/rails_com/connection.rb +31 -0
- data/app/controllers/admin_controller.rb +4 -0
- data/app/controllers/application_controller.rb +7 -0
- data/app/controllers/base_controller.rb +2 -0
- data/app/controllers/board/base_controller.rb +3 -0
- data/app/controllers/board/home_controller.rb +6 -0
- data/app/controllers/board_controller.rb +3 -0
- data/app/controllers/com/audios_controller.rb +27 -0
- data/app/controllers/com/base_controller.rb +4 -0
- data/app/controllers/com/common_controller.rb +69 -0
- data/app/controllers/com/controller/admin.rb +114 -0
- data/app/controllers/com/controller/err_handler.rb +13 -0
- data/app/controllers/com/direct_uploads_controller.rb +11 -0
- data/app/controllers/com/log_controller.rb +30 -0
- data/app/controllers/com/nodes_controller.rb +22 -0
- data/app/controllers/com/panel/acme_accounts_controller.rb +12 -0
- data/app/controllers/com/panel/acme_identifiers_controller.rb +31 -0
- data/app/controllers/com/panel/acme_orders_controller.rb +64 -0
- data/app/controllers/com/panel/attachments_controller.rb +31 -0
- data/app/controllers/com/panel/base_controller.rb +5 -0
- data/app/controllers/com/panel/blob_defaults_controller.rb +13 -0
- data/app/controllers/com/panel/blobs_controller.rb +52 -0
- data/app/controllers/com/panel/cache_lists_controller.rb +5 -0
- data/app/controllers/com/panel/csps_controller.rb +18 -0
- data/app/controllers/com/panel/errs_controller.rb +18 -0
- data/app/controllers/com/panel/inbound_emails_controller.rb +15 -0
- data/app/controllers/com/panel/infos_controller.rb +9 -0
- data/app/controllers/com/panel/meta_actions_controller.rb +46 -0
- data/app/controllers/com/panel/meta_businesses_controller.rb +21 -0
- data/app/controllers/com/panel/meta_columns_controller.rb +47 -0
- data/app/controllers/com/panel/meta_controllers_controller.rb +46 -0
- data/app/controllers/com/panel/meta_models_controller.rb +32 -0
- data/app/controllers/com/panel/meta_namespaces_controller.rb +29 -0
- data/app/controllers/com/pdfs_controller.rb +37 -0
- data/app/controllers/com/videos_controller.rb +28 -0
- data/app/controllers/home_controller.rb +6 -0
- data/app/controllers/my/base_controller.rb +4 -0
- data/app/controllers/my/home_controller.rb +8 -0
- data/app/controllers/my_controller.rb +3 -0
- data/app/controllers/panel/base_controller.rb +4 -0
- data/app/controllers/panel/home_controller.rb +8 -0
- data/app/controllers/panel_controller.rb +5 -0
- data/app/controllers/rails_com/application.rb +113 -0
- data/app/helpers/rails_com/active_helper.rb +35 -39
- data/app/helpers/rails_com/form_helper.rb +21 -0
- data/app/helpers/rails_com/format_helper.rb +13 -0
- data/app/helpers/rails_com/frame_helper.rb +13 -0
- data/app/helpers/rails_com/kaminari_helper.rb +9 -0
- data/app/helpers/rails_com/time_helper.rb +23 -0
- data/app/helpers/rails_com/url_helper.rb +12 -0
- data/app/jobs/active_storage/identify_job.rb +9 -0
- data/app/jobs/application_job.rb +2 -0
- data/app/jobs/com/acme_job.rb +9 -0
- data/app/jobs/com/err_job.rb +10 -0
- data/app/mailboxes/application_mailbox.rb +2 -0
- data/app/mailers/application_mailer.rb +3 -0
- data/app/models/com/acme_account.rb +5 -0
- data/app/models/com/acme_identifier.rb +5 -0
- data/app/models/com/acme_order.rb +5 -0
- data/app/models/com/application_record.rb +5 -0
- data/app/models/com/blob_default.rb +5 -0
- data/app/models/com/cache_list.rb +5 -0
- data/app/models/com/csp.rb +5 -0
- data/app/models/com/err.rb +5 -0
- data/app/models/com/ext/debug.rb +71 -0
- data/app/models/com/ext/extra.rb +20 -0
- data/app/models/com/ext/parameter.rb +19 -0
- data/app/models/com/ext/sequence.rb +36 -0
- data/app/models/com/ext/state_machine.rb +82 -0
- data/app/models/com/ext/taxon.rb +81 -0
- data/app/models/com/ext/taxon_prepend.rb +21 -0
- data/app/models/com/info.rb +5 -0
- data/app/models/com/meta_action.rb +5 -0
- data/app/models/com/meta_business.rb +5 -0
- data/app/models/com/meta_column.rb +5 -0
- data/app/models/com/meta_controller.rb +5 -0
- data/app/models/com/meta_model.rb +5 -0
- data/app/models/com/meta_namespace.rb +5 -0
- data/app/models/com/meta_operation.rb +5 -0
- data/app/models/com/meta_route.rb +5 -0
- data/app/models/com/model/acme_account.rb +70 -0
- data/app/models/com/model/acme_identifier.rb +132 -0
- data/app/models/com/model/acme_order.rb +139 -0
- data/app/models/com/model/blob_default.rb +36 -0
- data/app/models/com/model/cache_list.rb +15 -0
- data/app/models/com/model/csp.rb +23 -0
- data/app/models/com/model/err.rb +108 -0
- data/app/models/com/model/info.rb +31 -0
- data/app/models/com/model/meta_action.rb +70 -0
- data/app/models/com/model/meta_business.rb +66 -0
- data/app/models/com/model/meta_column.rb +36 -0
- data/app/models/com/model/meta_controller.rb +115 -0
- data/app/models/com/model/meta_model.rb +58 -0
- data/app/models/com/model/meta_namespace.rb +61 -0
- data/app/models/com/model/meta_operation.rb +18 -0
- data/app/models/com/model/meta_permission.rb +10 -0
- data/app/models/com/model/meta_relation.rb +6 -0
- data/app/models/com/model/meta_route.rb +10 -0
- data/app/models/com.rb +11 -0
- data/app/models/concerns/feishu_bot.rb +15 -0
- data/app/models/concerns/log_record_bot.rb +40 -0
- data/app/models/concerns/work_wechat_bot.rb +18 -0
- data/app/stores/com/env_yaml.rb +96 -0
- data/app/stores/com/yaml.rb +89 -0
- data/app/views/admin/_breadcrumb.html.erb +5 -0
- data/app/views/application/_actionsheet.html.erb +20 -0
- data/app/views/application/_alert.html+phone.erb +6 -0
- data/app/views/application/_alert.html.erb +9 -0
- data/app/views/application/_auth_navbar.html.erb +18 -0
- data/app/views/application/_breadcrumb.html.erb +0 -0
- data/app/views/application/_button.html+phone.erb +3 -0
- data/app/views/application/_button.html.erb +3 -0
- data/app/views/application/_edit_form.html+phone.erb +10 -0
- data/app/views/application/_edit_form.html.erb +4 -0
- data/app/views/application/_error_messages.html.erb +11 -0
- data/app/views/application/_filter_form.html+phone.erb +14 -0
- data/app/views/application/_filter_form.html.erb +9 -0
- data/app/views/application/_filter_table.html.erb +0 -0
- data/app/views/application/_footer.html.erb +8 -0
- data/app/views/application/_form.html.erb +4 -0
- data/app/views/application/_index_sortable_table.html.erb +22 -0
- data/app/views/application/_index_table.html+phone.erb +13 -0
- data/app/views/application/_index_table.html.erb +22 -0
- data/app/views/application/_index_tbody.html.erb +3 -0
- data/app/views/application/_index_thead.html.erb +4 -0
- data/app/views/application/_index_tr.html+phone.erb +4 -0
- data/app/views/application/_index_tr.html.erb +16 -0
- data/app/views/application/_index_tree_table.html.erb +18 -0
- data/app/views/application/_locales.html.erb +11 -0
- data/app/views/application/_modal.html+phone.erb +14 -0
- data/app/views/application/_modal.html.erb +14 -0
- data/app/views/application/_nav.html.erb +0 -0
- data/app/views/application/_nav_bar.html+phone.erb +0 -0
- data/app/views/application/_nav_bar.html.erb +25 -0
- data/app/views/application/_nav_brand.html.erb +3 -0
- data/app/views/application/_nav_with_login.html.erb +0 -0
- data/app/views/application/_nav_without_login.html.erb +0 -0
- data/app/views/application/_new_form.html+phone.erb +10 -0
- data/app/views/application/_new_form.html.erb +4 -0
- data/app/views/application/_pagination.json.jbuilder +7 -0
- data/app/views/application/_show.html+phone.erb +20 -0
- data/app/views/application/_show.html.erb +13 -0
- data/app/views/application/_show_table.html.erb +0 -0
- data/app/views/application/_tab_bar.html.erb +3 -0
- data/app/views/application/_tab_bar_item.erb +4 -0
- data/app/views/application/alert.turbo_stream.erb +1 -0
- data/app/views/application/controller_not_found.json.jbuilder +4 -0
- data/app/views/application/create.json.jbuilder +1 -0
- data/app/views/application/create.turbo_stream.erb +3 -0
- data/app/views/application/destroy.json.jbuilder +0 -0
- data/app/views/application/destroy.turbo_stream.erb +3 -0
- data/app/views/application/edit.html.erb +7 -0
- data/app/views/application/edit.json.jbuilder +2 -0
- data/app/views/{shared/_error_messages.html.erb → application/err.turbo_stream.erb} +4 -4
- data/app/views/application/index.html.erb +5 -0
- data/app/views/application/index.json.jbuilder +1 -0
- data/app/views/application/move_higher.turbo_stream.erb +3 -0
- data/app/views/application/move_lower.turbo_stream.erb +3 -0
- data/app/views/application/new.html.erb +7 -0
- data/app/views/application/new.json.jbuilder +2 -0
- data/app/views/application/show.html.erb +3 -0
- data/app/views/application/show.json.jbuilder +1 -0
- data/app/views/application/update.json.jbuilder +1 -0
- data/app/views/application/update.turbo_stream.erb +3 -0
- data/app/views/board/home/index.html.erb +0 -0
- data/app/views/com/attachments/_file_upload.html.erb +19 -0
- data/app/views/com/attachments/_image_preview.html.erb +9 -0
- data/app/views/com/attachments/_list.html.erb +31 -0
- data/app/views/com/attachments/_list_edit.html.erb +28 -0
- data/app/views/com/attachments/_list_field.html.erb +6 -0
- data/app/views/com/attachments/_list_many.html.erb +17 -0
- data/app/views/com/attachments/_video_item.html.erb +6 -0
- data/app/views/com/audios/show.html.erb +3 -0
- data/app/views/com/common/deploy.html.erb +0 -0
- data/app/views/com/common/info.json.jbuilder +1 -0
- data/app/views/com/extra/_extra_form.html.erb +5 -0
- data/app/views/com/extra/_item.html.erb +15 -0
- data/app/views/com/nodes/_children_options.html.erb +4 -0
- data/app/views/com/nodes/_children_select.html.erb +15 -0
- data/app/views/com/nodes/_outer_children_options.html.erb +4 -0
- data/app/views/com/nodes/_outer_options.html+phone.erb +2 -0
- data/app/views/com/nodes/_outer_options.html.erb +4 -0
- data/app/views/com/nodes/_outer_select.html.erb +12 -0
- data/app/views/com/nodes/_self_and_siblings_options.html.erb +4 -0
- data/app/views/com/nodes/_siblings_options.html.erb +4 -0
- data/app/views/com/nodes/_siblings_select.html.erb +14 -0
- data/app/views/com/nodes/children.turbo_stream.erb +3 -0
- data/app/views/com/nodes/outer.turbo_stream.erb +3 -0
- data/app/views/com/panel/acme_accounts/_filter_form.html.erb +9 -0
- data/app/views/com/panel/acme_accounts/_index_tbody.html.erb +7 -0
- data/app/views/com/panel/acme_accounts/_index_thead.html.erb +4 -0
- data/app/views/com/panel/acme_accounts/_index_tr.html.erb +16 -0
- data/app/views/com/panel/acme_identifiers/_breadcrumb.html.erb +7 -0
- data/app/views/com/panel/acme_identifiers/_button.html.erb +0 -0
- data/app/views/com/panel/acme_identifiers/_filter_form.html.erb +9 -0
- data/app/views/com/panel/acme_identifiers/_form.html.erb +2 -0
- data/app/views/com/panel/acme_identifiers/_index_tbody.html.erb +16 -0
- data/app/views/com/panel/acme_identifiers/_index_thead.html.erb +17 -0
- data/app/views/com/panel/acme_identifiers/_show_table.html.erb +24 -0
- data/app/views/com/panel/acme_identifiers/index.html.erb +3 -0
- data/app/views/com/panel/acme_orders/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/acme_orders/_filter_form.html.erb +9 -0
- data/app/views/com/panel/acme_orders/_form.html.erb +4 -0
- data/app/views/com/panel/acme_orders/_index_tbody.html.erb +11 -0
- data/app/views/com/panel/acme_orders/_index_thead.html.erb +8 -0
- data/app/views/com/panel/acme_orders/_index_tr.html.erb +25 -0
- data/app/views/com/panel/acme_orders/_item_form.html.erb +14 -0
- data/app/views/com/panel/acme_orders/_new_form.html.erb +7 -0
- data/app/views/com/panel/acme_orders/_show_table.html.erb +4 -0
- data/app/views/com/panel/attachments/_breadcrumb.html.erb +10 -0
- data/app/views/com/panel/attachments/_button.html.erb +0 -0
- data/app/views/com/panel/attachments/_filter_form.html.erb +13 -0
- data/app/views/com/panel/attachments/_index_tbody.html.erb +6 -0
- data/app/views/com/panel/attachments/_index_thead.html.erb +7 -0
- data/app/views/com/panel/attachments/_index_tr.html.erb +10 -0
- data/app/views/com/panel/attachments/index.html.erb +5 -0
- data/app/views/com/panel/base/_index_meta_action.html.erb +14 -0
- data/app/views/com/panel/base/_nav.html.erb +3 -0
- data/app/views/com/panel/blob_defaults/_add_form.html.erb +7 -0
- data/app/views/com/panel/blob_defaults/_filter_form.html.erb +10 -0
- data/app/views/com/panel/blob_defaults/_form.html.erb +4 -0
- data/app/views/com/panel/blob_defaults/_index_tbody.html.erb +7 -0
- data/app/views/com/panel/blob_defaults/_index_thead.html.erb +5 -0
- data/app/views/com/panel/blob_defaults/_index_tr.html.erb +13 -0
- data/app/views/com/panel/blob_defaults/add.turbo_stream.erb +1 -0
- data/app/views/com/panel/blobs/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/blobs/_filter_form.html.erb +13 -0
- data/app/views/com/panel/blobs/_index_tbody.html.erb +22 -0
- data/app/views/com/panel/blobs/_index_thead.html.erb +12 -0
- data/app/views/com/panel/blobs/_index_tr.html.erb +13 -0
- data/app/views/com/panel/blobs/_new_form.html.erb +5 -0
- data/app/views/com/panel/blobs/index.html.erb +5 -0
- data/app/views/com/panel/cache_lists/_index_tbody.html.erb +4 -0
- data/app/views/com/panel/cache_lists/_index_thead.html.erb +5 -0
- data/app/views/com/panel/cache_lists/_show_table.html.erb +8 -0
- data/app/views/com/panel/csps/_button.html.erb +0 -0
- data/app/views/com/panel/csps/_filter_form.html.erb +8 -0
- data/app/views/com/panel/csps/_index_tbody.html.erb +11 -0
- data/app/views/com/panel/csps/_index_thead.html.erb +12 -0
- data/app/views/com/panel/csps/_index_tr.html.erb +13 -0
- data/app/views/com/panel/csps/_show/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/csps/_show_table.html.erb +48 -0
- data/app/views/com/panel/csps/show.html.erb +7 -0
- data/app/views/com/panel/errs/_button.html.erb +0 -0
- data/app/views/com/panel/errs/_filter_form.html.erb +11 -0
- data/app/views/com/panel/errs/_index_tbody.html.erb +16 -0
- data/app/views/com/panel/errs/_index_thead.html.erb +11 -0
- data/app/views/com/panel/errs/_index_tr.html.erb +13 -0
- data/app/views/com/panel/errs/_show/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/errs/_show_table.html.erb +44 -0
- data/app/views/com/panel/errs/show.html.erb +7 -0
- data/app/views/com/panel/inbound_emails/_button.html.erb +0 -0
- data/app/views/com/panel/inbound_emails/_filter_form.html.erb +9 -0
- data/app/views/com/panel/inbound_emails/_index_tbody.html.erb +5 -0
- data/app/views/com/panel/inbound_emails/_index_thead.html.erb +6 -0
- data/app/views/com/panel/inbound_emails/_show_table.html.erb +10 -0
- data/app/views/com/panel/inbound_emails/index.html.erb +5 -0
- data/app/views/com/panel/infos/_filter_form.html.erb +9 -0
- data/app/views/com/panel/infos/_index_tbody.html.erb +4 -0
- data/app/views/com/panel/infos/_index_thead.html.erb +5 -0
- data/app/views/com/panel/infos/index.json.jbuilder +1 -0
- data/app/views/com/panel/meta_actions/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/meta_actions/_form.html.erb +1 -0
- data/app/views/com/panel/meta_actions/_index_tbody.html.erb +4 -0
- data/app/views/com/panel/meta_actions/_index_thead.html.erb +5 -0
- data/app/views/com/panel/meta_actions/_roles.html.erb +9 -0
- data/app/views/com/panel/meta_actions/index.html.erb +3 -0
- data/app/views/com/panel/meta_actions/roles.js.erb +6 -0
- data/app/views/com/panel/meta_actions/update.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_businesses/_breadcrumb.html.erb +10 -0
- data/app/views/com/panel/meta_businesses/_button.html.erb +3 -0
- data/app/views/com/panel/meta_businesses/_form.html.erb +3 -0
- data/app/views/com/panel/meta_businesses/_index_tbody.html.erb +12 -0
- data/app/views/com/panel/meta_businesses/_index_thead.html.erb +2 -0
- data/app/views/com/panel/meta_businesses/_index_tr.html.erb +16 -0
- data/app/views/com/panel/meta_businesses/_show_table.html.erb +8 -0
- data/app/views/com/panel/meta_businesses/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_columns/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/meta_columns/_form.html.erb +6 -0
- data/app/views/com/panel/meta_columns/_index_tbody.html.erb +20 -0
- data/app/views/com/panel/meta_columns/_index_thead.html.erb +12 -0
- data/app/views/com/panel/meta_columns/_index_tr.html.erb +22 -0
- data/app/views/com/panel/meta_columns/_show_table.html.erb +20 -0
- data/app/views/com/panel/meta_columns/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_columns/test.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_controllers/_button.html.erb +3 -0
- data/app/views/com/panel/meta_controllers/_filter_form.html.erb +8 -0
- data/app/views/com/panel/meta_controllers/_filter_tablex.html.erb +8 -0
- data/app/views/com/panel/meta_controllers/_form.html.erb +2 -0
- data/app/views/com/panel/meta_controllers/_index_meta_business.html.erb +10 -0
- data/app/views/com/panel/meta_controllers/_index_meta_controller.html.erb +15 -0
- data/app/views/com/panel/meta_controllers/_index_meta_namespace.html.erb +12 -0
- data/app/views/com/panel/meta_controllers/_index_tbody.html.erb +28 -0
- data/app/views/com/panel/meta_controllers/_index_thead.html.erb +2 -0
- data/app/views/com/panel/meta_controllers/index.html.erb +3 -0
- data/app/views/com/panel/meta_controllers/meta_actions.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_controllers/meta_controllers.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_controllers/meta_namespaces.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_controllers/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_models/_button.html.erb +6 -0
- data/app/views/com/panel/meta_models/_form.html.erb +4 -0
- data/app/views/com/panel/meta_models/_index_tbody.html.erb +3 -0
- data/app/views/com/panel/meta_models/_index_thead.html.erb +4 -0
- data/app/views/com/panel/meta_models/_index_tr.html.erb +19 -0
- data/app/views/com/panel/meta_models/_show_table.html.erb +12 -0
- data/app/views/com/panel/meta_models/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_namespaces/_breadcrumb.html.erb +10 -0
- data/app/views/com/panel/meta_namespaces/_button.html.erb +3 -0
- data/app/views/com/panel/meta_namespaces/_form.html.erb +5 -0
- data/app/views/com/panel/meta_namespaces/_index_tbody.html.erb +20 -0
- data/app/views/com/panel/meta_namespaces/_index_thead.html.erb +6 -0
- data/app/views/com/panel/meta_namespaces/_show_table.html.erb +20 -0
- data/app/views/com/panel/meta_namespaces/sync.turbo_stream.erb +3 -0
- data/app/views/com/videos/show.html.erb +9 -0
- data/app/{assets/javascripts/controllers/active_storage_ext/videos/show.ready.js → views/com/videos/show.js} +0 -0
- data/app/views/default_form/_date_field.html.erb +1 -0
- data/app/views/default_form/_datetime_field.html.erb +1 -0
- data/app/views/default_form/_number_field.html.erb +1 -0
- data/app/views/default_form/_outer_select.html.erb +14 -0
- data/app/views/default_form/_select_enum.html.erb +1 -0
- data/app/views/default_form/_text_field.html.erb +1 -0
- data/app/views/default_form/_time_field.html.erb +1 -0
- data/app/views/extra_form/_number_field.html.erb +1 -0
- data/app/views/extra_form/_outer_select.html.erb +14 -0
- data/app/views/extra_form/_text_field.html.erb +1 -0
- data/app/views/home/index.html.erb +0 -0
- data/app/views/kaminari/com/_first_page.html.erb +3 -0
- data/app/views/kaminari/{_gap.html.erb → com/_gap.html.erb} +1 -1
- data/app/views/kaminari/com/_last_page.html.erb +3 -0
- data/app/views/kaminari/com/_next_page.html.erb +3 -0
- data/app/views/kaminari/com/_page.html.erb +1 -0
- data/app/views/kaminari/{_paginator.html.erb → com/_paginator.html+phone.erb} +3 -3
- data/app/views/kaminari/com/_paginator.html.erb +17 -0
- data/app/views/kaminari/com/_prev_page.html.erb +3 -0
- data/app/views/layouts/_admin_head.html.erb +22 -0
- data/app/views/layouts/_application_head.html.erb +26 -0
- data/app/views/layouts/_phone_head.html.erb +28 -0
- data/app/views/layouts/admin.html.erb +12 -0
- data/app/views/layouts/application.html+phone.erb +12 -0
- data/app/views/layouts/application.html.erb +11 -0
- data/app/views/layouts/application.json.jbuilder +2 -0
- data/app/views/layouts/board.html+phone.erb +10 -0
- data/app/views/layouts/board.html.erb +12 -0
- data/app/views/layouts/mailer.html.erb +14 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/layouts/my.html+phone.erb +11 -0
- data/app/views/layouts/my.html.erb +13 -0
- data/app/views/layouts/panel.html.erb +12 -0
- data/app/views/my/home/index.html.erb +0 -0
- data/app/views/panel/_breadcrumb.html.erb +0 -0
- data/app/views/panel/_com_nav.html.erb +19 -0
- data/app/views/panel/_nav.html.erb +6 -0
- data/app/views/panel/_nav_without_login.html.erb +3 -0
- data/app/views/panel/destroy.turbo_stream.erb +1 -0
- data/app/views/panel/home/index.html.erb +0 -0
- data/config/default_form.yml +74 -0
- data/config/locales/en.controller.yml +46 -0
- data/config/locales/en.yml +2 -2
- data/config/locales/zh.attributes.yml +9 -0
- data/config/locales/zh.controller.yml +65 -0
- data/config/locales/zh.enum.yml +11 -0
- data/config/locales/zh.helper.yml +10 -0
- data/config/locales/zh.rb +34 -0
- data/config/locales/zh.yml +66 -10
- data/config/routes.rb +140 -8
- data/lib/active_storage/service/disc_service.rb +41 -0
- data/lib/default_form/active_record/extend.rb +38 -0
- data/lib/default_form/builder/default.rb +88 -0
- data/lib/default_form/builder/helper.rb +212 -0
- data/lib/default_form/builder/wrap.rb +58 -0
- data/lib/default_form/config.rb +50 -0
- data/lib/default_form/controller_helper.rb +14 -0
- data/lib/default_form/form_builder.rb +61 -0
- data/lib/default_form/override/action_view/helpers/tags/collection_check_boxes.rb +23 -0
- data/lib/default_form/override/action_view/helpers/tags/collection_radio_buttons.rb +23 -0
- data/lib/default_form/view_helper.rb +39 -0
- data/lib/generators/jbuilder_generator.rb +22 -0
- data/lib/generators/scaffold_generator.rb +27 -0
- data/lib/generators/templates/jbuilder/_show.json.jbuilder.tt +1 -0
- data/lib/generators/templates/jbuilder/index.json.jbuilder.tt +1 -0
- data/lib/generators/templates/jbuilder/partial.json.jbuilder.tt +17 -0
- data/lib/generators/templates/scaffold_erb/_edit_form.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_filter_form.html.erb.tt +9 -0
- data/lib/generators/templates/scaffold_erb/_form.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_index_tbody.html.erb.tt +3 -0
- data/lib/generators/templates/scaffold_erb/_index_thead.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_new_form.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_show_table.html.erb.tt +6 -0
- data/lib/generators/templates/scaffold_erb/index.html.erb.tt +5 -0
- data/lib/rails_com/action_controller/errors.rb +11 -0
- data/lib/rails_com/action_controller/extend.rb +20 -0
- data/lib/rails_com/action_controller/include.rb +31 -0
- data/lib/rails_com/action_controller/parameters.rb +19 -0
- data/lib/rails_com/action_controller/public_exceptions.rb +31 -0
- data/lib/rails_com/action_controller/subscriber.rb +32 -0
- data/lib/rails_com/action_controller.rb +9 -0
- data/lib/rails_com/action_mailbox/inbound_email.rb +23 -0
- data/lib/rails_com/action_mailbox/mail_ext.rb +34 -0
- data/lib/rails_com/action_mailbox.rb +4 -0
- data/lib/rails_com/action_text/rich_text.rb +16 -0
- data/lib/rails_com/action_text.rb +3 -0
- data/lib/rails_com/action_view/partial_renderer.rb +22 -0
- data/lib/rails_com/action_view/template_renderer.rb +41 -0
- data/lib/rails_com/action_view/translation_helper.rb +23 -0
- data/lib/rails_com/action_view.rb +5 -0
- data/lib/rails_com/{rails_ext → active_storage}/activestorage_attached.rb +7 -3
- data/lib/rails_com/active_storage/attached_macros.rb +32 -0
- data/lib/rails_com/active_storage/attachment_prepend.rb +14 -0
- data/lib/rails_com/{rails_ext → active_storage}/attachment_transfer.rb +15 -6
- data/lib/rails_com/{rails_ext → active_storage}/video_response.rb +6 -1
- data/lib/rails_com/active_storage.rb +9 -0
- data/lib/rails_com/all.rb +23 -0
- data/lib/rails_com/api.rb +24 -0
- data/lib/rails_com/config.rb +22 -14
- data/lib/rails_com/engine.rb +42 -21
- data/lib/rails_com/utils/hex_helper.rb +12 -0
- data/lib/rails_com/utils/jobber.rb +3 -1
- data/lib/rails_com/utils/num_helper.rb +7 -5
- data/lib/rails_com/utils/qrcode_helper.rb +35 -0
- data/lib/rails_com/utils/setting.rb +5 -5
- data/lib/rails_com/utils/time_helper.rb +2 -0
- data/lib/rails_com/utils/uid_helper.rb +22 -13
- data/lib/rails_com.rb +31 -29
- data/lib/templates/rails/scaffold_controller/api_controller.rb.tt +20 -19
- data/lib/templates/rails/scaffold_controller/controller.rb.tt +1 -52
- data/lib/templates/test_unit/scaffold/functional_test.rb.tt +64 -0
- metadata +558 -108
- data/app/assets/config/rails_com_manifest.js +0 -6
- data/app/assets/images/image-square.png +0 -0
- data/app/assets/images/verification.jpg +0 -0
- data/app/assets/javascripts/rails_com/application.js +0 -45
- data/app/assets/javascripts/rails_com/attachment.js +0 -416
- data/app/assets/javascripts/rails_com/checkbox.js +0 -59
- data/app/assets/javascripts/rails_com/fetch_xhr_script.js +0 -20
- data/app/assets/javascripts/rails_com/footer.js +0 -3
- data/app/assets/javascripts/rails_com/picture.js +0 -17
- data/app/assets/javascripts/rails_com/sidebar.js +0 -40
- data/app/assets/stylesheets/controllers/active_storage_ext/videos/show.css +0 -7
- data/app/assets/stylesheets/controllers/active_storage_ext/videos/transfer.css +0 -4
- data/app/assets/stylesheets/rails_com/application.css +0 -3
- data/app/controllers/active_storage_ext/admin/attachments_controller.rb +0 -13
- data/app/controllers/active_storage_ext/admin/base_controller.rb +0 -4
- data/app/controllers/active_storage_ext/admin/blob_defaults_controller.rb +0 -54
- data/app/controllers/active_storage_ext/admin/blobs_controller.rb +0 -48
- data/app/controllers/active_storage_ext/audios_controller.rb +0 -24
- data/app/controllers/active_storage_ext/videos_controller.rb +0 -25
- data/app/controllers/concerns/rails_common_api.rb +0 -50
- data/app/controllers/concerns/rails_common_xhr.rb +0 -15
- data/app/helpers/rails_com/assets_helper.rb +0 -91
- data/app/models/active_storage/blob_default.rb +0 -5
- data/app/models/concerns/state_machine.rb +0 -79
- data/app/views/active_storage_ext/admin/attachments/destroy.js.erb +0 -1
- data/app/views/active_storage_ext/admin/blob_defaults/_form.html.erb +0 -7
- data/app/views/active_storage_ext/admin/blob_defaults/_search_form.html.erb +0 -7
- data/app/views/active_storage_ext/admin/blob_defaults/edit.html.erb +0 -9
- data/app/views/active_storage_ext/admin/blob_defaults/index.html.erb +0 -48
- data/app/views/active_storage_ext/admin/blob_defaults/new.html.erb +0 -9
- data/app/views/active_storage_ext/admin/blob_defaults/show.html.erb +0 -10
- data/app/views/active_storage_ext/admin/blobs/_search_form.html.erb +0 -9
- data/app/views/active_storage_ext/admin/blobs/destroy.js.erb +0 -1
- data/app/views/active_storage_ext/admin/blobs/index.html.erb +0 -51
- data/app/views/active_storage_ext/admin/blobs/new.html.erb +0 -13
- data/app/views/active_storage_ext/admin/blobs/show.html.erb +0 -10
- data/app/views/active_storage_ext/attachments/_default_image_item.html.erb +0 -6
- data/app/views/active_storage_ext/attachments/_image_item.html.erb +0 -6
- data/app/views/active_storage_ext/attachments/_list.html.erb +0 -25
- data/app/views/active_storage_ext/attachments/_list_edit.html.erb +0 -25
- data/app/views/active_storage_ext/attachments/_list_form.html.erb +0 -28
- data/app/views/active_storage_ext/attachments/_video_item.html.erb +0 -6
- data/app/views/active_storage_ext/audios/show.html.erb +0 -5
- data/app/views/active_storage_ext/videos/show.html.erb +0 -6
- data/app/views/kaminari/_first_page.html.erb +0 -3
- data/app/views/kaminari/_last_page.html.erb +0 -3
- data/app/views/kaminari/_next_page.html.erb +0 -3
- data/app/views/kaminari/_page.html.erb +0 -1
- data/app/views/kaminari/_prev_page.html.erb +0 -3
- data/app/views/layouts/rails_com/application.html.erb +0 -17
- data/app/views/shared/_alert.html.erb +0 -8
- data/app/views/shared/_locales.html.erb +0 -8
- data/config/locales/zh.datetime.yml +0 -44
- data/db/migrate/20181012025833_rails_com_init.rb +0 -13
- data/lib/generators/doc_model_generator.rb +0 -37
- data/lib/generators/doc_models_generator.rb +0 -11
- data/lib/generators/templates/model.erb +0 -6
- data/lib/mina/git2.rb +0 -59
- data/lib/mina/puma.rb +0 -64
- data/lib/mina/sidekiq.rb +0 -67
- data/lib/mina/whenever.rb +0 -27
- data/lib/rails_com/core_ext/array.rb +0 -72
- data/lib/rails_com/core_ext/date.rb +0 -25
- data/lib/rails_com/core_ext/hash.rb +0 -38
- data/lib/rails_com/core_ext/nil.rb +0 -7
- data/lib/rails_com/core_ext/numeric.rb +0 -11
- data/lib/rails_com/core_ext/string.rb +0 -15
- data/lib/rails_com/helpers/controller_helper.rb +0 -30
- data/lib/rails_com/helpers/model_helper.rb +0 -107
- data/lib/rails_com/meta/controllers.rb +0 -8
- data/lib/rails_com/meta/models.rb +0 -21
- data/lib/rails_com/meta/routes.rb +0 -53
- data/lib/rails_com/rails_ext/attached_macros.rb +0 -21
- data/lib/rails_com/rails_ext/errors.rb +0 -4
- data/lib/rails_com/rails_ext/named_base.rb +0 -9
- data/lib/rails_com/rails_ext/persistence_sneakily.rb +0 -11
- data/lib/rails_com/rails_ext/scaffold_generator.rb +0 -15
- data/lib/rails_com/rails_ext/template_renderer.rb +0 -54
- data/lib/rails_com/rails_ext/translation_helper.rb +0 -18
- data/lib/rails_com/sprockets/non_digest_assets.rb +0 -16
- data/lib/rails_com/utils/babel.rb +0 -38
- data/lib/rails_com/version.rb +0 -3
- data/lib/tasks/rails_com_tasks.rake +0 -4
- data/lib/templates/erb/scaffold/_form.html.erb.tt +0 -12
- data/lib/templates/erb/scaffold/_search_form.html.erb.tt +0 -7
- data/lib/templates/erb/scaffold/edit.html.erb.tt +0 -9
- data/lib/templates/erb/scaffold/index.html.erb.tt +0 -47
- data/lib/templates/erb/scaffold/new.html.erb.tt +0 -9
- data/lib/templates/erb/scaffold/show.html.erb.tt +0 -16
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Com
|
3
|
+
module Ext::StateMachine
|
4
|
+
|
5
|
+
# to defined next_xxx_states in class
|
6
|
+
|
7
|
+
# obj.next_to state: 'xxx'
|
8
|
+
def next_to(options = {}, &block)
|
9
|
+
options.each do |column, value|
|
10
|
+
if self.class.method_defined? "next_#{column}_states"
|
11
|
+
_next_state = self.send("next_#{column}_states").first
|
12
|
+
else
|
13
|
+
_next_state = next_state(column, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
if _next_state == value.to_s
|
17
|
+
assign_attributes(column => value)
|
18
|
+
else
|
19
|
+
error_msg = "Next state is wrong, should be #{_next_state}"
|
20
|
+
errors.add column, error_msg
|
21
|
+
raise ActiveRecord::Rollback, error_msg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def next_to!(options = {}, &block)
|
27
|
+
self.next_to(options, &block)
|
28
|
+
self.save!
|
29
|
+
end
|
30
|
+
|
31
|
+
def trigger_to(options = {}, &block)
|
32
|
+
options.each do |column, value|
|
33
|
+
if self.class.method_defined? "next_#{column}_states"
|
34
|
+
_next_states = self.send "next_#{column}_states"
|
35
|
+
else
|
36
|
+
_next_states = next_states(column, &block)
|
37
|
+
end
|
38
|
+
|
39
|
+
if _next_states.include?(value.to_s)
|
40
|
+
assign_attributes(column => value)
|
41
|
+
else
|
42
|
+
error_msg = "Next state is wrong, should be one of #{_next_states.join(', ')}"
|
43
|
+
errors.add column, error_msg
|
44
|
+
raise ActiveRecord::Rollback, error_msg
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def trigger_to!(options = {}, &block)
|
50
|
+
self.trigger_to(options, &block)
|
51
|
+
self.save!
|
52
|
+
end
|
53
|
+
|
54
|
+
def next_state(state_name, &block)
|
55
|
+
next_states(state_name, &block).first
|
56
|
+
end
|
57
|
+
|
58
|
+
# obj.next_states(:state) do |result|
|
59
|
+
# result.reject
|
60
|
+
# end
|
61
|
+
def next_states(state_name, &block)
|
62
|
+
_states = self.class.send(state_name.to_s.pluralize)
|
63
|
+
_states = _states.keys
|
64
|
+
_state = self.send(state_name)
|
65
|
+
|
66
|
+
if _state.nil?
|
67
|
+
next_index = 0
|
68
|
+
else
|
69
|
+
i = _states.index(_state)
|
70
|
+
next_index = i + 1
|
71
|
+
end
|
72
|
+
result = _states[next_index..(_states.size - 1)]
|
73
|
+
|
74
|
+
if block_given?
|
75
|
+
yield block.call(result)
|
76
|
+
else
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# required fields
|
2
|
+
# :parent_id
|
3
|
+
require 'closure_tree'
|
4
|
+
module Com
|
5
|
+
module Ext::Taxon
|
6
|
+
|
7
|
+
def self.included(model)
|
8
|
+
if model.table_exists? && model.column_names.include?('position')
|
9
|
+
model.has_closure_tree order: 'position'
|
10
|
+
else
|
11
|
+
model.has_closure_tree
|
12
|
+
end
|
13
|
+
model.include Com::Ext::TaxonPrepend
|
14
|
+
|
15
|
+
model.attribute :parent_ancestors, :json, default: {}
|
16
|
+
model.before_validation :sync_parent_id, if: -> { parent_ancestors_changed? && (parent_ancestors.presence != parent_ancestors_was.presence) }
|
17
|
+
model.before_validation :set_parent_ancestors, if: -> { parent.present? && parent_ancestors.blank? } # todo 考虑 parent 改变的情况
|
18
|
+
model.hierarchy_class.attribute :generations, :integer, null: false
|
19
|
+
model.hierarchy_class.attribute :created_at, :datetime, null: true # 需要 created_at/updated_at 可为空值
|
20
|
+
model.hierarchy_class.attribute :updated_at, :datetime, null: true
|
21
|
+
model.hierarchy_class.index [:ancestor_id, :descendant_id, :generations], unique: true, name: "#{model.name.underscore}_anc_desc_idx"
|
22
|
+
|
23
|
+
def model.max_depth
|
24
|
+
self.hierarchy_class.maximum(:generations).to_i + 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def model.extract_multi_attributes(pairs)
|
28
|
+
_pairs = pairs.select { |k, _| k.include?('(') }
|
29
|
+
_real = {}
|
30
|
+
r = self.new.send :extract_callstack_for_multiparameter_attributes, _pairs
|
31
|
+
r.each do |k, v|
|
32
|
+
_real[k.sub(/ancestors$/, 'id')] = v.values.compact.last
|
33
|
+
end
|
34
|
+
_real
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def depth_str
|
39
|
+
(0..self.class.max_depth - self.depth).to_a.reverse.join
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_parent_ancestors
|
43
|
+
self.parent_ancestors = Hash(parent.parent_ancestors).merge! parent.depth.to_s => parent.id
|
44
|
+
end
|
45
|
+
|
46
|
+
def sync_parent_id
|
47
|
+
_parent_id = Hash(parent_ancestors).values.compact.last
|
48
|
+
if _parent_id
|
49
|
+
self.parent_id = _parent_id
|
50
|
+
else
|
51
|
+
self.parent_id = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def middle?
|
56
|
+
parent_id.present? && depth < self.class.max_depth
|
57
|
+
end
|
58
|
+
|
59
|
+
def sheer_descendant_ids(c_ids = child_ids)
|
60
|
+
@sheer_descendant_ids ||= c_ids.dup
|
61
|
+
get_ids = self.class.where(parent_id: c_ids).pluck(:id)
|
62
|
+
if get_ids.present?
|
63
|
+
_get_ids = get_ids - @sheer_descendant_ids
|
64
|
+
@sheer_descendant_ids.concat get_ids
|
65
|
+
sheer_descendant_ids(_get_ids)
|
66
|
+
else
|
67
|
+
@sheer_descendant_ids
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def sheer_ancestor_ids
|
72
|
+
node, node_ids = self, []
|
73
|
+
until (node_ids + [self.id]).include?(node.parent_id)
|
74
|
+
node_ids << node.parent_id
|
75
|
+
node = node.parent
|
76
|
+
end
|
77
|
+
node_ids
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Com
|
2
|
+
module Ext::TaxonPrepend
|
3
|
+
|
4
|
+
def self_and_siblings
|
5
|
+
if self.class.column_names.include?('organ_id')
|
6
|
+
super.where(organ_id: self.organ_id)
|
7
|
+
else
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def depth
|
13
|
+
if parent
|
14
|
+
parent.depth + 1
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'acme-client'
|
2
|
+
module Com
|
3
|
+
module Model::AcmeAccount
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attribute :email, :string
|
8
|
+
attribute :kid, :string
|
9
|
+
|
10
|
+
has_many :acme_orders, dependent: :destroy_async
|
11
|
+
|
12
|
+
if ActiveStorage::Blob.services.instance_values.dig('configurations', :acme)
|
13
|
+
has_one_attached :private_pem, service: :acme
|
14
|
+
else
|
15
|
+
has_one_attached :private_pem
|
16
|
+
end
|
17
|
+
|
18
|
+
after_create_commit :generate_account
|
19
|
+
|
20
|
+
validates :email, uniqueness: true
|
21
|
+
end
|
22
|
+
|
23
|
+
def private_key
|
24
|
+
return @private_key if defined? @private_key
|
25
|
+
if private_pem_blob
|
26
|
+
@private_key = OpenSSL::PKey::RSA.new(private_pem_blob.download)
|
27
|
+
else
|
28
|
+
@private_key = OpenSSL::PKey::RSA.new(4096)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_account
|
33
|
+
store_private_pem unless private_pem_blob
|
34
|
+
self.update(kid: account.kid)
|
35
|
+
end
|
36
|
+
|
37
|
+
def store_private_pem
|
38
|
+
Tempfile.open do |file|
|
39
|
+
file.binmode
|
40
|
+
file.write private_key.to_pem
|
41
|
+
file.rewind
|
42
|
+
self.private_pem.attach io: file, filename: "#{email}.pem"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def client
|
47
|
+
return @client if defined? @client
|
48
|
+
|
49
|
+
if self.kid
|
50
|
+
@client = Acme::Client.new(private_key: private_key, directory: directory, kid: kid)
|
51
|
+
else
|
52
|
+
@client = Acme::Client.new(private_key: private_key, directory: directory)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def directory
|
57
|
+
RailsCom.config.acme_url
|
58
|
+
end
|
59
|
+
|
60
|
+
def contact
|
61
|
+
"mailto:#{email}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def account
|
65
|
+
return @account if defined? @account
|
66
|
+
@account = client.new_account(contact: contact, terms_of_service_agreed: true)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
module Com
|
2
|
+
module Model::AcmeIdentifier
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :identifier, :string
|
7
|
+
attribute :file_name, :string
|
8
|
+
attribute :file_content, :string
|
9
|
+
attribute :token, :string
|
10
|
+
attribute :record_name, :string
|
11
|
+
attribute :record_content, :string
|
12
|
+
attribute :domain, :string
|
13
|
+
attribute :wildcard, :boolean
|
14
|
+
attribute :url, :string
|
15
|
+
attribute :dns_valid, :boolean, default: false
|
16
|
+
attribute :file_valid, :boolean, default: false
|
17
|
+
|
18
|
+
belongs_to :acme_order
|
19
|
+
|
20
|
+
enum status: {
|
21
|
+
pending: 'pending',
|
22
|
+
valid: 'valid',
|
23
|
+
invalid: 'invalid'
|
24
|
+
}, _prefix: true
|
25
|
+
|
26
|
+
before_save :renew_dns_valid, if: -> { record_content_changed? }
|
27
|
+
before_save :renew_file_valid, if: -> { file_content_changed? }
|
28
|
+
before_save :compute_wildcard, if: -> { identifier_changed? && identifier.present? }
|
29
|
+
end
|
30
|
+
|
31
|
+
def renew_dns_valid
|
32
|
+
self.dns_valid = false
|
33
|
+
end
|
34
|
+
|
35
|
+
def renew_file_valid
|
36
|
+
self.file_valid = false
|
37
|
+
end
|
38
|
+
|
39
|
+
def compute_wildcard
|
40
|
+
if identifier.start_with?('*.')
|
41
|
+
self.wildcard = true
|
42
|
+
self.domain = identifier.delete_prefix('*.')
|
43
|
+
else
|
44
|
+
self.domain = identifier
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# todo use aliyun temply
|
49
|
+
def ensure_dns
|
50
|
+
r = AliDns.add_acme_record domain, record_content
|
51
|
+
if r['RecordId']
|
52
|
+
AliDns.check_record(domain, record_content)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def dns_resolv
|
57
|
+
Resolv::DNS.open do |dns|
|
58
|
+
records = dns.getresources dns_host, Resolv::DNS::Resource::IN::TXT
|
59
|
+
records.map!(&:data)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def dns_verify?
|
64
|
+
unless dns_resolv.include?(record_content)
|
65
|
+
ensure_dns
|
66
|
+
end
|
67
|
+
|
68
|
+
auth = authorization
|
69
|
+
auth.dns.request_validation
|
70
|
+
if auth.reload && auth.status == 'valid'
|
71
|
+
self.update dns_valid: true, status: 'valid'
|
72
|
+
end
|
73
|
+
dns_valid
|
74
|
+
end
|
75
|
+
|
76
|
+
def auto_verify
|
77
|
+
if file_name.present? && file_content.present?
|
78
|
+
file_verify?
|
79
|
+
else
|
80
|
+
dns_verify?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def file_verify?
|
85
|
+
file_path = Rails.root.join('public', file_name)
|
86
|
+
|
87
|
+
unless file_path.file? && file_path.read == file_content
|
88
|
+
file_path.dirname.exist? || file_path.dirname.mkpath
|
89
|
+
File.open(file_path, 'w') do |f|
|
90
|
+
f.write file_content
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
auth = authorization
|
95
|
+
auth.http.request_validation
|
96
|
+
if auth.reload && auth.status == 'valid'
|
97
|
+
self.update file_valid: true, status: 'valid'
|
98
|
+
end
|
99
|
+
|
100
|
+
file_valid
|
101
|
+
end
|
102
|
+
|
103
|
+
def save_auth(auth = authorization)
|
104
|
+
update(
|
105
|
+
record_name: auth.dns&.record_name,
|
106
|
+
record_content: auth.dns&.record_content,
|
107
|
+
file_name: auth.http&.filename,
|
108
|
+
file_content: auth.http&.file_content,
|
109
|
+
url: auth.url,
|
110
|
+
status: auth.status
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
def dns_host
|
115
|
+
"#{record_name}.#{domain}"
|
116
|
+
end
|
117
|
+
|
118
|
+
def authorization
|
119
|
+
auth = acme_order.order.authorizations.find { |i| domain == i.domain && wildcard.present? == i.wildcard.present? }
|
120
|
+
rescue Acme::Client::Error::BadNonce
|
121
|
+
retry
|
122
|
+
else
|
123
|
+
save_auth(auth)
|
124
|
+
auth
|
125
|
+
end
|
126
|
+
|
127
|
+
def deactivate
|
128
|
+
acme_order.acme_account.client.deactivate_authorization(url: url)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'acme-client'
|
2
|
+
module Com
|
3
|
+
module Model::AcmeOrder
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attribute :orderid, :string
|
8
|
+
attribute :url, :string
|
9
|
+
attribute :issued_at, :datetime
|
10
|
+
attribute :expire_at, :datetime, comment: '过期时间'
|
11
|
+
|
12
|
+
enum status: {
|
13
|
+
pending: 'pending',
|
14
|
+
ready: 'ready',
|
15
|
+
valid: 'valid',
|
16
|
+
invalid: 'invalid'
|
17
|
+
}, _prefix: true
|
18
|
+
|
19
|
+
belongs_to :acme_account
|
20
|
+
has_many :acme_identifiers, dependent: :delete_all
|
21
|
+
accepts_nested_attributes_for :acme_identifiers
|
22
|
+
|
23
|
+
if ActiveStorage::Blob.services.instance_values.dig('configurations', :acme)
|
24
|
+
has_one_attached :private_pem, service: :acme
|
25
|
+
has_one_attached :cert_key, service: :acme
|
26
|
+
else
|
27
|
+
has_one_attached :private_pem
|
28
|
+
has_one_attached :cert_key
|
29
|
+
end
|
30
|
+
|
31
|
+
after_update_commit :renew_before_expired, if: -> { saved_change_to_issued_at? && issued_at.present? }
|
32
|
+
end
|
33
|
+
|
34
|
+
# status: pending
|
35
|
+
def order(renewal = false)
|
36
|
+
if defined?(@order) && !renewal
|
37
|
+
return @order
|
38
|
+
end
|
39
|
+
|
40
|
+
if !renewal && url
|
41
|
+
begin
|
42
|
+
@order = acme_account.client.order(url: url)
|
43
|
+
rescue Acme::Client::Error::BadNonce
|
44
|
+
retry
|
45
|
+
rescue Acme::Client::Error::NotFound => e
|
46
|
+
@order = renew_order
|
47
|
+
end
|
48
|
+
else
|
49
|
+
@order = renew_order
|
50
|
+
end
|
51
|
+
|
52
|
+
@order
|
53
|
+
end
|
54
|
+
|
55
|
+
# x
|
56
|
+
def renew_order
|
57
|
+
r = acme_account.client.new_order(identifiers: identifiers)
|
58
|
+
rescue Acme::Client::Error::BadNonce
|
59
|
+
retry
|
60
|
+
else
|
61
|
+
self.orderid = r.to_h[:url].split('/')[-1]
|
62
|
+
self.assign_attributes r.to_h.slice(:status, :url)
|
63
|
+
self.save
|
64
|
+
r
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_cert(tries = 2)
|
68
|
+
case order.status
|
69
|
+
when 'invalid'
|
70
|
+
order(true)
|
71
|
+
when 'pending'
|
72
|
+
acme_identifiers.map(&:authorization)
|
73
|
+
acme_identifiers.map(&:auto_verify).all?(true) && order.reload
|
74
|
+
when 'ready'
|
75
|
+
finalize
|
76
|
+
when 'valid'
|
77
|
+
cert # order.certificate_url.present?
|
78
|
+
end
|
79
|
+
rescue
|
80
|
+
retry unless (tries -= 1).zero?
|
81
|
+
end
|
82
|
+
|
83
|
+
def identifiers
|
84
|
+
acme_identifiers.pluck(:identifier).sort
|
85
|
+
end
|
86
|
+
|
87
|
+
def identifiers_string
|
88
|
+
r = identifiers.first
|
89
|
+
r = r.delete_prefix '*.'
|
90
|
+
r.gsub('.', '_')
|
91
|
+
end
|
92
|
+
|
93
|
+
def common_name
|
94
|
+
identifiers.first
|
95
|
+
end
|
96
|
+
|
97
|
+
def csr
|
98
|
+
return @csr if defined? @csr
|
99
|
+
@csr = Acme::Client::CertificateRequest.new(names: identifiers, subject: { common_name: common_name })
|
100
|
+
Tempfile.open do |file|
|
101
|
+
file.binmode
|
102
|
+
file.write @csr.private_key.to_pem
|
103
|
+
file.rewind
|
104
|
+
self.private_pem.attach io: file, filename: "#{identifiers_string}.key"
|
105
|
+
end
|
106
|
+
@csr
|
107
|
+
end
|
108
|
+
|
109
|
+
# status: valid
|
110
|
+
def finalize
|
111
|
+
order.finalize(csr: csr)
|
112
|
+
rescue Acme::Client::Error::BadNonce
|
113
|
+
retry
|
114
|
+
ensure
|
115
|
+
self.status = order.status
|
116
|
+
self.save
|
117
|
+
end
|
118
|
+
|
119
|
+
def cert
|
120
|
+
r = order.certificate
|
121
|
+
rescue Acme::Client::Error::BadNonce
|
122
|
+
retry
|
123
|
+
else
|
124
|
+
file = Tempfile.new
|
125
|
+
file.binmode
|
126
|
+
file.write r
|
127
|
+
file.rewind
|
128
|
+
self.issued_at = Time.current
|
129
|
+
self.status = order.status
|
130
|
+
self.cert_key.attach io: file, filename: "#{identifiers_string}.pem"
|
131
|
+
r
|
132
|
+
end
|
133
|
+
|
134
|
+
def renew_before_expired
|
135
|
+
AcmeJob.set(wait_until: issued_at + 2.months).perform_later(self)
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Com
|
3
|
+
module Model::BlobDefault
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attribute :record_class, :string, comment: 'AR 类名,如 User'
|
8
|
+
attribute :name, :string, comment: '名称, attach 名称,如:avatar'
|
9
|
+
|
10
|
+
has_one_attached :file
|
11
|
+
|
12
|
+
after_commit :delete_default_cache, on: [:create, :destroy]
|
13
|
+
after_update_commit :delete_default_cache
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete_default_cache
|
17
|
+
r = Rails.cache.delete('blob_default/default')
|
18
|
+
logger.debug "Cache key blob_default/default delete: #{r}"
|
19
|
+
end
|
20
|
+
|
21
|
+
class_methods do
|
22
|
+
def defaults
|
23
|
+
Rails.cache.fetch('blob_default/default') do
|
24
|
+
BlobDefault.includes(:file_attachment).map do |i|
|
25
|
+
["#{i.record_class}_#{i.name}", i.file_attachment&.blob_id]
|
26
|
+
end.compact.to_h
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def cache_clear
|
31
|
+
Rails.cache.delete('blob_default/default')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Com
|
2
|
+
module Model::Csp
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :document_uri, :string
|
7
|
+
attribute :referrer, :string
|
8
|
+
attribute :violated_directive, :string
|
9
|
+
attribute :effective_directive, :string
|
10
|
+
attribute :original_policy, :string
|
11
|
+
attribute :disposition, :string
|
12
|
+
attribute :blocked_uri, :string
|
13
|
+
attribute :line_number, :string
|
14
|
+
attribute :column_number, :string
|
15
|
+
attribute :source_file, :string
|
16
|
+
attribute :status_code, :string
|
17
|
+
attribute :script_sample, :string
|
18
|
+
|
19
|
+
default_scope -> { order(id: :desc) }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|