From 0a5c1feeff0c5a2ba819d249f1e49e614777e05b Mon Sep 17 00:00:00 2001 From: Lucas Santos da Costa Date: Sat, 18 Nov 2023 05:52:58 -0300 Subject: [PATCH 1/2] Remove unused files --- app/helpers/.keep | 0 lib/tabler/engine.rb | 1 + lib/tabler/rails.rb | 7 ------- test/dummy/config/application.rb | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 app/helpers/.keep delete mode 100644 lib/tabler/rails.rb diff --git a/app/helpers/.keep b/app/helpers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/tabler/engine.rb b/lib/tabler/engine.rb index 6c9ce6f..84d743c 100644 --- a/lib/tabler/engine.rb +++ b/lib/tabler/engine.rb @@ -2,5 +2,6 @@ module Tabler class Engine < ::Rails::Engine + isolate_namespace Tabler end end diff --git a/lib/tabler/rails.rb b/lib/tabler/rails.rb deleted file mode 100644 index 525b5cb..0000000 --- a/lib/tabler/rails.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -# -# require 'tabler/version' -# require 'tabler/engine' -# -# module Tabler -# end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 90fbe21..e164646 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -7,7 +7,7 @@ # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -require 'tabler/rails' +require 'tabler' module Dummy class Application < Rails::Application From 894e1687d00900b2ba5decd622fe88f247e781aa Mon Sep 17 00:00:00 2001 From: Lucas Santos da Costa Date: Sat, 18 Nov 2023 05:53:39 -0300 Subject: [PATCH 2/2] Add layouts templates --- app/helpers/tabler_helper.rb | 7 ++++++ lib/generators/tabler/installer_generator.rb | 8 +++++++ .../tabler/templates/application.html.erb.tt | 21 +++++++++++++++++ .../tabler/templates/tight.html.erb.tt | 23 +++++++++++++++++++ lib/tabler.rb | 7 ++++++ test/support/dummy_test_helpers.rb | 4 ++++ 6 files changed, 70 insertions(+) create mode 100644 app/helpers/tabler_helper.rb create mode 100644 lib/generators/tabler/templates/application.html.erb.tt create mode 100644 lib/generators/tabler/templates/tight.html.erb.tt create mode 100644 lib/tabler.rb diff --git a/app/helpers/tabler_helper.rb b/app/helpers/tabler_helper.rb new file mode 100644 index 0000000..33ed211 --- /dev/null +++ b/app/helpers/tabler_helper.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module TablerHelper + def title(title = nil, default_title:) + content_for :title, title || default_title + end +end diff --git a/lib/generators/tabler/installer_generator.rb b/lib/generators/tabler/installer_generator.rb index 82acc17..be19654 100644 --- a/lib/generators/tabler/installer_generator.rb +++ b/lib/generators/tabler/installer_generator.rb @@ -9,6 +9,8 @@ class InstallerGenerator < Rails::Generators::Base PACKAGES = %w[@tabler/core tom-select].freeze JS_LINES = %(\nimport "@tabler/core/dist/js/tabler.esm";\nimport "tom-select/dist/js/tom-select.complete";) CSS_LINES = %(\n@import "@tabler/core/dist/css/tabler.css";\n@import "tom-select/dist/css/tom-select.css";\n) + TEMPLATES = %w[application.html.erb tight.html.erb] + class WrongNodeVersion < Rails::Generators::Error; end @@ -40,6 +42,12 @@ def add_css_lines append_to_file application_css_path, CSS_LINES end + def generate_application_layout + TEMPLATES.each do |template| + template template, "app/views/layouts/#{template}", force: true + end + end + private def fetch_application_css_path diff --git a/lib/generators/tabler/templates/application.html.erb.tt b/lib/generators/tabler/templates/application.html.erb.tt new file mode 100644 index 0000000..5e1f702 --- /dev/null +++ b/lib/generators/tabler/templates/application.html.erb.tt @@ -0,0 +1,21 @@ + + + + <%%= title(default_title: 'Tabler') %> + + <%%= csrf_meta_tags %> + <%%= csp_meta_tag %> + + <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> + <%%= yield :javascripts %> + + +
+
+ <%%= yield %> +
+
+ + + diff --git a/lib/generators/tabler/templates/tight.html.erb.tt b/lib/generators/tabler/templates/tight.html.erb.tt new file mode 100644 index 0000000..b1e9d0d --- /dev/null +++ b/lib/generators/tabler/templates/tight.html.erb.tt @@ -0,0 +1,23 @@ + + + + <%%= title(default_title: 'Tabler' %> + + <%%= csrf_meta_tags %> + <%%= csp_meta_tag %> + + <%%= stylesheet_link_tag 'application', 'data-turbo-track': 'reload' %> + <%%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> + <%%= yield :javascripts %> + + +
+
+
+ <%%= link_to('Tabler', '/', class: 'navbar-brand') %> +
+ <%%= yield %> +
+
+ + diff --git a/lib/tabler.rb b/lib/tabler.rb new file mode 100644 index 0000000..f3b71c9 --- /dev/null +++ b/lib/tabler.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'tabler/engine' +require 'tabler/version' + +module Tabler +end diff --git a/test/support/dummy_test_helpers.rb b/test/support/dummy_test_helpers.rb index 1fdc144..2798974 100644 --- a/test/support/dummy_test_helpers.rb +++ b/test/support/dummy_test_helpers.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true module DummyTestHelpers + def application_template + Rails.root.join('app/views/layouts/application.html.erb') + end + def package_template Rails.root.join('package_template.json') end