lamelight07 commited on
Commit
701bce4
·
verified ·
1 Parent(s): bda76ed

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +259 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Getting Wiser
3
- emoji: 🚀
4
- colorFrom: green
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: getting-wiser
3
+ emoji: 🐳
4
+ colorFrom: purple
5
+ colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,259 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0">
6
+ <title>Today I Learned</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .gradient-bg {
11
+ background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
12
+ }
13
+ .post-card {
14
+ transition: transform 0.2s, box-shadow 0.2s;
15
+ }
16
+ .post-card:hover {
17
+ transform: translateY(-2px);
18
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
19
+ }
20
+ .like-btn.liked {
21
+ color: #ff0000;
22
+ }
23
+ .fade-in {
24
+ animation: fadeIn 0.3s ease-in;
25
+ }
26
+ @keyframes fadeIn {
27
+ from { opacity: 0; transform: translateY(10px); }
28
+ to { opacity: 1; transform: translateY(0); }
29
+ }
30
+ .heart-animation {
31
+ animation: heartBeat 0.5s;
32
+ }
33
+ @keyframes heartBeat {
34
+ 0% { transform: scale(1); }
35
+ 25% { transform: scale(1.2); }
36
+ 50% { transform: scale(0.8); }
37
+ 75% { transform: scale(1.1); }
38
+ 100% { transform: scale(1); }
39
+ }
40
+ </style>
41
+ </head>
42
+ <body class="bg-gray-100 min-h-screen">
43
+ <header class="gradient-bg text-white shadow-lg">
44
+ <div class="container mx-auto px-4 py-6">
45
+ <div class="flex justify-between items-center">
46
+ <h1 class="text-3xl font-bold">Today I Learned</h1>
47
+ <div class="text-sm">
48
+ <span id="post-count">0</span> posts shared
49
+ </div>
50
+ </div>
51
+ <p class="mt-2 opacity-90">Share what you've learned today with the community!</p>
52
+ </div>
53
+ </header>
54
+
55
+ <main class="container mx-auto px-4 py-8">
56
+ <div class="max-w-2xl mx-auto">
57
+ <!-- Post Form -->
58
+ <div class="bg-white rounded-lg shadow-md p-6 mb-8">
59
+ <h2 class="text-xl font-semibold mb-4 text-gray-800">What did you learn today?</h2>
60
+ <form id="post-form" class="space-y-4">
61
+ <div>
62
+ <input type="text" id="user-name" class="w-full px-4 py-2 mb-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Your name (optional)">
63
+ <textarea id="post-content" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Share your knowledge..." required></textarea>
64
+ </div>
65
+ <div class="flex justify-between items-center">
66
+ <div class="text-sm text-gray-500">
67
+ <i class="fas fa-info-circle mr-1"></i> Only text posts allowed
68
+ </div>
69
+ <button type="submit" class="px-6 py-2 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition">
70
+ Post
71
+ </button>
72
+ </div>
73
+ </form>
74
+ </div>
75
+
76
+ <!-- Posts Wall -->
77
+ <div id="posts-wall" class="space-y-6">
78
+ <!-- Posts will be inserted here by JavaScript -->
79
+ </div>
80
+
81
+ <!-- No Posts Message -->
82
+ <div id="no-posts" class="text-center py-12">
83
+ <div class="text-gray-400 mb-4">
84
+ <i class="fas fa-comment-slash text-5xl"></i>
85
+ </div>
86
+ <h3 class="text-xl font-medium text-gray-600">No posts yet</h3>
87
+ <p class="text-gray-500 mt-2">Be the first to share what you've learned today!</p>
88
+ </div>
89
+ </div>
90
+ </main>
91
+
92
+ <footer class="bg-gray-800 text-white py-6">
93
+ <div class="container mx-auto px-4 text-center">
94
+ <p>© 2023 Today I Learned. All posts are automatically deleted after 50 newest ones.</p>
95
+ </div>
96
+ </footer>
97
+
98
+ <script>
99
+ document.addEventListener('DOMContentLoaded', function() {
100
+ // Initialize posts array from localStorage or create empty array
101
+ let posts = JSON.parse(localStorage.getItem('posts')) || [];
102
+ const postsWall = document.getElementById('posts-wall');
103
+ const noPosts = document.getElementById('no-posts');
104
+ const postForm = document.getElementById('post-form');
105
+ const postContent = document.getElementById('post-content');
106
+ const userName = document.getElementById('user-name');
107
+ const postCount = document.getElementById('post-count');
108
+
109
+ // Update post count
110
+ postCount.textContent = posts.length;
111
+
112
+ // Display posts
113
+ function displayPosts() {
114
+ postsWall.innerHTML = '';
115
+
116
+ if (posts.length === 0) {
117
+ noPosts.style.display = 'block';
118
+ return;
119
+ } else {
120
+ noPosts.style.display = 'none';
121
+ }
122
+
123
+ // Show only the 50 most recent posts
124
+ const recentPosts = posts.slice(0, 50);
125
+
126
+ recentPosts.forEach((post, index) => {
127
+ const postElement = document.createElement('div');
128
+ postElement.className = 'post-card bg-white rounded-lg shadow-md p-6 fade-in';
129
+ postElement.innerHTML = `
130
+ <div class="flex items-start mb-4">
131
+ <div class="flex-shrink-0 h-10 w-10 rounded-full bg-gray-200 flex items-center justify-center text-gray-500">
132
+ <i class="fas fa-user"></i>
133
+ </div>
134
+ <div class="ml-3">
135
+ <p class="text-sm font-medium text-gray-900">${post.name ? escapeHtml(post.name) : 'Anonymous Learner'}</p>
136
+ <p class="text-xs text-gray-500">${formatDate(post.timestamp)}</p>
137
+ </div>
138
+ </div>
139
+ <div class="mb-4 text-gray-700">
140
+ ${escapeHtml(post.content)}
141
+ </div>
142
+ <div class="flex items-center">
143
+ <button class="like-btn flex items-center text-gray-500 hover:text-red-500 focus:outline-none ${post.liked ? 'liked' : ''}" data-index="${index}">
144
+ <i class="fas fa-heart ${post.liked ? 'heart-animation' : ''} mr-1"></i>
145
+ <span>${post.likes}</span>
146
+ </button>
147
+ </div>
148
+ `;
149
+ postsWall.appendChild(postElement);
150
+ });
151
+ }
152
+
153
+ // Format date to relative time (e.g., "2 hours ago")
154
+ function formatDate(timestamp) {
155
+ const now = new Date();
156
+ const postDate = new Date(timestamp);
157
+ const seconds = Math.floor((now - postDate) / 1000);
158
+
159
+ let interval = Math.floor(seconds / 31536000);
160
+ if (interval >= 1) return `${interval} year${interval === 1 ? '' : 's'} ago`;
161
+
162
+ interval = Math.floor(seconds / 2592000);
163
+ if (interval >= 1) return `${interval} month${interval === 1 ? '' : 's'} ago`;
164
+
165
+ interval = Math.floor(seconds / 86400);
166
+ if (interval >= 1) return `${interval} day${interval === 1 ? '' : 's'} ago`;
167
+
168
+ interval = Math.floor(seconds / 3600);
169
+ if (interval >= 1) return `${interval} hour${interval === 1 ? '' : 's'} ago`;
170
+
171
+ interval = Math.floor(seconds / 60);
172
+ if (interval >= 1) return `${interval} minute${interval === 1 ? '' : 's'} ago`;
173
+
174
+ return `${Math.floor(seconds)} second${seconds === 1 ? '' : 's'} ago`;
175
+ }
176
+
177
+ // Escape HTML to prevent XSS
178
+ function escapeHtml(unsafe) {
179
+ return unsafe
180
+ .replace(/&/g, "&amp;")
181
+ .replace(/</g, "&lt;")
182
+ .replace(/>/g, "&gt;")
183
+ .replace(/"/g, "&quot;")
184
+ .replace(/'/g, "&#039;")
185
+ .replace(/\n/g, "<br>");
186
+ }
187
+
188
+ // Handle form submission
189
+ postForm.addEventListener('submit', function(e) {
190
+ e.preventDefault();
191
+
192
+ const content = postContent.value.trim();
193
+ if (!content) return;
194
+
195
+ // Create new post
196
+ const newPost = {
197
+ name: userName.value.trim(),
198
+ content: content,
199
+ timestamp: new Date().toISOString(),
200
+ likes: 0,
201
+ liked: false
202
+ };
203
+
204
+ // Add to beginning of array (most recent first)
205
+ posts.unshift(newPost);
206
+
207
+ // Keep only the 50 most recent posts
208
+ if (posts.length > 50) {
209
+ posts = posts.slice(0, 50);
210
+ }
211
+
212
+ // Save to localStorage
213
+ localStorage.setItem('posts', JSON.stringify(posts));
214
+
215
+ // Update UI
216
+ postCount.textContent = posts.length;
217
+ displayPosts();
218
+
219
+ // Reset form
220
+ postContent.value = '';
221
+ userName.value = '';
222
+ });
223
+
224
+ // Handle like button clicks
225
+ postsWall.addEventListener('click', function(e) {
226
+ if (e.target.closest('.like-btn')) {
227
+ const likeBtn = e.target.closest('.like-btn');
228
+ const postIndex = parseInt(likeBtn.dataset.index);
229
+ const heartIcon = likeBtn.querySelector('i.fa-heart');
230
+
231
+ // Toggle like status
232
+ if (posts[postIndex].liked) {
233
+ posts[postIndex].likes--;
234
+ posts[postIndex].liked = false;
235
+ heartIcon.classList.remove('heart-animation');
236
+ } else {
237
+ posts[postIndex].likes++;
238
+ posts[postIndex].liked = true;
239
+ heartIcon.classList.add('heart-animation');
240
+ // Remove animation class after animation completes
241
+ setTimeout(() => {
242
+ heartIcon.classList.remove('heart-animation');
243
+ }, 500);
244
+ }
245
+
246
+ // Save to localStorage
247
+ localStorage.setItem('posts', JSON.stringify(posts));
248
+
249
+ // Update UI
250
+ displayPosts();
251
+ }
252
+ });
253
+
254
+ // Initial display
255
+ displayPosts();
256
+ });
257
+ </script>
258
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=lamelight07/getting-wiser" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
259
+ </html>