tina4ruby 0.5.2 → 3.0.0

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/README.md +360 -559
  4. data/exe/{tina4 → tina4ruby} +1 -0
  5. data/lib/tina4/ai.rb +312 -0
  6. data/lib/tina4/auth.rb +44 -3
  7. data/lib/tina4/auto_crud.rb +163 -0
  8. data/lib/tina4/cli.rb +242 -77
  9. data/lib/tina4/constants.rb +46 -0
  10. data/lib/tina4/cors.rb +74 -0
  11. data/lib/tina4/database/sqlite3_adapter.rb +139 -0
  12. data/lib/tina4/database.rb +43 -7
  13. data/lib/tina4/debug.rb +4 -79
  14. data/lib/tina4/dev_admin.rb +1162 -0
  15. data/lib/tina4/dev_mailbox.rb +191 -0
  16. data/lib/tina4/dev_reload.rb +9 -9
  17. data/lib/tina4/drivers/firebird_driver.rb +19 -3
  18. data/lib/tina4/drivers/mssql_driver.rb +3 -3
  19. data/lib/tina4/drivers/mysql_driver.rb +4 -4
  20. data/lib/tina4/drivers/postgres_driver.rb +9 -2
  21. data/lib/tina4/drivers/sqlite_driver.rb +1 -1
  22. data/lib/tina4/env.rb +42 -2
  23. data/lib/tina4/error_overlay.rb +252 -0
  24. data/lib/tina4/events.rb +90 -0
  25. data/lib/tina4/field_types.rb +4 -0
  26. data/lib/tina4/frond.rb +1336 -0
  27. data/lib/tina4/gallery/auth/meta.json +1 -0
  28. data/lib/tina4/gallery/auth/src/routes/api/gallery_auth.rb +114 -0
  29. data/lib/tina4/gallery/database/meta.json +1 -0
  30. data/lib/tina4/gallery/database/src/routes/api/gallery_db.rb +43 -0
  31. data/lib/tina4/gallery/error-overlay/meta.json +1 -0
  32. data/lib/tina4/gallery/error-overlay/src/routes/api/gallery_crash.rb +17 -0
  33. data/lib/tina4/gallery/orm/meta.json +1 -0
  34. data/lib/tina4/gallery/orm/src/routes/api/gallery_products.rb +16 -0
  35. data/lib/tina4/gallery/queue/meta.json +1 -0
  36. data/lib/tina4/gallery/queue/src/routes/api/gallery_queue.rb +27 -0
  37. data/lib/tina4/gallery/rest-api/meta.json +1 -0
  38. data/lib/tina4/gallery/rest-api/src/routes/api/gallery_hello.rb +14 -0
  39. data/lib/tina4/gallery/templates/meta.json +1 -0
  40. data/lib/tina4/gallery/templates/src/routes/gallery_page.rb +12 -0
  41. data/lib/tina4/gallery/templates/src/templates/gallery_page.twig +257 -0
  42. data/lib/tina4/health.rb +39 -0
  43. data/lib/tina4/html_element.rb +148 -0
  44. data/lib/tina4/localization.rb +2 -2
  45. data/lib/tina4/log.rb +203 -0
  46. data/lib/tina4/messenger.rb +484 -0
  47. data/lib/tina4/migration.rb +132 -29
  48. data/lib/tina4/orm.rb +337 -31
  49. data/lib/tina4/public/css/tina4.css +178 -1
  50. data/lib/tina4/public/css/tina4.min.css +1 -2
  51. data/lib/tina4/public/favicon.ico +0 -0
  52. data/lib/tina4/public/images/logo.svg +5 -0
  53. data/lib/tina4/public/images/tina4-logo-icon.webp +0 -0
  54. data/lib/tina4/public/js/frond.min.js +420 -0
  55. data/lib/tina4/public/js/tina4-dev-admin.min.js +367 -0
  56. data/lib/tina4/public/js/tina4.min.js +93 -0
  57. data/lib/tina4/public/swagger/index.html +90 -0
  58. data/lib/tina4/public/swagger/oauth2-redirect.html +63 -0
  59. data/lib/tina4/queue.rb +40 -4
  60. data/lib/tina4/queue_backends/lite_backend.rb +88 -0
  61. data/lib/tina4/rack_app.rb +314 -23
  62. data/lib/tina4/rate_limiter.rb +123 -0
  63. data/lib/tina4/request.rb +61 -15
  64. data/lib/tina4/response.rb +54 -24
  65. data/lib/tina4/response_cache.rb +134 -0
  66. data/lib/tina4/router.rb +90 -15
  67. data/lib/tina4/scss_compiler.rb +2 -2
  68. data/lib/tina4/seeder.rb +56 -61
  69. data/lib/tina4/service_runner.rb +303 -0
  70. data/lib/tina4/session.rb +85 -0
  71. data/lib/tina4/session_handlers/mongo_handler.rb +1 -1
  72. data/lib/tina4/session_handlers/valkey_handler.rb +43 -0
  73. data/lib/tina4/shutdown.rb +84 -0
  74. data/lib/tina4/sql_translation.rb +295 -0
  75. data/lib/tina4/template.rb +36 -6
  76. data/lib/tina4/templates/base.twig +2 -2
  77. data/lib/tina4/templates/errors/302.twig +14 -0
  78. data/lib/tina4/templates/errors/401.twig +9 -0
  79. data/lib/tina4/templates/errors/403.twig +22 -15
  80. data/lib/tina4/templates/errors/404.twig +22 -15
  81. data/lib/tina4/templates/errors/500.twig +31 -15
  82. data/lib/tina4/templates/errors/502.twig +9 -0
  83. data/lib/tina4/templates/errors/503.twig +12 -0
  84. data/lib/tina4/templates/errors/base.twig +37 -0
  85. data/lib/tina4/version.rb +1 -1
  86. data/lib/tina4/webserver.rb +28 -18
  87. data/lib/tina4.rb +57 -21
  88. metadata +51 -19
  89. data/lib/tina4/public/js/tina4.js +0 -134
  90. data/lib/tina4/public/js/tina4helper.js +0 -387
