Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed app/helpers/.keep
Empty file.
7 changes: 7 additions & 0 deletions app/helpers/tabler_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module TablerHelper
def title(title = nil, default_title:)
content_for :title, title || default_title
end
end
8 changes: 8 additions & 0 deletions lib/generators/tabler/installer_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions lib/generators/tabler/templates/application.html.erb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<%%= title(default_title: 'Tabler') %>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%%= 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 %>
</head>
<body class="layout-fluid theme-light">
<div class="page">
<div class="page-wrapper">
<%%= yield %>
</div>
</div>
<turbo-frame id="modal-show" target="_top"></turbo-frame>
</body>
</html>
23 changes: 23 additions & 0 deletions lib/generators/tabler/templates/tight.html.erb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<%%= title(default_title: 'Tabler' %>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%%= 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 %>
</head>
<body class="border-top-wide border-primary d-flex flex-column">
<div class="page page-center">
<div class="container-tight py-4">
<div class="text-center mb-4">
<%%= link_to('Tabler', '/', class: 'navbar-brand') %>
</div>
<%%= yield %>
</div>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions lib/tabler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require 'tabler/engine'
require 'tabler/version'

module Tabler
end
1 change: 1 addition & 0 deletions lib/tabler/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

module Tabler
class Engine < ::Rails::Engine
isolate_namespace Tabler
end
end
7 changes: 0 additions & 7 deletions lib/tabler/rails.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/support/dummy_test_helpers.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down