kono_utils 0.15.15 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +17 -78
- data/app/assets/javascripts/kono_utils/core.coffee +477 -0
- data/app/assets/stylesheets/kono_utils/{_kono_styles.css.scss → core.css.scss} +1 -16
- data/app/policies/kono_utils/base_editing_policy_concern.rb +52 -3
- data/app/policies/kono_utils/base_search_form_policy_concern.rb +25 -0
- data/config/initializers/mysql.rb +2 -2
- data/config/locales/it.yml +3 -1
- data/lib/generators/kono_utils/install/install_generator.rb +44 -0
- data/lib/generators/templates/base_editing_controller.template +3 -0
- data/lib/generators/templates/base_editing_helper.template +3 -0
- data/lib/generators/templates/base_editing_policy.template +4 -0
- data/lib/generators/templates/initializer.rb +3 -1
- data/lib/kono_utils.rb +29 -18
- data/lib/kono_utils/application_core_helper.rb +524 -0
- data/lib/kono_utils/application_enum_helper.rb +53 -0
- data/lib/kono_utils/application_helper.rb +4 -578
- data/lib/kono_utils/base_editing_core_helper.rb +194 -0
- data/lib/kono_utils/base_editing_helper.rb +3 -186
- data/lib/kono_utils/base_search.rb +32 -19
- data/lib/kono_utils/concerns.rb +12 -10
- data/lib/kono_utils/concerns/active_record_translation.rb +8 -4
- data/lib/kono_utils/concerns/active_storage_remover_helper.rb +61 -0
- data/lib/kono_utils/concerns/base_editing.rb +199 -53
- data/lib/kono_utils/configuration.rb +18 -0
- data/lib/kono_utils/engine.rb +15 -6
- data/lib/kono_utils/paginate_proxer.rb +17 -0
- data/lib/kono_utils/search_form_builder.rb +24 -0
- data/lib/kono_utils/version.rb +1 -1
- data/spec/dummy/.gitignore +2 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/javascripts/application.js +2 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/base_editing_controller.rb +3 -0
- data/spec/dummy/app/controllers/users_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/helpers/base_editing_helper.rb +3 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/policies/application_policy.rb +49 -0
- data/spec/dummy/app/policies/base_editing_policy.rb +4 -0
- data/spec/dummy/app/policies/user_policy.rb +23 -0
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/bin/setup +20 -13
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config/application.rb +15 -17
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +31 -11
- data/spec/dummy/config/environments/production.rb +26 -16
- data/spec/dummy/config/environments/test.rb +10 -6
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +6 -3
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/kono_utils.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults_5_2.rb +38 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/spec/dummy/config/locales/en.yml +10 -0
- data/spec/dummy/config/routes.rb +3 -52
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/migrate/20190716093114_create_users.rb +11 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/spec/models/user_spec.rb +5 -0
- data/spec/dummy/yarn.lock +21 -0
- metadata +83 -144
- data/app/assets/javascripts/kono_utils/utilities.coffee +0 -481
- data/app/assets/stylesheets/kono_utils/utils.css.scss +0 -4
- data/app/input/bs_aceeditor_input.rb +0 -53
- data/app/input/bs_autocomplete_input.rb +0 -60
- data/app/input/bs_datepicker_input.rb +0 -16
- data/app/input/bs_datetimepicker_input.rb +0 -80
- data/app/input/bs_file_download_input.rb +0 -35
- data/app/input/bs_image_input.rb +0 -35
- data/app/input/bs_label_with_container_input.rb +0 -22
- data/app/input/bs_location_picker_input.rb +0 -95
- data/app/input/bs_readonly_input.rb +0 -52
- data/app/input/bs_timepicker_input.rb +0 -14
- data/app/views/kono_utils/application/_search_panel.html.erb +0 -36
- data/app/views/kono_utils/base_editing/_edit.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_edit_page_side_title_header.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_edit_page_title_header.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_form.html.erb +0 -15
- data/app/views/kono_utils/base_editing/_index_buttons.html.erb +0 -2
- data/app/views/kono_utils/base_editing/_index_page_side_title_header.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_index_page_title_header.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_index_tfoot.html.erb +0 -0
- data/app/views/kono_utils/base_editing/_new.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_new_page_side_title_header.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_new_page_title_header.html.erb +0 -3
- data/app/views/kono_utils/base_editing/_search_form.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/_edit_page_side_title_header.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/_edit_page_title_header.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/_index_page_side_title_header.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/_index_page_title_header.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/_new_page_side_title_header.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/_new_page_title_header.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/edit.html.erb +0 -1
- data/app/views/kono_utils/base_editing/application/new.html.erb +0 -1
- data/app/views/kono_utils/base_editing/edit.html.erb +0 -1
- data/app/views/kono_utils/base_editing/index.html.erb +0 -36
- data/app/views/kono_utils/base_editing/new.html.erb +0 -1
- data/lib/kono_utils/encoder.rb +0 -47
- data/lib/kono_utils/fiscal_code.rb +0 -47
- data/lib/kono_utils/params_hash_array.rb +0 -37
- data/lib/kono_utils/percentage.rb +0 -60
- data/lib/kono_utils/tmp_file.rb +0 -81
- data/lib/kono_utils/virtual_model.rb +0 -22
- data/lib/tasks/kono_utils_tasks.rake +0 -4
- data/spec/lib/kono_utils/fiscal_code_spec.rb +0 -56
- data/vendor/assets/javascripts/EventEmitter.js +0 -473
@@ -0,0 +1,18 @@
|
|
1
|
+
module KonoUtils
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :google_api_key
|
4
|
+
attr_accessor :application_helper_includes
|
5
|
+
attr_accessor :base_editing_helper_includes
|
6
|
+
attr_accessor :pagination_proxer
|
7
|
+
|
8
|
+
#@return [KonoUtils::SearchFormBuilder]
|
9
|
+
attr_accessor :search_form_builder
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@application_helper_includes = []
|
13
|
+
@base_editing_helper_includes = []
|
14
|
+
@pagination_proxer = PaginateProxer
|
15
|
+
@search_form_builder = SearchFormBuilder
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/kono_utils/engine.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
1
|
module KonoUtils
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
|
4
|
-
require 'bootstrap3-datetimepicker-rails'
|
5
|
-
require 'momentjs-rails'
|
6
|
-
require 'font-awesome-rails'
|
7
|
-
require 'rails-assets-bootstrap-treeview'
|
8
|
-
require 'will_paginate'
|
9
|
-
require 'will_paginate-bootstrap'
|
10
4
|
require 'rdiscount'
|
5
|
+
require 'pundit'
|
6
|
+
require 'kono_utils_helpers'
|
11
7
|
|
12
8
|
|
13
9
|
initializer 'kono_utils.append_views', :group => :all do |app|
|
14
10
|
ActionController::Base.append_view_path KonoUtils::Engine.root.join("app", "views", "kono_utils")
|
15
11
|
end
|
16
12
|
|
13
|
+
|
14
|
+
initializer 'kono_utils.append_helpers', :group => :all do |app|
|
15
|
+
KonoUtils.configure do |c|
|
16
|
+
c.application_helper_includes << KonoUtils::ApplicationCoreHelper
|
17
|
+
c.application_helper_includes << KonoUtils::ApplicationEnumHelper
|
18
|
+
c.base_editing_helper_includes << KonoUtils::BaseEditingCoreHelper
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
initializer 'kono_utils.appen_custom_format', :group => :all do |app|
|
23
|
+
Mime::Type.register Mime[:js].to_s, :inject
|
24
|
+
end
|
25
|
+
|
17
26
|
end
|
18
27
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module KonoUtils
|
2
|
+
##
|
3
|
+
# Simple PORO to proxyng the pagination operations
|
4
|
+
class PaginateProxer
|
5
|
+
|
6
|
+
attr_accessor :collection
|
7
|
+
|
8
|
+
def initialize(collection)
|
9
|
+
@collection = collection
|
10
|
+
end
|
11
|
+
|
12
|
+
def paginate(params={})
|
13
|
+
raise "TO Override with the correct pagination method of the gem used"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module KonoUtils
|
2
|
+
##
|
3
|
+
# PORO che si occupa di fare da proxy nella generazione della form della ricerca.
|
4
|
+
# Questa classe è designata a staccare la logica del modello della ricerca dalla logica del controller e view
|
5
|
+
class SearchFormBuilder
|
6
|
+
|
7
|
+
#@return [KonoUtils::BaseSearch] o una classe derivata
|
8
|
+
attr_reader :search
|
9
|
+
|
10
|
+
# @param [KonoUtils::BaseSearch] search
|
11
|
+
def initialize(search)
|
12
|
+
@search = search
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
##
|
17
|
+
# Costruisce la path per fare le richieste, oppure false nel caso non sia stata configurata
|
18
|
+
# @return [String,FalseClass]
|
19
|
+
def search_path
|
20
|
+
Rails.application.routes.url_helpers.polymorphic_path(search) rescue false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/kono_utils/version.rb
CHANGED
@@ -2,4 +2,14 @@ class ApplicationController < ActionController::Base
|
|
2
2
|
# Prevent CSRF attacks by raising an exception.
|
3
3
|
# For APIs, you may want to use :null_session instead.
|
4
4
|
protect_from_forgery with: :exception
|
5
|
+
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
##
|
10
|
+
# Semplificazione in sviluppo di un possibile utente
|
11
|
+
def current_user
|
12
|
+
User.first || User.create(username: 'mario', surname: 'rossi',email:"example@tld.it")
|
13
|
+
end
|
14
|
+
|
5
15
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class ApplicationPolicy
|
2
|
+
attr_reader :user, :record
|
3
|
+
|
4
|
+
def initialize(user, record)
|
5
|
+
@user = user
|
6
|
+
@record = record
|
7
|
+
end
|
8
|
+
|
9
|
+
def index?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def show?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def create?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def new?
|
22
|
+
create?
|
23
|
+
end
|
24
|
+
|
25
|
+
def update?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def edit?
|
30
|
+
update?
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy?
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
class Scope
|
38
|
+
attr_reader :user, :scope
|
39
|
+
|
40
|
+
def initialize(user, scope)
|
41
|
+
@user = user
|
42
|
+
@scope = scope
|
43
|
+
end
|
44
|
+
|
45
|
+
def resolve
|
46
|
+
scope.all
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/dummy/bin/rails
CHANGED
data/spec/dummy/bin/setup
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
3
4
|
|
4
5
|
# path to your application root.
|
5
|
-
APP_ROOT =
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
6
7
|
|
7
|
-
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
8
13
|
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
10
19
|
|
11
|
-
|
12
|
-
system
|
13
|
-
system "bundle check || bundle install"
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
14
22
|
|
15
23
|
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?(
|
17
|
-
#
|
24
|
+
# unless File.exist?('config/database.yml')
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
18
26
|
# end
|
19
27
|
|
20
28
|
puts "\n== Preparing database =="
|
21
|
-
system
|
29
|
+
system! 'bin/rails db:setup'
|
22
30
|
|
23
31
|
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system
|
25
|
-
system "rm -rf tmp/cache"
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
33
|
|
27
34
|
puts "\n== Restarting application server =="
|
28
|
-
system
|
35
|
+
system! 'bin/rails restart'
|
29
36
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a way to update your development environment automatically.
|
14
|
+
# Add necessary update steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
puts "\n== Updating database =="
|
24
|
+
system! 'bin/rails db:migrate'
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
28
|
+
|
29
|
+
puts "\n== Restarting application server =="
|
30
|
+
system! 'bin/rails restart'
|
31
|
+
end
|
data/spec/dummy/bin/yarn
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(APP_ROOT) do
|
4
|
+
begin
|
5
|
+
exec "yarnpkg", *ARGV
|
6
|
+
rescue Errno::ENOENT
|
7
|
+
$stderr.puts "Yarn executable was not detected in the system."
|
8
|
+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
@@ -1,32 +1,30 @@
|
|
1
|
-
|
1
|
+
require_relative 'boot'
|
2
2
|
|
3
|
+
require "rails"
|
3
4
|
# Pick the frameworks you want:
|
5
|
+
require "active_model/railtie"
|
6
|
+
require "active_job/railtie"
|
4
7
|
require "active_record/railtie"
|
8
|
+
require "active_storage/engine"
|
5
9
|
require "action_controller/railtie"
|
6
10
|
require "action_mailer/railtie"
|
7
11
|
require "action_view/railtie"
|
12
|
+
# require "action_cable/engine"
|
8
13
|
require "sprockets/railtie"
|
9
|
-
|
14
|
+
require "rails/test_unit/railtie"
|
10
15
|
|
16
|
+
# Require the gems listed in Gemfile, including any gems
|
17
|
+
# you've limited to :test, :development, or :production.
|
11
18
|
Bundler.require(*Rails.groups)
|
12
|
-
require "kono_utils"
|
13
19
|
|
14
20
|
module Dummy
|
15
21
|
class Application < Rails::Application
|
16
|
-
#
|
17
|
-
|
18
|
-
# -- all .rb files in that directory are automatically loaded.
|
19
|
-
|
20
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
21
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
22
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
23
|
-
|
24
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
25
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
26
|
-
# config.i18n.default_locale = :de
|
22
|
+
# Initialize configuration defaults for originally generated Rails version.
|
23
|
+
config.load_defaults 6.0
|
27
24
|
|
28
|
-
#
|
29
|
-
|
25
|
+
# Settings in config/environments/* take precedence over those specified here.
|
26
|
+
# Application configuration can go into files in config/initializers
|
27
|
+
# -- all .rb files in that directory are automatically loaded after loading
|
28
|
+
# the framework and any gems in your application.
|
30
29
|
end
|
31
30
|
end
|
32
|
-
|
@@ -9,33 +9,53 @@ Rails.application.configure do
|
|
9
9
|
# Do not eager load code on boot.
|
10
10
|
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports
|
13
|
-
config.consider_all_requests_local
|
14
|
-
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
16
|
+
# Run rails dev:cache to toggle caching.
|
17
|
+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
|
18
|
+
config.action_controller.perform_caching = true
|
19
|
+
|
20
|
+
config.cache_store = :memory_store
|
21
|
+
config.public_file_server.headers = {
|
22
|
+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
23
|
+
}
|
24
|
+
else
|
25
|
+
config.action_controller.perform_caching = false
|
26
|
+
|
27
|
+
config.cache_store = :null_store
|
28
|
+
end
|
29
|
+
|
30
|
+
# Store uploaded files on the local file system (see config/storage.yml for options)
|
31
|
+
config.active_storage.service = :local
|
15
32
|
|
16
33
|
# Don't care if the mailer can't send.
|
17
34
|
config.action_mailer.raise_delivery_errors = false
|
18
35
|
|
36
|
+
config.action_mailer.perform_caching = false
|
37
|
+
|
19
38
|
# Print deprecation notices to the Rails logger.
|
20
39
|
config.active_support.deprecation = :log
|
21
40
|
|
22
41
|
# Raise an error on page load if there are pending migrations.
|
23
42
|
config.active_record.migration_error = :page_load
|
24
43
|
|
44
|
+
# Highlight code that triggered database queries in logs.
|
45
|
+
config.active_record.verbose_query_logs = true
|
46
|
+
|
25
47
|
# Debug mode disables concatenation and preprocessing of assets.
|
26
48
|
# This option may cause significant delays in view rendering with a large
|
27
49
|
# number of complex assets.
|
28
50
|
config.assets.debug = true
|
29
51
|
|
30
|
-
#
|
31
|
-
|
32
|
-
config.assets.digest = true
|
33
|
-
|
34
|
-
# Adds additional error checking when serving assets at runtime.
|
35
|
-
# Checks for improperly declared sprockets dependencies.
|
36
|
-
# Raises helpful error messages.
|
37
|
-
config.assets.raise_runtime_errors = true
|
52
|
+
# Suppress logger output for asset requests.
|
53
|
+
config.assets.quiet = true
|
38
54
|
|
39
55
|
# Raises error for missing translations
|
40
56
|
# config.action_view.raise_on_missing_translations = true
|
57
|
+
|
58
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
59
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
60
|
+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
41
61
|
end
|