@@ -0,0 +1 @@
1
+ {"name": "Auth", "description": "JWT login form with token display", "try_url": "/gallery/auth"}
@@ -0,0 +1,114 @@
1
+ # Gallery: Auth — JWT login with a visual demo page.
2
+
3
+ Tina4::Router.get("/gallery/auth") do |request, response|
4
+ html = <<~HTML
5
+ <!DOCTYPE html>
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
9
+ <title>Auth Demo</title><link rel="stylesheet" href="/css/tina4.min.css">
10
+ </head>
11
+ <body class="bg-dark text-light">
12
+ <div class="container mt-5" style="max-width:600px;">
13
+ <h2 class="mb-4">JWT Authentication Demo</h2>
14
+ <div class="card mb-4">
15
+ <div class="card-header bg-primary text-white">Login</div>
16
+ <div class="card-body">
17
+ <div class="form-group mb-3">
18
+ <label class="form-label">Username</label>
19
+ <input type="text" id="username" class="form-control" placeholder="admin" value="admin">
20
+ </div>
21
+ <div class="form-group mb-3">
22
+ <label class="form-label">Password</label>
23
+ <input type="password" id="password" class="form-control" placeholder="secret" value="secret">
24
+ </div>
25
+ <button class="btn btn-primary" onclick="doLogin()">Login</button>
26
+ </div>
27
+ </div>
28
+ <div id="result" style="display:none;">
29
+ <div class="card mb-3">
30
+ <div class="card-header bg-success text-white">Token Received</div>
31
+ <div class="card-body">
32
+ <pre id="token" style="word-break:break-all;white-space:pre-wrap;color:#4ade80;background:#1e293b;padding:1rem;border-radius:0.5rem;"></pre>
33
+ </div>
34
+ </div>
35
+ <div class="card mb-3">
36
+ <div class="card-header">Token Payload (decoded)</div>
37
+ <div class="card-body">
38
+ <pre id="payload" style="color:#38bdf8;background:#1e293b;padding:1rem;border-radius:0.5rem;"></pre>
39
+ </div>
40
+ </div>
41
+ <button class="btn btn-outline-info" onclick="verifyToken()">Verify Token</button>
42
+ <span id="verify-result" class="ms-2"></span>
43
+ </div>
44
+ <div class="card bg-dark mt-4" style="border:1px solid #334155;">
45
+ <div class="card-body">
46
+ <h6 style="color:#e2e8f0;">How it works</h6>
47
+ <pre style="background:#0f172a;color:#4ade80;padding:1rem;border-radius:0.5rem;font-size:0.8rem;"><code>token = Tina4::Auth.create_token({ username: "admin" })
48
+ payload = Tina4::Auth.get_payload(token)
49
+ result = Tina4::Auth.validate_token(token)</code></pre>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <script>
54
+ var currentToken = '';
55
+ function doLogin() {
56
+ fetch('/api/gallery/auth/login', {
57
+ method: 'POST',
58
+ headers: {'Content-Type': 'application/json'},
59
+ body: JSON.stringify({
60
+ username: document.getElementById('username').value,
61
+ password: document.getElementById('password').value
62
+ })
63
+ }).then(r => r.json()).then(d => {
64
+ if (d.token) {
65
+ currentToken = d.token;
66
+ document.getElementById('token').textContent = d.token;
67
+ try {
68
+ var parts = d.token.split('.');
69
+ var payload = JSON.parse(atob(parts[1]));
70
+ document.getElementById('payload').textContent = JSON.stringify(payload, null, 2);
71
+ } catch(e) {
72
+ document.getElementById('payload').textContent = 'Could not decode';
73
+ }
74
+ document.getElementById('result').style.display = 'block';
75
+ document.getElementById('verify-result').textContent = '';
76
+ } else {
77
+ alert(d.error || 'Login failed');
78
+ }
79
+ });
80
+ }
81
+ function verifyToken() {
82
+ fetch('/api/gallery/auth/verify?token=' + encodeURIComponent(currentToken))
83
+ .then(r => r.json()).then(d => {
84
+ var el = document.getElementById('verify-result');
85
+ if (d.valid) {
86
+ el.innerHTML = '<span class="badge bg-success">Valid</span>';
87
+ } else {
88
+ el.innerHTML = '<span class="badge bg-danger">Invalid</span>';
89
+ }
90
+ });
91
+ }
92
+ </script>
93
+ </body></html>
94
+ HTML
95
+ response.html(html)
96
+ end
97
+
98
+ Tina4::Router.post("/api/gallery/auth/login") do |request, response|
99
+ body = request.body || {}
100
+ username = body["username"].to_s
101
+ password = body["password"].to_s
102
+ if !username.empty? && !password.empty?
103
+ token = Tina4::Auth.create_token({ username: username, role: "user" })
104
+ response.json({ token: token, message: "Welcome #{username}!" })
105
+ else
106
+ response.json({ error: "Username and password required" }, 401)
107
+ end
108
+ end
109
+
110
+ Tina4::Router.get("/api/gallery/auth/verify") do |request, response|
111
+ token = request.params["token"].to_s
112
+ result = Tina4::Auth.validate_token(token)
113
+ response.json({ valid: result[:valid] })
114
+ end
@@ -0,0 +1 @@
1
+ {"name": "Database", "description": "Raw SQL queries with the Database class", "try_url": "/api/gallery/db/tables"}
@@ -0,0 +1,43 @@
1
+ # Gallery: Database — raw SQL query demo.
2
+
3
+ Tina4::Router.get("/api/gallery/db/tables") do |request, response|
4
+ begin
5
+ db = Tina4::Database.new("sqlite://data/gallery.db")
6
+ db.execute(<<~SQL)
7
+ CREATE TABLE IF NOT EXISTS gallery_notes (
8
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
9
+ title TEXT NOT NULL,
10
+ body TEXT,
11
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
12
+ )
13
+ SQL
14
+ tables = db.tables
15
+ response.json({ tables: tables, engine: "sqlite" })
16
+ rescue => e
17
+ response.json({ error: e.message }, 500)
18
+ end
19
+ end
20
+
21
+ Tina4::Router.post("/api/gallery/db/notes") do |request, response|
22
+ begin
23
+ db = Tina4::Database.new("sqlite://data/gallery.db")
24
+ body = request.body || {}
25
+ db.insert("gallery_notes", {
26
+ title: body["title"] || "Untitled",
27
+ body: body["body"] || ""
28
+ })
29
+ response.json({ created: true }, 201)
30
+ rescue => e
31
+ response.json({ error: e.message }, 500)
32
+ end
33
+ end
34
+
35
+ Tina4::Router.get("/api/gallery/db/notes") do |request, response|
36
+ begin
37
+ db = Tina4::Database.new("sqlite://data/gallery.db")
38
+ result = db.fetch("SELECT * FROM gallery_notes ORDER BY id DESC", [], limit: 50)
39
+ response.json(result.to_a)
40
+ rescue => e
41
+ response.json({ error: e.message }, 500)
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ {"name": "Error Overlay", "description": "See the rich debug error page with stack trace and source code", "try_url": "/api/gallery/crash"}
@@ -0,0 +1,17 @@
1
+ # Gallery: Error Overlay — deliberately crash to demo the debug overlay.
2
+ #
3
+ # This route deliberately raises an error to showcase the error overlay.
4
+ #
5
+ # In debug mode (TINA4_DEBUG=true), you will see:
6
+ # - Exception type and message
7
+ # - Stack trace with syntax-highlighted source code
8
+ # - The exact line that caused the error (highlighted)
9
+ # - Request details (method, path, headers)
10
+ # - Environment info (framework version, Ruby version)
11
+
12
+ Tina4::Router.get("/api/gallery/crash") do |request, response|
13
+ # Simulate a realistic error — accessing a missing key
14
+ user = { name: "Alice", email: "alice@example.com" }
15
+ role = user.fetch(:role) # KeyError: key not found: :role — this line will be highlighted in the overlay
16
+ response.json({ role: role })
17
+ end
@@ -0,0 +1 @@
1
+ {"name": "ORM", "description": "Product model with CRUD endpoints", "try_url": "/api/gallery/products"}
@@ -0,0 +1,16 @@
1
+ # Gallery: ORM — Product CRUD endpoints.
2
+
3
+ Tina4::Router.get("/api/gallery/products") do |request, response|
4
+ response.json({
5
+ products: [
6
+ { id: 1, name: "Widget", price: 9.99 },
7
+ { id: 2, name: "Gadget", price: 24.99 }
8
+ ],
9
+ note: "Connect a database and deploy the ORM model for live data"
10
+ })
11
+ end
12
+
13
+ Tina4::Router.post("/api/gallery/products") do |request, response|
14
+ data = request.body || {}
15
+ response.json({ created: data, id: 3 }, 201)
16
+ end
@@ -0,0 +1 @@
1
+ {"name": "Queue", "description": "Background job producer and consumer", "try_url": "/api/gallery/queue/produce"}
@@ -0,0 +1,27 @@
1
+ # Gallery: Queue — produce and consume background jobs.
2
+
3
+ Tina4::Router.post("/api/gallery/queue/produce") do |request, response|
4
+ body = request.body || {}
5
+ task = body["task"] || "default-task"
6
+ data = body["data"] || {}
7
+
8
+ begin
9
+ db = Tina4::Database.new("sqlite://data/gallery_queue.db")
10
+ queue = Tina4::Queue.new(db, topic: "gallery-tasks")
11
+ producer = Tina4::Producer.new(queue)
12
+ producer.produce({ task: task, data: data })
13
+ response.json({ queued: true, task: task }, 201)
14
+ rescue => e
15
+ response.json({ queued: true, task: task, note: "Queue demo (#{e.message})" }, 201)
16
+ end
17
+ end
18
+
19
+ Tina4::Router.get("/api/gallery/queue/status") do |request, response|
20
+ begin
21
+ db = Tina4::Database.new("sqlite://data/gallery_queue.db")
22
+ queue = Tina4::Queue.new(db, topic: "gallery-tasks")
23
+ response.json({ topic: "gallery-tasks", size: queue.size })
24
+ rescue => e
25
+ response.json({ topic: "gallery-tasks", size: 0, note: "Queue demo (#{e.message})" })
26
+ end
27
+ end
@@ -0,0 +1 @@
1
+ {"name": "REST API", "description": "A simple JSON API with GET and POST endpoints", "try_url": "/api/gallery/hello"}
@@ -0,0 +1,14 @@
1
+ # Gallery: REST API — simple JSON endpoints.
2
+
3
+ Tina4::Router.get("/api/gallery/hello") do |request, response|
4
+ response.json({ message: "Hello from Tina4!", method: "GET" })
5
+ end
6
+
7
+ Tina4::Router.get("/api/gallery/hello/{name}") do |request, response|
8
+ response.json({ message: "Hello #{request.params["name"]}!", method: "GET" })
9
+ end
10
+
11
+ Tina4::Router.post("/api/gallery/hello") do |request, response|
12
+ data = request.body || {}
13
+ response.json({ echo: data, method: "POST" }, 201)
14
+ end
@@ -0,0 +1 @@
1
+ {"name": "Templates", "description": "Twig template with dynamic data", "try_url": "/gallery/page"}
@@ -0,0 +1,12 @@
1
+ # Gallery: Templates — render an HTML page with dynamic data via template.
2
+
3
+ Tina4::Router.get "/gallery/page", template: "gallery_page.twig" do |request, response|
4
+ response.call({
5
+ title: "Gallery Demo Page",
6
+ items: [
7
+ { name: "Tina4 Ruby", description: "Zero-dep web framework", badge: "v3.0.0" },
8
+ { name: "Twig Engine", description: "Built-in template rendering", badge: "included" },
9
+ { name: "Auto-Reload", description: "Templates refresh on save", badge: "dev mode" }
10
+ ]
11
+ }, Tina4::HTTP_OK)
12
+ end
@@ -0,0 +1,257 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>{{ title }}</title>
7
+ <link rel="stylesheet" href="/css/tina4.min.css">
8
+ <style>
9
+ .component-section { margin-bottom: 2.5rem; }
10
+ .component-section h3 { border-bottom: 2px solid var(--bs-primary, #0d6efd); padding-bottom: 0.5rem; margin-bottom: 1rem; }
11
+ .code-preview { background: #1e293b; color: #4ade80; padding: 1rem; border-radius: 0.5rem; font-family: monospace; font-size: 0.85rem; overflow-x: auto; margin-top: 0.75rem; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+
16
+ <!-- Navbar -->
17
+ <nav class="navbar navbar-dark bg-dark navbar-expand-lg">
18
+ <div class="container">
19
+ <a class="navbar-brand" href="/">Tina4 CSS Showcase</a>
20
+ <div class="navbar-nav ms-auto">
21
+ <a class="nav-link active" href="#">Components</a>
22
+ <a class="nav-link" href="/__dev">Dashboard</a>
23
+ <a class="nav-link" href="/swagger">API Docs</a>
24
+ </div>
25
+ </div>
26
+ </nav>
27
+
28
+ <div class="container mt-4">
29
+
30
+ <div class="alert alert-info alert-dismissible mb-4">
31
+ <strong>tina4css</strong> — Zero-dependency CSS framework (~24KB). Bootstrap-compatible class names, dark mode ready. No CDN needed — ships with every Tina4 project.
32
+ <button type="button" class="btn-close" onclick="this.parentElement.remove()"></button>
33
+ </div>
34
+
35
+ <!-- Buttons -->
36
+ <div class="component-section">
37
+ <h3>Buttons</h3>
38
+ <div class="d-flex flex-wrap gap-2 mb-3">
39
+ <button class="btn btn-primary">Primary</button>
40
+ <button class="btn btn-secondary">Secondary</button>
41
+ <button class="btn btn-success">Success</button>
42
+ <button class="btn btn-danger">Danger</button>
43
+ <button class="btn btn-warning">Warning</button>
44
+ <button class="btn btn-info">Info</button>
45
+ <button class="btn btn-dark">Dark</button>
46
+ <button class="btn btn-light">Light</button>
47
+ </div>
48
+ <div class="d-flex flex-wrap gap-2 mb-3">
49
+ <button class="btn btn-outline-primary">Outline</button>
50
+ <button class="btn btn-outline-success">Outline</button>
51
+ <button class="btn btn-outline-danger">Outline</button>
52
+ <button class="btn btn-outline-warning">Outline</button>
53
+ </div>
54
+ <div class="d-flex flex-wrap gap-2">
55
+ <button class="btn btn-primary btn-lg">Large</button>
56
+ <button class="btn btn-primary">Default</button>
57
+ <button class="btn btn-primary btn-sm">Small</button>
58
+ </div>
59
+ </div>
60
+
61
+ <!-- Alerts -->
62
+ <div class="component-section">
63
+ <h3>Alerts</h3>
64
+ <div class="alert alert-success">Success — Record saved successfully!</div>
65
+ <div class="alert alert-danger">Error — Something went wrong.</div>
66
+ <div class="alert alert-warning">Warning — Please check your input.</div>
67
+ <div class="alert alert-info">Info — New version available.</div>
68
+ </div>
69
+
70
+ <!-- Cards -->
71
+ <div class="component-section">
72
+ <h3>Cards</h3>
73
+ <div class="row">
74
+ {% for item in items %}
75
+ <div class="col-md-4 mb-3">
76
+ <div class="card h-100">
77
+ <div class="card-header bg-primary text-white">{{ item.name }}</div>
78
+ <div class="card-body">
79
+ <p class="card-text">{{ item.description }}</p>
80
+ <span class="badge bg-success">{{ item.badge }}</span>
81
+ </div>
82
+ <div class="card-footer text-muted">
83
+ <small>Built with tina4css</small>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ {% endfor %}
88
+ </div>
89
+ </div>
90
+
91
+ <!-- Badges -->
92
+ <div class="component-section">
93
+ <h3>Badges</h3>
94
+ <span class="badge bg-primary me-1">Primary</span>
95
+ <span class="badge bg-secondary me-1">Secondary</span>
96
+ <span class="badge bg-success me-1">Success</span>
97
+ <span class="badge bg-danger me-1">Danger</span>
98
+ <span class="badge bg-warning me-1">Warning</span>
99
+ <span class="badge bg-info me-1">Info</span>
100
+ <span class="badge bg-dark me-1">Dark</span>
101
+ </div>
102
+
103
+ <!-- Forms -->
104
+ <div class="component-section">
105
+ <h3>Forms</h3>
106
+ <div class="card">
107
+ <div class="card-body">
108
+ <form>
109
+ <div class="row mb-3">
110
+ <div class="col-md-6">
111
+ <div class="form-group">
112
+ <label class="form-label">Full Name</label>
113
+ <input type="text" class="form-control" placeholder="Andre van Zuydam">
114
+ </div>
115
+ </div>
116
+ <div class="col-md-6">
117
+ <div class="form-group">
118
+ <label class="form-label">Email</label>
119
+ <input type="email" class="form-control" placeholder="you@example.com">
120
+ </div>
121
+ </div>
122
+ </div>
123
+ <div class="row mb-3">
124
+ <div class="col-md-6">
125
+ <div class="form-group">
126
+ <label class="form-label">Framework</label>
127
+ <select class="form-select">
128
+ <option>Python</option>
129
+ <option>PHP</option>
130
+ <option selected>Ruby</option>
131
+ <option>Node.js</option>
132
+ </select>
133
+ </div>
134
+ </div>
135
+ <div class="col-md-6">
136
+ <div class="form-group">
137
+ <label class="form-label">Database</label>
138
+ <select class="form-select">
139
+ <option>SQLite</option>
140
+ <option>PostgreSQL</option>
141
+ <option>MySQL</option>
142
+ <option>Firebird</option>
143
+ <option>MSSQL</option>
144
+ </select>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ <div class="form-group mb-3">
149
+ <label class="form-label">Message</label>
150
+ <textarea class="form-control" rows="3" placeholder="Tell us about your project..."></textarea>
151
+ </div>
152
+ <div class="form-check mb-3">
153
+ <input class="form-check-input" type="checkbox" checked>
154
+ <label class="form-check-label">I agree to the terms</label>
155
+ </div>
156
+ <button type="button" class="btn btn-primary">Submit</button>
157
+ <button type="button" class="btn btn-outline-secondary ms-2">Cancel</button>
158
+ </form>
159
+ </div>
160
+ </div>
161
+ </div>
162
+
163
+ <!-- Table -->
164
+ <div class="component-section">
165
+ <h3>Tables</h3>
166
+ <div class="table-responsive">
167
+ <table class="table table-striped table-hover">
168
+ <thead>
169
+ <tr>
170
+ <th>#</th>
171
+ <th>Framework</th>
172
+ <th>Port</th>
173
+ <th>Language</th>
174
+ <th>Status</th>
175
+ </tr>
176
+ </thead>
177
+ <tbody>
178
+ <tr><td>1</td><td>tina4-python</td><td>7145</td><td>Python 3.12+</td><td><span class="badge bg-success">Stable</span></td></tr>
179
+ <tr><td>2</td><td>tina4-php</td><td>7146</td><td>PHP 8.2+</td><td><span class="badge bg-success">Stable</span></td></tr>
180
+ <tr><td>3</td><td>tina4-ruby</td><td>7147</td><td>Ruby 3.1+</td><td><span class="badge bg-success">Stable</span></td></tr>
181
+ <tr><td>4</td><td>tina4-nodejs</td><td>7148</td><td>Node 20+</td><td><span class="badge bg-success">Stable</span></td></tr>
182
+ </tbody>
183
+ </table>
184
+ </div>
185
+ </div>
186
+
187
+ <!-- Breadcrumbs -->
188
+ <div class="component-section">
189
+ <h3>Breadcrumbs</h3>
190
+ <nav>
191
+ <ol class="breadcrumb">
192
+ <li class="breadcrumb-item"><a href="/">Home</a></li>
193
+ <li class="breadcrumb-item"><a href="#">Gallery</a></li>
194
+ <li class="breadcrumb-item active">Components</li>
195
+ </ol>
196
+ </nav>
197
+ </div>
198
+
199
+ <!-- Input Groups -->
200
+ <div class="component-section">
201
+ <h3>Input Groups</h3>
202
+ <div class="input-group mb-3">
203
+ <span class="input-group-text">@</span>
204
+ <input type="text" class="form-control" placeholder="Username">
205
+ </div>
206
+ <div class="input-group mb-3">
207
+ <input type="text" class="form-control" placeholder="Search routes...">
208
+ <button class="btn btn-primary">Search</button>
209
+ </div>
210
+ <div class="input-group">
211
+ <span class="input-group-text">https://</span>
212
+ <input type="text" class="form-control" placeholder="tina4.com">
213
+ <span class="input-group-text">/api</span>
214
+ </div>
215
+ </div>
216
+
217
+ <!-- Progress -->
218
+ <div class="component-section">
219
+ <h3>Progress Bars</h3>
220
+ <div class="progress mb-2"><div class="progress-bar bg-primary" style="width: 25%">25%</div></div>
221
+ <div class="progress mb-2"><div class="progress-bar bg-success" style="width: 50%">50%</div></div>
222
+ <div class="progress mb-2"><div class="progress-bar bg-warning" style="width: 75%">75%</div></div>
223
+ <div class="progress"><div class="progress-bar bg-danger" style="width: 100%">100%</div></div>
224
+ </div>
225
+
226
+ <!-- List Group -->
227
+ <div class="component-section">
228
+ <h3>List Group</h3>
229
+ <div class="list-group">
230
+ <a href="#" class="list-group-item list-group-item-action active">Routes — 12 registered</a>
231
+ <a href="#" class="list-group-item list-group-item-action">Queue — 3 pending jobs</a>
232
+ <a href="#" class="list-group-item list-group-item-action">Database — SQLite connected</a>
233
+ <a href="#" class="list-group-item list-group-item-action disabled">Cache — Not configured</a>
234
+ </div>
235
+ </div>
236
+
237
+ <!-- How this page was built -->
238
+ <div class="card mt-4 mb-5" style="background:#0f172a;border:1px solid #334155;">
239
+ <div class="card-body">
240
+ <h5 style="color:#e2e8f0;">How this page was built</h5>
241
+ <pre style="background:#1e293b;border:1px solid #334155;border-radius:0.5rem;padding:1.25rem;margin-top:0.75rem;overflow-x:auto;font-family:'SF Mono',SFMono-Regular,Consolas,monospace;font-size:0.9rem;line-height:1.7;"><code><span style="color:#c084fc;">Tina4::Router.get</span> <span style="color:#4ade80;">"/gallery/page"</span>, <span style="color:#38bdf8;">template:</span> <span style="color:#4ade80;">"gallery_page.twig"</span> <span style="color:#c084fc;">do</span> |request, response|
242
+ response.call({
243
+ <span style="color:#fbbf24;">title:</span> <span style="color:#4ade80;">"tina4css Component Showcase"</span>,
244
+ <span style="color:#fbbf24;">items:</span> [...]
245
+ }, Tina4::HTTP_OK)
246
+ <span style="color:#c084fc;">end</span></code></pre>
247
+ <p style="color:#94a3b8;margin-top:0.75rem;margin-bottom:0;">
248
+ Rendered via <code style="color:#c084fc;">template:</code> keyword. Styled with <strong style="color:#e2e8f0;">tina4css</strong> — zero external CDN.
249
+ All components above use only <code style="color:#4ade80;">&lt;link href="/css/tina4.min.css"&gt;</code>.
250
+ </p>
251
+ </div>
252
+ </div>
253
+
254
+ </div>
255
+
256
+ </body>
257
+ </html>
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Tina4
6
+ module Health
7
+ START_TIME = Process.clock_gettime(Process::CLOCK_MONOTONIC)
8
+
9
+ class << self
10
+ def register!
11
+ Tina4::Router.add_route("GET", "/health", method(:handle))
12
+ end
13
+
14
+ def handle(_request, response)
15
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
16
+ uptime = (now - START_TIME).round(2)
17
+
18
+ payload = {
19
+ status: "ok",
20
+ version: Tina4::VERSION,
21
+ uptime: uptime,
22
+ framework: "tina4-ruby"
23
+ }
24
+
25
+ response.json(payload)
26
+ end
27
+
28
+ def status
29
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
30
+ {
31
+ status: "ok",
32
+ version: Tina4::VERSION,
33
+ uptime: (now - START_TIME).round(2),
34
+ framework: "tina4-ruby"
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end