Module: Ideasbugs::Widget
- Defined in:
- lib/ideasbugs/widget.rb
Overview
Serves the self-contained browser widget. The JavaScript is plain ES (no framework, no build step) and styles itself inline, so it drops into any Rails app regardless of its CSS or JS setup. It is served by the engine's own controller rather than through the host's asset pipeline, so there is no dependency on it — and it lives under lib/ (not app/assets/) so a host that does run a pipeline never ingests it either: nothing lands in the host's asset namespace or precompiled output.
Constant Summary collapse
- SOURCE =
File.('widget.js', __dir__)
- DASHBOARD_STYLESHEET_SOURCE =
File.('dashboard.css', __dir__)
- RTL_LANGUAGES =
Right-to-left scripts, so the form renders mirrored for those locales. Matched on the language subtag, so region variants ("ar-EG") count too.
%w[ar arc ckb dv fa ha he ks ku ps sd ug ur yi].freeze
Class Method Summary collapse
- .dashboard_stylesheet ⇒ Object
- .dashboard_stylesheet_fingerprint ⇒ Object
-
.fingerprint ⇒ Object
Content fingerprint for the cache-busting script URL: a changed file is a changed URL, so no browser can ever run stale widget code — Safari has been caught ignoring must-revalidate on same-URL scripts.
- .javascript ⇒ Object
-
.snippet(endpoint:, locale:, nonce: nil) ⇒ Object
The two
27 28 29
# File 'lib/ideasbugs/widget.rb', line 27 def dashboard_stylesheet @dashboard_stylesheet ||= File.read(DASHBOARD_STYLESHEET_SOURCE) end
.dashboard_stylesheet_fingerprint ⇒ Object
38 39 40
# File 'lib/ideasbugs/widget.rb', line 38 def dashboard_stylesheet_fingerprint @dashboard_stylesheet_fingerprint ||= Digest::MD5.hexdigest(dashboard_stylesheet) end
.fingerprint ⇒ Object
Content fingerprint for the cache-busting script URL: a changed file is a changed URL, so no browser can ever run stale widget code — Safari has been caught ignoring must-revalidate on same-URL scripts.
34 35 36
# File 'lib/ideasbugs/widget.rb', line 34 def fingerprint @fingerprint ||= Digest::MD5.hexdigest(javascript) end
.javascript ⇒ Object
23 24 25
# File 'lib/ideasbugs/widget.rb', line 23 def javascript @javascript ||= File.read(SOURCE) end
.snippet(endpoint:, locale:, nonce: nil) ⇒ Object
The two