Class: Monolith::ExceptionsController::Show
- Inherits:
-
View
- Object
- View
- Monolith::ExceptionsController::Show
- Defined in:
- app/controllers/monolith/exceptions_controller.rb
Overview
Phlex views
Instance Attribute Summary collapse
-
#exception ⇒ Object
writeonly
Sets the attribute exception.
Instance Method Summary collapse
- #render_grouped_trace(grouped_trace) ⇒ Object
- #render_source_extract(extract) ⇒ Object
- #view_template ⇒ Object
Instance Attribute Details
#exception=(value) ⇒ Object (writeonly)
Sets the attribute exception
181 182 183 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 181 def exception=(value) @exception = value end |
Instance Method Details
#render_grouped_trace(grouped_trace) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 264 def render_grouped_trace(grouped_trace) # Group frames by category current_group = nil grouped_trace.each_with_index do |frame_data, idx| # If we're starting a new group, render the group header if current_group != frame_data[:group] current_group = frame_data[:group] # Group header with subtle color coding group_color = case current_group when 'Application' then 'bg-blue-900/50' when 'Gems' then 'bg-purple-900/50' when 'Framework' then 'bg-green-900/50' when 'Ruby' then 'bg-red-900/50' else 'bg-gray-700' end div(class: "#{group_color} text-gray-300 px-4 py-2 text-xs font-bold uppercase tracking-wide") do plain current_group end end # Render the frame (clickable link with Turbo Frame target) if frame_data[:file] && frame_data[:line] a( href: url_for(controller: 'monolith/exceptions', action: 'source', file: frame_data[:file], line: frame_data[:line]), class: "block border-b border-gray-700 px-4 py-3 font-mono text-xs hover:bg-gray-700/50 transition-colors no-underline", data_turbo_frame: "source-view" ) do div(class: "truncate text-gray-200 mb-1 font-medium") { plain frame_data[:file] } div(class: "text-gray-400 text-xs") do span(class: "text-cyan-400") { "Line #{frame_data[:line]}" } if frame_data[:method] plain " • " code(class: "text-yellow-300") { frame_data[:method] } end end end else div(class: "border-b border-gray-700 px-4 py-3 font-mono text-xs") do code(class: "text-xs text-gray-400") { frame_data[:frame] } end end end end |
#render_source_extract(extract) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 216 def render_source_extract(extract) return unless extract div(class: "min-h-full bg-gray-900") do # File header (sticky at top) div(class: "sticky top-0 bg-gray-800 text-gray-300 px-6 py-3 font-mono text-xs border-b border-gray-700 z-10") do span(class: "text-gray-500") { "📄 " } span(class: "text-green-400") { extract[:file] } end # Code lines - text editor style div(class: "p-6") do div(class: "font-mono text-sm") do extract[:lines].each do |line_data| div( id: "L#{line_data[:number]}", class: line_data[:highlighted] ? "bg-red-900/30 border-l-4 border-red-500" : "" ) do div(class: "flex") do # Line number (left side, text editor style) div(class: "px-4 py-1 text-right select-none text-gray-600 min-w-[4rem]") do if line_data[:highlighted] span(class: "text-red-400 font-bold") { line_data[:number].to_s } else plain line_data[:number].to_s end end # Code content div(class: "px-4 py-1 flex-1 whitespace-pre") do code(class: line_data[:highlighted] ? "text-red-300" : "text-gray-300") do plain line_data[:content] end end end end end end end # Auto-scroll to highlighted line on load if extract[:line_number] script do raw safe("setTimeout(() => { const frame = document.getElementById('source-view'); const el = document.getElementById('L#{extract[:line_number]}'); if (frame && el) { el.scrollIntoView({ block: 'center', behavior: 'instant' }); } }, 10);") end end end end |
#view_template ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 183 def view_template e = @exception # Full-screen dark background with code editor aesthetic div(class: "relative h-screen overflow-hidden bg-gray-900") do # Main scrollable code area (fills entire screen) - wrapped in turbo frame turbo_frame_tag "source-view", class: "h-full overflow-y-auto block" do extract = e.source_extract if extract render_source_extract(extract) else div(class: "flex items-center justify-center h-full text-gray-500 font-mono text-sm") do plain "Click a stack frame to view source" end end end # Floating HUD on the right side div(class: "fixed top-20 right-8 w-96 max-h-[calc(100vh-6rem)] flex flex-col bg-gray-800/80 backdrop-blur-md rounded-xl shadow-2xl border border-gray-700 overflow-hidden") do # Exception header (fixed at top of HUD) div(class: "bg-gray-700 text-white p-4 border-b border-gray-600") do h1(class: "text-lg font-bold mb-1 text-red-400") { e.class_name } p(class: "text-sm text-gray-300 leading-snug") { e. } end # Scrollable stack trace div(class: "overflow-y-auto flex-1") do render_grouped_trace(e.grouped_trace) end end end end |