commit3r commited on
Commit
2caf0dc
·
verified ·
1 Parent(s): d01bb87

create a minimal site that uses webrtc (so serverless) to stream live raw text messages, it only works for clients who are online and connected to the site, make it a cool design, no dramatic font and scientific but retro inspirted from mac os 7 - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +331 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Temp
3
- emoji: 🔥
4
- colorFrom: yellow
5
- colorTo: green
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: temp
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: blue
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,331 @@
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>RetroText Stream</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://unpkg.com/peerjs@1.4.7/dist/peerjs.min.js"></script>
9
+ <style>
10
+ @font-face {
11
+ font-family: 'Chicago';
12
+ src: url('https://cdn.jsdelivr.net/gh/eliheuer/chicago@master/chicago.woff2') format('woff2');
13
+ }
14
+
15
+ body {
16
+ background: #C0C7C8 url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23a0a7a8' fill-opacity='0.2' fill-rule='evenodd'%3E%3Cpath d='M5 5h1v1H5V5zM0 0h1v1H0V0zm3 3h1v1H3V3z'/%3E%3C/g%3E%3C/svg%3E");
17
+ font-family: 'Chicago', 'SF Mono', monospace;
18
+ color: #000;
19
+ }
20
+
21
+ .mac-window {
22
+ border: 2px solid;
23
+ border-top-color: #fff;
24
+ border-left-color: #fff;
25
+ border-right-color: #808080;
26
+ border-bottom-color: #808080;
27
+ box-shadow: 2px 2px 0 #000;
28
+ }
29
+
30
+ .title-bar {
31
+ background: linear-gradient(to right, #000080, #1084d0);
32
+ color: white;
33
+ letter-spacing: 0.5px;
34
+ }
35
+
36
+ .btn {
37
+ border: 2px solid;
38
+ border-top-color: #fff;
39
+ border-left-color: #fff;
40
+ border-right-color: #808080;
41
+ border-bottom-color: #808080;
42
+ background: #c0c0c0;
43
+ box-shadow: inset -1px -1px 0 #000;
44
+ }
45
+
46
+ .btn:active {
47
+ border-top-color: #808080;
48
+ border-left-color: #808080;
49
+ border-right-color: #fff;
50
+ border-bottom-color: #fff;
51
+ box-shadow: inset 1px 1px 0 #000;
52
+ }
53
+
54
+ .message-box {
55
+ background: #fff;
56
+ border: 2px solid;
57
+ border-top-color: #808080;
58
+ border-left-color: #808080;
59
+ border-right-color: #fff;
60
+ border-bottom-color: #fff;
61
+ }
62
+
63
+ .status-bar {
64
+ background: #c0c0c0;
65
+ border-top: 2px solid #808080;
66
+ }
67
+
68
+ .scrollbar::-webkit-scrollbar {
69
+ width: 12px;
70
+ }
71
+
72
+ .scrollbar::-webkit-scrollbar-track {
73
+ background: #c0c0c0;
74
+ border-left: 2px solid #808080;
75
+ }
76
+
77
+ .scrollbar::-webkit-scrollbar-thumb {
78
+ background: #808080;
79
+ border: 2px solid #c0c0c0;
80
+ border-top-color: #fff;
81
+ border-left-color: #fff;
82
+ border-right-color: #000;
83
+ border-bottom-color: #000;
84
+ }
85
+
86
+ .terminal-text {
87
+ font-family: 'Chicago', monospace;
88
+ font-size: 14px;
89
+ line-height: 1.4;
90
+ color: #000;
91
+ }
92
+
93
+ .blink {
94
+ animation: blink 1s infinite;
95
+ }
96
+
97
+ @keyframes blink {
98
+ 50% { opacity: 0; }
99
+ }
100
+
101
+ .peer-id {
102
+ background: #fff;
103
+ border: 1px solid #808080;
104
+ padding: 2px 4px;
105
+ font-size: 12px;
106
+ letter-spacing: 0.5px;
107
+ }
108
+
109
+ .input-field {
110
+ background: #fff;
111
+ border: 2px solid;
112
+ border-top-color: #000;
113
+ border-left-color: #000;
114
+ border-right-color: #fff;
115
+ border-bottom-color: #fff;
116
+ font-family: 'Chicago', monospace;
117
+ }
118
+
119
+ .input-field:focus {
120
+ outline: none;
121
+ border: 2px solid #000080;
122
+ }
123
+ </style>
124
+ </head>
125
+ <body class="min-h-screen flex items-center justify-center p-4">
126
+ <div class="mac-window w-full max-w-2xl">
127
+ <!-- Title Bar -->
128
+ <div class="title-bar flex items-center justify-between px-3 py-1">
129
+ <div class="flex items-center">
130
+ <div class="w-3 h-3 rounded-full bg-[#ff6057] mr-2"></div>
131
+ <div class="w-3 h-3 rounded-full bg-[#ffbd2e] mr-2"></div>
132
+ <div class="w-3 h-3 rounded-full bg-[#28c940] mr-2"></div>
133
+ <h1 class="text-sm font-bold">RetroText Stream</h1>
134
+ </div>
135
+ <div class="text-xs">WebRTC Text Broadcast</div>
136
+ </div>
137
+
138
+ <!-- Main Content -->
139
+ <div class="bg-[#c0c0c0] p-4">
140
+ <!-- Connection Info -->
141
+ <div class="mb-4 flex items-center justify-between">
142
+ <div class="flex items-center">
143
+ <span class="mr-2">Status:</span>
144
+ <div id="status" class="bg-[#28c940] px-2 py-1 text-xs font-bold">CONNECTING...</div>
145
+ </div>
146
+ <div class="flex items-center">
147
+ <span class="mr-2">Peer ID:</span>
148
+ <div id="peer-id" class="peer-id">Generating...</div>
149
+ </div>
150
+ </div>
151
+
152
+ <!-- Message Display -->
153
+ <div class="message-box mb-4 h-64 overflow-hidden">
154
+ <div id="message-container" class="terminal-text p-3 h-full overflow-y-auto scrollbar">
155
+ <div>> Initializing WebRTC connection...</div>
156
+ <div>> Using public STUN servers</div>
157
+ <div>> Establishing peer connection...</div>
158
+ <div id="connection-status" class="blink">> Waiting for peers</div>
159
+ </div>
160
+ </div>
161
+
162
+ <!-- Input Area -->
163
+ <div class="flex">
164
+ <input
165
+ type="text"
166
+ id="message-input"
167
+ class="input-field flex-grow px-3 py-2 mr-2"
168
+ placeholder="Type message here..."
169
+ disabled
170
+ >
171
+ <button id="send-btn" class="btn px-4 py-2 font-bold" disabled>Send</button>
172
+ </div>
173
+ </div>
174
+
175
+ <!-- Status Bar -->
176
+ <div class="status-bar px-3 py-1 flex justify-between text-xs">
177
+ <div>Connected Peers: <span id="peer-count">0</span></div>
178
+ <div>RetroText Stream v1.0</div>
179
+ </div>
180
+ </div>
181
+
182
+ <script>
183
+ document.addEventListener('DOMContentLoaded', () => {
184
+ // DOM Elements
185
+ const messageContainer = document.getElementById('message-container');
186
+ const messageInput = document.getElementById('message-input');
187
+ const sendBtn = document.getElementById('send-btn');
188
+ const statusIndicator = document.getElementById('status');
189
+ const peerIdDisplay = document.getElementById('peer-id');
190
+ const connectionStatus = document.getElementById('connection-status');
191
+ const peerCountDisplay = document.getElementById('peer-count');
192
+
193
+ // State
194
+ let peer = null;
195
+ let connections = [];
196
+ let peerId = null;
197
+
198
+ // Initialize PeerJS
199
+ function initializePeer() {
200
+ // Generate a random peer ID
201
+ peerId = 'retro-' + Math.random().toString(36).substr(2, 8).toUpperCase();
202
+ peerIdDisplay.textContent = peerId;
203
+
204
+ // Create peer
205
+ peer = new Peer(peerId, {
206
+ host: '0.peerjs.com',
207
+ port: 443,
208
+ secure: true,
209
+ config: {
210
+ iceServers: [
211
+ { urls: 'stun:stun.l.google.com:19302' },
212
+ { urls: 'stun:stun1.l.google.com:19302' }
213
+ ]
214
+ }
215
+ });
216
+
217
+ // Peer event handlers
218
+ peer.on('open', (id) => {
219
+ statusIndicator.textContent = 'CONNECTED';
220
+ statusIndicator.className = 'bg-[#28c940] px-2 py-1 text-xs font-bold';
221
+ connectionStatus.innerHTML = `> Ready to connect! Share ID: <span class="font-bold">${id}</span>`;
222
+ messageInput.disabled = false;
223
+ sendBtn.disabled = false;
224
+ });
225
+
226
+ peer.on('connection', (conn) => {
227
+ setupConnection(conn);
228
+ updatePeerCount();
229
+ });
230
+
231
+ peer.on('error', (err) => {
232
+ console.error('Peer error:', err);
233
+ appendMessage(`> ERROR: ${err.type} - ${err.message}`);
234
+ statusIndicator.textContent = 'ERROR';
235
+ statusIndicator.className = 'bg-[#ff6057] px-2 py-1 text-xs font-bold';
236
+ });
237
+
238
+ peer.on('disconnected', () => {
239
+ statusIndicator.textContent = 'DISCONNECTED';
240
+ statusIndicator.className = 'bg-[#ffbd2e] px-2 py-1 text-xs font-bold';
241
+ appendMessage('> Disconnected from signaling server');
242
+ });
243
+ }
244
+
245
+ // Set up a connection
246
+ function setupConnection(conn) {
247
+ connections.push(conn);
248
+ updatePeerCount();
249
+
250
+ conn.on('open', () => {
251
+ appendMessage(`> Connected to peer: ${conn.peer.substr(0, 8)}`);
252
+ });
253
+
254
+ conn.on('data', (data) => {
255
+ appendMessage(`${conn.peer.substr(0, 8)}> ${data}`);
256
+ });
257
+
258
+ conn.on('close', () => {
259
+ connections = connections.filter(c => c.peer !== conn.peer);
260
+ appendMessage(`> Disconnected from peer: ${conn.peer.substr(0, 8)}`);
261
+ updatePeerCount();
262
+ });
263
+
264
+ conn.on('error', (err) => {
265
+ console.error('Connection error:', err);
266
+ appendMessage(`> ERROR with peer ${conn.peer.substr(0, 8)}: ${err.message}`);
267
+ });
268
+ }
269
+
270
+ // Connect to another peer
271
+ function connectToPeer(peerId) {
272
+ if (!peer) return;
273
+
274
+ const conn = peer.connect(peerId);
275
+ setupConnection(conn);
276
+ }
277
+
278
+ // Send message to all connected peers
279
+ function broadcastMessage(message) {
280
+ if (message.trim() === '') return;
281
+
282
+ connections.forEach(conn => {
283
+ if (conn.open) {
284
+ conn.send(message);
285
+ }
286
+ });
287
+
288
+ appendMessage(`YOU> ${message}`);
289
+ messageInput.value = '';
290
+ }
291
+
292
+ // Append message to display
293
+ function appendMessage(message) {
294
+ const messageElement = document.createElement('div');
295
+ messageElement.textContent = message;
296
+ messageContainer.appendChild(messageElement);
297
+ messageContainer.scrollTop = messageContainer.scrollHeight;
298
+ }
299
+
300
+ // Update peer count display
301
+ function updatePeerCount() {
302
+ peerCountDisplay.textContent = connections.length;
303
+ }
304
+
305
+ // Event listeners
306
+ sendBtn.addEventListener('click', () => {
307
+ broadcastMessage(messageInput.value);
308
+ });
309
+
310
+ messageInput.addEventListener('keypress', (e) => {
311
+ if (e.key === 'Enter') {
312
+ broadcastMessage(messageInput.value);
313
+ }
314
+ });
315
+
316
+ // Initialize
317
+ initializePeer();
318
+
319
+ // Handle URL parameters for connecting to a peer
320
+ const urlParams = new URLSearchParams(window.location.search);
321
+ const connectTo = urlParams.get('connect');
322
+ if (connectTo) {
323
+ setTimeout(() => {
324
+ connectToPeer(connectTo);
325
+ appendMessage(`> Attempting connection to ${connectTo.substr(0, 8)}...`);
326
+ }, 2000);
327
+ }
328
+ });
329
+ </script>
330
+ <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=commit3r/temp" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
331
+ </html>