Class: Decidim::FaviconController
- Inherits:
-
DecidimController
- Object
- DecidimController
- Decidim::FaviconController
- Includes:
- ActionController::DataStreaming, NeedsOrganization
- Defined in:
- app/controllers/decidim/favicon_controller.rb
Overview
We serve a custom /favicon.ico route for Decidim in order to show the correct favicons also when browsing e.g. PDF documents originating from the same domain displayed inline in the browser. For those special files displayed in the browser, the favicon could be otherwise incorrectly shown or cached.
This custom route ensures that the favicons are always correctly served for the domain.
Instance Method Summary collapse
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#show ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/decidim/favicon_controller.rb', line 21 def show response.headers["Content-Type"] = "image/vnd.microsoft.icon" response.headers["Content-Disposition"] = %(inline; filename="favicon.ico") return render_blank_favicon unless favicon_blob return unless stale?(favicon_blob, public: true, last_modified: favicon_blob.created_at) expires_in 1.week, public: true # For Rails 7, check out `send_blob_stream`. favicon_blob.download do |chunk| response.stream.write(chunk) end end |