This repository was archived by the owner on May 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts.html
More file actions
142 lines (112 loc) · 2.52 KB
/
Copy pathposts.html
File metadata and controls
142 lines (112 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<title>Posts</title>
<style>
body {
font-family: Arial, sans-serif;
background: #eef1f5;
padding: 20px;
margin: 0;
}
.topbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25px;
}
.topbar h2 {
color: #222;
}
.topbar a {
text-decoration: none;
color: #444;
margin-left: 10px;
font-weight: bold;
}
#postsContainer {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
.post {
background: #ffffff;
border: 1px solid #d1d5db;
border-radius: 16px;
padding: 20px;
width: 100%;
max-width: calc(33.333% - 1rem);
box-shadow:
0 4px 6px rgba(0,0,0,0.05),
0 10px 20px rgba(0,0,0,0.08);
transition: all 0.25s ease;
}
.post:hover {
transform: translateY(-5px);
box-shadow:
0 8px 12px rgba(0,0,0,0.08),
0 18px 28px rgba(0,0,0,0.12);
border-color: #9ca3af;
}
.username {
font-weight: bold;
font-size: 18px;
margin-bottom: 12px;
color: #111827;
}
.post p {
color: #4b5563;
line-height: 1.6;
word-wrap: break-word;
}
@media (max-width: 900px) {
.post {
max-width: calc(50% - 1rem);
}
}
@media (max-width: 600px) {
.post {
max-width: 100%;
}
}
</style>
</head>
<body>
<div class="topbar">
<h2>All Posts</h2>
<div>
<a href="/create-post">Create Post</a> |
<a href="/login">Login</a>
</div>
</div>
<div id="postsContainer">Loading posts...</div>
<script>
async function loadPosts() {
try {
const res = await fetch("/posts-lists");
const data = await res.json();
const container = document.getElementById("postsContainer");
container.innerHTML = "";
if (data.length === 0) {
container.innerHTML = "<p>No posts yet</p>";
return;
}
data.forEach(post => {
const div = document.createElement("div");
div.className = "post";
div.innerHTML = `
<div class="username">${post.username}</div>
<p>${post.content}</p>
`;
container.appendChild(div);
});
} catch (err) {
alert(err)
document.getElementById("postsContainer").innerHTML =
"<p>Error loading posts</p>";
}
}
loadPosts();
</script>
</body>
</html>