Handle css and js files
Seto Elkahfi committed
Jun 17, 2026 at 08:25 UTC
64df9c10cd50bba5ce5a4f65ba62f424db8bf884
2 files changed
+12
-1
Gemfile.lock
+1
-1
index 4571d3b..41a546e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -373,7 +373,7 @@ DEPENDENCIES
redcarpet (~> 3.6)
rouge (~> 4.5)
rubocop-rails-omakase
- smbcloud-auth (~> 0.3.34)
+ smbcloud-auth (~> 0.3.35)
solid_cable
solid_cache
solid_queue
app/controllers/blobs_controller.rb
+11
index f987d88..2c33acf 100644
--- a/app/controllers/blobs_controller.rb
+++ b/app/controllers/blobs_controller.rb
@@ -4,6 +4,15 @@ class BlobsController < ApplicationController
before_action :ensure_can_read!
def show
+ # A file path like ".../app.js" or "...style.css" makes Rails negotiate a
+ # non-HTML format from the trailing extension — which has no template (→
+ # UnknownFormat) and, for ":js", also skips the HTML layout. Pinning the view
+ # lookup formats governs both template and layout resolution; request.format
+ # sets the response content type. Together they make any file type render as
+ # a full, styled HTML page.
+ request.format = :html
+ lookup_context.formats = [ :html ]
+
@branch = params[:branch]
@file_path = params[:path]
@path_parts = @file_path.to_s.split("/").reject(&:blank?)
@@ -25,6 +34,8 @@ class BlobsController < ApplicationController
@highlighted_lines = highlight_lines(content, @filename)
@line_count = content.lines.count
end
+
+ render :show
end
def raw