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.
- checksums.yaml +4 -4
- data/lib/tina4/ai.rb +492 -134
- data/lib/tina4/cli.rb +784 -74
- data/lib/tina4/database.rb +12 -5
- data/lib/tina4/dev_admin.rb +266 -66
- data/lib/tina4/events.rb +19 -0
- data/lib/tina4/field_types.rb +6 -1
- data/lib/tina4/frond.rb +112 -81
- data/lib/tina4/metrics.rb +43 -2
- data/lib/tina4/orm.rb +17 -7
- data/lib/tina4/public/js/tina4-dev-admin.min.js +167 -28
- data/lib/tina4/query_builder.rb +8 -2
- data/lib/tina4/rack_app.rb +17 -1
- data/lib/tina4/template.rb +57 -15
- data/lib/tina4/version.rb +1 -1
- metadata +1 -1
data/lib/tina4/template.rb
CHANGED
|
@@ -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
|
-
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
<
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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