maquina 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.overmind.env +1 -0
  3. data/Gemfile +20 -0
  4. data/Gemfile.lock +346 -0
  5. data/Procfile.dev +3 -0
  6. data/app/assets/images/maquina/.keep +0 -0
  7. data/app/assets/javascripts/maquina/controllers/file_controller.js +1 -1
  8. data/app/assets/javascripts/maquina/controllers/modal_controller.js +1 -1
  9. data/app/assets/javascripts/maquina/controllers/modal_open_controller.js +3 -8
  10. data/app/assets/stylesheets/maquina/application.tailwind.css +96 -97
  11. data/app/controllers/concerns/.keep +0 -0
  12. data/app/controllers/concerns/maquina/authenticate.rb +8 -1
  13. data/app/controllers/concerns/maquina/resourceful.rb +9 -9
  14. data/app/models/concerns/.keep +0 -0
  15. data/app/models/concerns/maquina/blockeable.rb +13 -3
  16. data/app/models/concerns/maquina/searchable.rb +2 -2
  17. data/app/models/maquina/application_record.rb +3 -3
  18. data/app/models/maquina/current.rb +2 -1
  19. data/app/models/maquina/membership.rb +10 -0
  20. data/app/models/maquina/organization.rb +7 -0
  21. data/app/models/maquina/plan.rb +1 -3
  22. data/app/models/maquina/user.rb +8 -3
  23. data/app/policies/maquina/application_policy.rb +3 -6
  24. data/app/policies/maquina/invitation_policy.rb +2 -2
  25. data/app/policies/maquina/navigation_policy.rb +2 -2
  26. data/app/policies/maquina/user_policy.rb +7 -3
  27. data/app/views/layouts/maquina/application.html.erb +1 -2
  28. data/app/views/layouts/maquina/sessions.html.erb +1 -2
  29. data/app/views/maquina/application/_navbar.html.erb +1 -1
  30. data/app/views/maquina/application/components/file_component.rb +38 -5
  31. data/app/views/maquina/application/form.rb +3 -2
  32. data/app/views/maquina/application/index_header.rb +1 -1
  33. data/app/views/maquina/application/index_modal.rb +1 -3
  34. data/config/importmap.rb +12 -0
  35. data/db/migrate/20230829183530_create_maquina_organizations.rb +11 -0
  36. data/db/migrate/20230829192656_create_maquina_memberships.rb +15 -0
  37. data/lib/generators/maquina/install_generator.rb +0 -4
  38. data/lib/generators/maquina/tailwind_config/USAGE +14 -0
  39. data/lib/generators/maquina/tailwind_config/tailwind_config_generator.rb +17 -3
  40. data/lib/generators/maquina/tailwind_config/templates/app/assets/stylesheets/maquina.css +96 -0
  41. data/lib/generators/maquina/tailwind_config/templates/lib/generators/tailwind_config/tailwind_config_generator.rb.tt +11 -0
  42. data/lib/generators/maquina/tailwind_config/templates/{app/assets/config/maquina → lib/generators/tailwind_config/templates/config}/tailwind.config.js.tt +4 -0
  43. data/lib/generators/maquina/tailwind_config/templates/lib/tasks/tailwind.rake.tt +11 -0
  44. data/lib/generators/maquina/templates/config/initializers/maquina.rb.tt +6 -0
  45. data/lib/maquina/engine.rb +0 -4
  46. data/lib/maquina/version.rb +1 -1
  47. data/lib/maquina.rb +11 -4
  48. metadata +23 -10
  49. data/config/definitions.rb +0 -1
  50. data/config/initializers/importmap.rb +0 -17
  51. data/lib/generators/maquina/templates/config/initializers/maquina.rb +0 -3
  52. data/lib/tasks/tailwind.rake +0 -25
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :tailwindcss do
4
+ desc "Generates your tailwind config file"
5
+ task :config do
6
+ Rails::Generators.invoke("tailwind_config", ["--force"])
7
+ end
8
+ end
9
+
10
+ Rake::Task["tailwindcss:build"].enhance(["tailwindcss:config"])
11
+ Rake::Task["tailwindcss:watch"].enhance(["tailwindcss:config"])
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Maquina.configure do |config|
4
+ # Configure membership roles.
5
+ config.membership_roles = Maquina.postgresql? ? {admin: "admin", member: "member"} : {admin: 0, member: 1}
6
+ end
@@ -9,9 +9,5 @@ module Maquina
9
9
  class Engine < ::Rails::Engine
