create-isotope-app 1.2.3 → 1.2.5
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.
package/package.json
CHANGED
|
@@ -126,7 +126,18 @@ class Kernel {
|
|
|
126
126
|
$replacement = "";
|
|
127
127
|
if (isset($data[$listKey]) && is_array($data[$listKey])) {
|
|
128
128
|
foreach ($data[$listKey] as $item) {
|
|
129
|
-
$
|
|
129
|
+
$rowHtml = $itemTpl;
|
|
130
|
+
if (is_array($item) || is_object($item)) {
|
|
131
|
+
$itemArray = (array)$item;
|
|
132
|
+
foreach ($itemArray as $k => $v) {
|
|
133
|
+
if (is_scalar($v)) {
|
|
134
|
+
$rowHtml = preg_replace('/\\\\{\\\\s*' . preg_quote($itemVar, '/') . '\\\\.' . preg_quote($k, '/') . '\\\\s*\\\\}/i', (string)$v, $rowHtml);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
$rowHtml = preg_replace('/\\\\{\\\\s*' . preg_quote($itemVar, '/') . '\\\\s*\\\\}/i', (string)$item, $rowHtml);
|
|
139
|
+
}
|
|
140
|
+
$replacement .= $rowHtml;
|
|
130
141
|
}
|
|
131
142
|
}
|
|
132
143
|
return $replacement;
|
|
@@ -6,7 +6,7 @@ export const nucleus = proton\`
|
|
|
6
6
|
// DATABASE CRUD EXAMPLE
|
|
7
7
|
try {
|
|
8
8
|
// In a real setup, you would have a 'posts' table
|
|
9
|
-
// $posts =
|
|
9
|
+
// $posts = \\Isotope\\Database::query("SELECT * FROM posts ORDER BY created_at DESC")->fetchAll();
|
|
10
10
|
|
|
11
11
|
// Mock data for demonstration if DB is not connected
|
|
12
12
|
$posts = [
|
|
@@ -18,7 +18,7 @@ try {
|
|
|
18
18
|
$action = $_POST['action'] ?? '';
|
|
19
19
|
if ($action === 'create') {
|
|
20
20
|
$title = $_POST['title'] ?? 'New Post';
|
|
21
|
-
//
|
|
21
|
+
// \\Isotope\\Database::query("INSERT INTO posts (title) VALUES (?)", [$title]);
|
|
22
22
|
header("Location: /posts");
|
|
23
23
|
exit;
|
|
24
24
|
}
|
|
@@ -28,14 +28,27 @@ try {
|
|
|
28
28
|
'posts' => $posts,
|
|
29
29
|
'db_config' => $_ENV['DB_NAME'] ?? 'Not Configured'
|
|
30
30
|
];
|
|
31
|
-
} catch (
|
|
31
|
+
} catch (\\Exception $e) {
|
|
32
32
|
return ['error' => $e->getMessage(), 'posts' => []];
|
|
33
33
|
}
|
|
34
34
|
\`;
|
|
35
35
|
|
|
36
36
|
"use client";
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
interface Post {
|
|
39
|
+
id: number;
|
|
40
|
+
title: string;
|
|
41
|
+
content: string;
|
|
42
|
+
created_at?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface PostsPageProps {
|
|
46
|
+
posts: Post[];
|
|
47
|
+
db_config?: string;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function PostsPage({ posts, db_config }: PostsPageProps) {
|
|
39
52
|
return (
|
|
40
53
|
<div className="p-8 max-w-4xl mx-auto text-white">
|
|
41
54
|
<h1 className="text-4xl font-bold mb-8 text-[#00d4ff]">Blog Posts (CRUD Demo)</h1>
|
|
@@ -87,7 +100,18 @@ return [
|
|
|
87
100
|
|
|
88
101
|
"use client";
|
|
89
102
|
|
|
90
|
-
|
|
103
|
+
interface Post {
|
|
104
|
+
id: number;
|
|
105
|
+
title: string;
|
|
106
|
+
content: string;
|
|
107
|
+
created_at?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface PostsPageProps {
|
|
111
|
+
posts: Post[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default function PostsPage({ posts }: PostsPageProps) {
|
|
91
115
|
return (
|
|
92
116
|
<div style={{ padding: '2rem', color: 'white' }}>
|
|
93
117
|
<h1>CRUD Demo</h1>
|