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
-
9app/views/scores/_scores.html.erb
-
4config/environments/production.rb
-
6config/environments/test.rb
-
2config/initializers/backtrace_cleaning.rb
-
2config/initializers/hot_changes.rb
-
3config/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) } |
Write
Preview
Loading…
Cancel
Save
Reference in new issue