pvincent 6 months ago
parent
commit
609ff9be61
  1. 6
      .env.sample
  2. 2
      TODO.md
  3. 3
      app/javascript/controllers/application.js
  4. 15
      app/reload/live_constants.rb
  5. 9
      app/views/layouts/application.html.erb

6
.env.sample

@ -1,3 +1,7 @@
RAILS_PORT=7500
DATABASE_HOST=localhost
DATABASE_NAME=easy-going-rails
DATABASE_NAME=easy-going-rails
DATABASE_USER=$DATABASE_NAME
DATABASE_PASSWORD=$DATABASE_NAME

2
TODO.md

@ -1,6 +1,8 @@
TODO
====
* [ ] LiveConstants
* [ ] monkeypatch rails-live-reload
* [ ] Tailwind
* [ ] copy TailAdmin (or WindMill) layout
* [ ] https://demo.tailadmin.com/crm

3
app/javascript/controllers/application.js

@ -3,7 +3,8 @@ import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.debug = true
const stimulusDebug = document.head.querySelector("meta[name=stimulus-debug]")
application.debug = stimulusDebug ? stimulusDebug.content === 'true' : false
window.Stimulus = application
export { application }

15
app/reload/live_constants.rb

@ -0,0 +1,15 @@
# Development Constants
module LiveConstants
# constants
STIMULUS_DEBUG = false
LOG_ACTIVE_RECORD = false
LOG_ACTION_VIEW = false
def self.reload!
ActionView::Base.logger.level = LOG_ACTION_VIEW ? :debug : :fatal
ActiveRecord::Base.logger.level = LOG_ACTIVE_RECORD ? :debug : :fatal
SemanticLogger[to_s].warn 'reloaded!'
end
reload!
end

9
app/views/layouts/application.html.erb

@ -5,13 +5,13 @@
<title>
<%=Rails.configuration.application_title%>
</title>
<!--META -->
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= tag :meta, name: :viewport, content: 'width=device-width,initial-scale=1' %>
<% if Rails.env.development? %>
<meta name="turbo-prefetch" content="false">
<%= tag :meta, name: 'turbo-prefetch', content: false %>
<%= tag :meta, name: 'stimulus-debug', content: LiveConstants::STIMULUS_DEBUG %>
<% end%>
<!-- LINK-->
@ -19,12 +19,9 @@
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head>
<body>
<%=render 'layouts/navbar' %>
<%=render 'layouts/notification' %>
<main class="m-8 flex flex-col">
<%= yield %>
</main>

Loading…
Cancel
Save