pvincent
4 months ago
13 changed files with 144 additions and 117 deletions
-
2Gemfile
-
138Gemfile.lock
-
3app/helpers/pagy_helper.rb
-
23app/javascript/controllers/hot_search_controller.js
-
3app/models/application_record.rb
-
19app/views/scores/_scores.html.erb
-
4config/environments/production.rb
-
6config/environments/test.rb
-
2config/initializers/backtrace_cleaning.rb
-
2config/initializers/hot_changes.rb
-
25config/initializers/rails_live_reload.rb
-
14db/schema.rb
-
20lib/semantic/ansi_formatter.rb
@ -0,0 +1,23 @@ |
|||||
|
import { Controller } from "@hotwired/stimulus"; |
||||
|
|
||||
|
// Connects to data-controller="hot-search"
|
||||
|
export default class extends Controller { |
||||
|
connect() { |
||||
|
this.debouncedSearch = debounce(this.debouncedSearch.bind(this), 400) |
||||
|
} |
||||
|
|
||||
|
debouncedSearch() { |
||||
|
Turbo.visit('/scores?q[name_cont]=' + this.element.value, { frame: 'scores', turbo: true, acceptsStreamResponse: true }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function debounce(callback, delay) { |
||||
|
let timeoutId; |
||||
|
return (...args) => { |
||||
|
if (timeoutId) { clearTimeout(timeoutId) } |
||||
|
timeoutId = setTimeout(() => { |
||||
|
callback(...args) |
||||
|
timeoutId = null |
||||
|
}, delay) |
||||
|
} |
||||
|
} |
@ -1,4 +1,7 @@ |
|||||
# abstract default ActiveRecord class |
# abstract default ActiveRecord class |
||||
class ApplicationRecord < ActiveRecord::Base |
class ApplicationRecord < ActiveRecord::Base |
||||
primary_abstract_class |
primary_abstract_class |
||||
|
|
||||
|
# returns a pretty name like: "MyModel#1" |
||||
|
def to_s = "#{self.class.name}##{id}" |
||||
end |
end |
@ -1,2 +1,2 @@ |
|||||
bc = Rails.backtrace_cleaner |
bc = Rails.backtrace_cleaner |
||||
bc.add_silencer { |line| %r{^lib/(monkey_patches|formatters)}.match?(line) } |
|
||||
|
bc.add_silencer { |line| %r{^lib/(monkey_patches|semantic)}.match?(line) } |
@ -1,18 +1,17 @@ |
|||||
if defined?(RailsLiveReload) && Rails.env.development? |
|
||||
|
return unless defined?(RailsLiveReload) && Rails.env.development? |
||||
|
|
||||
RailsLiveReload.configure do |config| |
|
||||
# HOT Constants |
|
||||
config.watch(%r{/\.env$}, reload: :always) |
|
||||
config.watch(%r{/\.env\.sample$}) |
|
||||
# config.watch(%r{/config/initializers/hot_changes.rb$}) |
|
||||
|
RailsLiveReload.configure do |config| |
||||
|
# HOT Constants |
||||
|
config.watch(%r{/\.env$}, reload: :always) |
||||
|
config.watch(%r{/\.env\.sample$}) |
||||
|
# config.watch(%r{/config/initializers/hot_changes.rb$}) |
||||
|
|
||||
# USEFUL for tailwind changes!!!! |
|
||||
config.watch %r{app/assets/builds/tailwind.css}, reload: :always |
|
||||
|
# USEFUL for tailwind changes!!!! |
||||
|
config.watch %r{app/assets/builds/tailwind.css}, reload: :always |
||||
|
|
||||
# Rk: prevent any reload from files ending with '.tailwind.css' |
|
||||
config.watch %r{(app|vendor)/(assets|javascript)/.+\.(css|js|html|png|jpg)(?<!tailwind\.css)$}, reload: :always |
|
||||
|
# Rk: prevent any reload from files ending with '.tailwind.css' |
||||
|
config.watch %r{(app|vendor)/(assets|javascript)/.+\.(css|js|html|png|jpg)(?<!tailwind\.css)$}, reload: :always |
||||
|
|
||||
# Default watched folders & files |
|
||||
config.watch %r{app/views/.+\.(erb|haml|slim)$} |
|
||||
end |
|
||||
|
# Default watched folders & files |
||||
|
config.watch %r{app/views/.+\.(erb|haml|slim)$} |
||||
end |
end |
Write
Preview
Loading…
Cancel
Save
Reference in new issue