Class: Testimonials::WidgetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/testimonials/widgets_controller.rb

Overview

Serves the widget JavaScript as a plain same-origin script. Same-origin matters: under a script-src 'self' (or nonce-based) CSP, an external script from the app's own host is always allowed — including when Turbo Drive swaps the and re-runs body scripts under the original page's CSP header, where a freshly minted inline nonce would be refused.

Instance Method Summary collapse

Instance Method Details

#dashboardObject



23
24
25
# File 'app/controllers/testimonials/widgets_controller.rb', line 23

def dashboard
  serve(Widget.dashboard_javascript, Widget.dashboard_fingerprint)
end

#showObject

The script URLs carry a content fingerprint (?v=), so stale code is structurally impossible: new code means a new URL. The canonical fingerprinted URL is immutable and gets long-lived caching; anything else only ETag-revalidates.



19
20
21
# File 'app/controllers/testimonials/widgets_controller.rb', line 19

def show
  serve(Widget.javascript, Widget.fingerprint)
end