tina4ruby 3.10.42 → 3.10.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,13 +70,27 @@ module Tina4
70
70
  msg = messages[code] || "Error"
71
71
  colors = { 403 => "#f59e0b", 404 => "#3b82f6", 500 => "#ef4444" }
72
72
  color = colors[code] || "#ef4444"
73
+
73
74
  <<~HTML
74
75
  <!DOCTYPE html>
75
76
  <html lang="en">
76
- <head>
77
- <meta charset="utf-8">
78
- <meta name="viewport" content="width=device-width, initial-scale=1">
79
- <title>#{code} — #{msg}</title>
77
+ #{error_overlay_head("#{code} — #{msg}")}
78
+ <body>
79
+ #{error_overlay_css(color)}
80
+ <div class="error-card">
81
+ <div class="logo">T4</div>
82
+ <div class="error-code">#{code}</div>
83
+ <div class="error-title">#{msg}</div>
84
+ <div class="error-msg">Something went wrong while processing your request.</div>
85
+ <a href="/" class="error-home">Go Home</a>
86
+ </div>
87
+ </body>
88
+ </html>
89
+ HTML
90
+ end
91
+
92
+ def error_overlay_css(color)
93
+ <<~CSS
80
94
  <style>
81
95
  * { box-sizing: border-box; margin: 0; padding: 0; }
82
96
  body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
@@ -88,18 +102,46 @@ module Tina4
88
102
  .error-home:hover { opacity: 0.9; }
89
103
  .logo { font-size: 1.5rem; margin-bottom: 1rem; opacity: 0.5; }
90
104
  </style>
105
+ CSS
106
+ end
107
+
108
+ def error_overlay_head(title)
109
+ <<~HEAD
110
+ <head>
111
+ <meta charset="utf-8">
112
+ <meta name="viewport" content="width=device-width, initial-scale=1">
113
+ <title>#{title}</title>
91
114
  </head>
92
- <body>
93
- <div class="error-card">
94
- <div class="logo">T4</div>
95
- <div class="error-code">#{code}</div>
96
- <div class="error-title">#{msg}</div>
97
- <div class="error-msg">Something went wrong while processing your request.</div>
98
- <a href="/" class="error-home">Go Home</a>
99
- </div>
100
- </body>
101
- </html>
102
- HTML
115
+ HEAD
116
+ end
117
+
118
+ def error_overlay_stacktrace(exception)
119
+ return "" unless exception.respond_to?(:backtrace) && exception.backtrace
120
+ lines = exception.backtrace.map { |l| "<li>#{l}</li>" }.join("\n")
121
+ "<ul class=\"stacktrace\">#{lines}</ul>"
122
+ end
123
+
124
+ def error_overlay_source(file, line)
125
+ return "" unless file && line && File.exist?(file)
126
+ lines = File.readlines(file)
127
+ start = [line.to_i - 4, 0].max
128
+ finish = [line.to_i + 3, lines.length - 1].min
129
+ snippet = lines[start..finish].each_with_index.map do |l, i|
130
+ num = start + i + 1
131
+ "<div class=\"source-line#{num == line.to_i ? ' highlight' : ''}\"><span class=\"line-num\">#{num}</span>#{l.chomp}</div>"
132
+ end.join("\n")
133
+ "<pre class=\"source-context\">#{snippet}</pre>"
134
+ end
135
+
136
+ def error_overlay_request(env)
137
+ return "" unless env.is_a?(Hash)
138
+ method = env["REQUEST_METHOD"] || "?"
139
+ path = env["PATH_INFO"] || "?"
140
+ "<div class=\"request-info\"><strong>#{method}</strong> #{path}</div>"
141
+ end
142
+
143
+ def error_overlay_env
144
+ "<div class=\"env-info\">Ruby #{RUBY_VERSION} | Tina4</div>"
103
145
  end
104
146
  end
105
147
 
data/lib/tina4/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.10.42"
4
+ VERSION = "3.10.44"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.42
4
+ version: 3.10.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team