10
10
  config.autoload_paths += %W[#{Engine.root}/app/views]
11
11
  isolate_namespace Maquina
12
-
13
- initializer "maquina.importmap", before: "importmap" do |app|
14
- app.config.importmap.paths << Engine.root.join("config/initializers/importmap.rb")
15
- end
16
12
  end
17
13
  end
@@ -1,3 +1,3 @@
1
1
  module Maquina
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/maquina.rb CHANGED
@@ -11,26 +11,33 @@ require "pagy"
11
11
  module Maquina
12
12
  class << self
13
13
  attr_accessor :configuration
14
+
15
+ def postgresql?
16
+ ActiveRecord::Base.connection_db_config.configuration_hash[:adapter].downcase == "postgresql"
17
+ end
14
18
  end
15
19
 
16
20
  class Configuration
17
21
  attr_accessor :password_retain_count, :temporary_block, :session_expiration, :signin_attempts, :tailwind_content,
18
- :importmap, :root_app_path
22
+ :importmap, :root_app_path, :membership_roles
19
23
 
20
24
  def initialize
21
25
  @password_retain_count = 3
22
26
  @temporary_block = 5.minutes
23
27
  @session_expiration = 2.days
24
28
  @signin_attempts = 5
25
- @importmap = Importmap::Map.new
26
29
  @root_app_path = nil
27
30
 
31
+ @membership_roles = {admin: "admin", member: "member"}
32
+
33
+ @importmap = Importmap::Map.new
34
+ @importmap.draw(Engine.root.join("config/importmap.rb"))
35
+
28
36
  @tailwind_content = [
29
37
  "#{Maquina::Engine.root}/app/views/**/*.{rb,erb}",
30
38
  "#{Maquina::Engine.root}/app/helpers/**/*.rb",
31
39
  "#{Maquina::Engine.root}/app/controllers/**/*.rb",
32
- "#{Maquina::Engine.root}/app/javascript/**/*.js",
33
- "#{Maquina::Engine.root}/app/assets/**/application.tailwind.css"
40
+ "#{Maquina::Engine.root}/app/javascript/**/*.js"
34
41
  ]
35
42
  end
36
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maquina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-08 00:00:00.000000000 Z
11
+ date: 2023-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.1.0
89
+ version: 1.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.1.0
96
+ version: 1.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tailwindcss-rails
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -295,9 +295,14 @@ executables: []
295
295
  extensions: []
296
296
  extra_rdoc_files: []
297
297
  files:
298
+ - ".overmind.env"
299
+ - Gemfile
300
+ - Gemfile.lock
298
301
  - MIT-LICENSE
302
+ - Procfile.dev
299
303
  - README.md
300
304
  - Rakefile
305
+ - app/assets/images/maquina/.keep
301
306
  - app/assets/images/maquina/maquina.svg
302
307
  - app/assets/javascripts/maquina/application.js
303
308
  - app/assets/javascripts/maquina/controllers/alert_controller.js
@@ -311,6 +316,7 @@ files:
311
316
  - app/assets/javascripts/maquina/controllers/submit_form_controller.js
312
317
  - app/assets/stylesheets/maquina/application.css
313
318
  - app/assets/stylesheets/maquina/application.tailwind.css
319
+ - app/controllers/concerns/.keep
314
320
  - app/controllers/concerns/maquina/authenticate.rb
315
321
  - app/controllers/concerns/maquina/create.rb
316
322
  - app/controllers/concerns/maquina/destroy.rb
@@ -334,6 +340,7 @@ files:
334
340
  - app/jobs/maquina/application_job.rb
335
341
  - app/mailers/maquina/application_mailer.rb
336
342
  - app/mailers/maquina/user_notifications_mailer.rb
343
+ - app/models/concerns/.keep
337
344
  - app/models/concerns/maquina/authenticate_by.rb
338
345
  - app/models/concerns/maquina/blockeable.rb
339
346
  - app/models/concerns/maquina/multifactor.rb
@@ -343,6 +350,8 @@ files:
343
350
  - app/models/maquina/application_record.rb
344
351
  - app/models/maquina/current.rb
345
352
  - app/models/maquina/invitation.rb
353
+ - app/models/maquina/membership.rb
354
+ - app/models/maquina/organization.rb
346
355
  - app/models/maquina/plan.rb
347
356
  - app/models/maquina/used_password.rb
348
357
  - app/models/maquina/user.rb
@@ -399,8 +408,7 @@ files:
399
408
  - app/views/maquina/unauthorized/401.html.erb
400
409
  - app/views/maquina/user_notifications_mailer/invitation_email.html.erb
401
410
  - app/views/maquina/user_notifications_mailer/invitation_email.text.erb
402
- - config/definitions.rb
403
- - config/initializers/importmap.rb
411
+ - config/importmap.rb
404
412
  - config/initializers/money.rb
405
413
  - config/initializers/pagy.rb
406
414
  - config/locales/flash.en.yml
@@ -415,18 +423,23 @@ files:
415
423
  - db/migrate/20221113020108_create_maquina_used_passwords.rb
416
424
  - db/migrate/20221115223414_create_maquina_active_sessions.rb
417
425
  - db/migrate/20230201203922_create_maquina_invitations.rb
426
+ - db/migrate/20230829183530_create_maquina_organizations.rb
427
+ - db/migrate/20230829192656_create_maquina_memberships.rb
418
428
  - db/schema.rb
419
429
  - lib/generators/maquina/install_generator.rb
420
430
  - lib/generators/maquina/install_templates/install_templates_generator.rb
431
+ - lib/generators/maquina/tailwind_config/USAGE
421
432
  - lib/generators/maquina/tailwind_config/tailwind_config_generator.rb
422
- - lib/generators/maquina/tailwind_config/templates/app/assets/config/maquina/tailwind.config.js.tt
423
- - lib/generators/maquina/templates/config/initializers/maquina.rb
433
+ - lib/generators/maquina/tailwind_config/templates/app/assets/stylesheets/maquina.css
434
+ - lib/generators/maquina/tailwind_config/templates/lib/generators/tailwind_config/tailwind_config_generator.rb.tt
435
+ - lib/generators/maquina/tailwind_config/templates/lib/generators/tailwind_config/templates/config/tailwind.config.js.tt
436
+ - lib/generators/maquina/tailwind_config/templates/lib/tasks/tailwind.rake.tt
437
+ - lib/generators/maquina/templates/config/initializers/maquina.rb.tt
424
438
  - lib/maquina.rb
425
439
  - lib/maquina/engine.rb
426
440
  - lib/maquina/version.rb
427
441
  - lib/tasks/install.rake
428
442
  - lib/tasks/maquina_tasks.rake
429
- - lib/tasks/tailwind.rake
430
443
  homepage: https://mariochavez.io
431
444
  licenses:
432
445
  - MIT
@@ -449,7 +462,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
449
462
  - !ruby/object:Gem::Version
450
463
  version: '0'
451
464
  requirements: []
452
- rubygems_version: 3.4.18
465
+ rubygems_version: 3.4.19
453
466
  signing_key:
454
467
  specification_version: 4
455
468
  summary: Rails engine for building Rails applications.
@@ -1 +0,0 @@
1
- /Users/marioch/Development/butaca2/config/definitions.rb
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "maquina"
4
-
5
- Maquina.configuration.importmap.draw do
6
- # Stimulus & Turbo
7
- pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
8
- pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
9
- pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
10
- pin "stimulus-use", to: "https://ga.jspm.io/npm:stimulus-use@0.51.0/dist/index.js"
11
- pin "hotkeys-js", to: "https://ga.jspm.io/npm:hotkeys-js@3.10.0/dist/hotkeys.esm.js"
12
-
13
- # Maquina entrypoint
14
- pin "application", to: "maquina/application.js", preload: true
15
-
16
- pin_all_from Maquina::Engine.root.join("app/assets/javascripts/maquina/controllers"), under: "controllers", to: "maquina/controllers"
17
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # TODO: Have and initializer
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "tailwindcss-rails"
4
-
5
- TAILWIND_COMPILE_COMMAND = "#{Tailwindcss::Engine.root.join("exe/tailwindcss")} -i #{Maquina::Engine.root.join("app/assets/stylesheets/maquina/application.tailwind.css")} -o #{Rails.root.join("app/assets/builds", "maquina/tailwind.css")} -c #{Rails.root.join("app/assets/config/maquina/tailwind.config.js")}"
6
-
7
- namespace :maquina do
8
- namespace :tailwindcss do
9
- desc "Build your Tailwind CSS"
10
- task :build do
11
- Rails::Generators.invoke("maquina:tailwind_config", ["--force"])
12
- system TAILWIND_COMPILE_COMMAND
13
- end
14
-
15
- desc "Watch and build your Tailwind CSS"
16
- task :watch do
17
- Rails::Generators.invoke("maquina:tailwind_config", ["--force"])
18
- system "#{TAILWIND_COMPILE_COMMAND} -w"
19
- end
20
- end
21
- end
22
-
23
- if Rake::Task.task_defined?("assets:precompile")
24
- Rake::Task["assets:precompile"].enhance(["maquina:tailwindcss:build"])
25
- end