Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +175 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
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: simple-galery
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: pink
|
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,175 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Simple Image Gallery</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<style>
|
9 |
+
.gallery-item {
|
10 |
+
transition: all 0.3s ease;
|
11 |
+
}
|
12 |
+
.gallery-item:hover {
|
13 |
+
transform: scale(1.02);
|
14 |
+
}
|
15 |
+
#drop-area {
|
16 |
+
border: 2px dashed #ccc;
|
17 |
+
transition: all 0.3s;
|
18 |
+
}
|
19 |
+
#drop-area.highlight {
|
20 |
+
border-color: #6b46c1;
|
21 |
+
background-color: #f5f3ff;
|
22 |
+
}
|
23 |
+
</style>
|
24 |
+
</head>
|
25 |
+
<body class="bg-gray-100 min-h-screen">
|
26 |
+
<div class="container mx-auto px-4 py-8">
|
27 |
+
<h1 class="text-3xl font-bold text-center mb-8 text-purple-700">Simple Image Gallery</h1>
|
28 |
+
|
29 |
+
<!-- Upload Section -->
|
30 |
+
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
|
31 |
+
<h2 class="text-xl font-semibold mb-4">Upload Images</h2>
|
32 |
+
|
33 |
+
<div id="drop-area" class="rounded-lg p-8 text-center mb-4">
|
34 |
+
<p class="mb-4">Drag & drop images here or</p>
|
35 |
+
<input type="file" id="fileElem" multiple accept="image/*" class="hidden">
|
36 |
+
<button id="browseBtn" class="bg-purple-600 text-white px-4 py-2 rounded hover:bg-purple-700">
|
37 |
+
Browse Files
|
38 |
+
</button>
|
39 |
+
</div>
|
40 |
+
|
41 |
+
<div class="progress-container hidden">
|
42 |
+
<div class="w-full bg-gray-200 rounded-full h-2.5">
|
43 |
+
<div id="progress-bar" class="bg-purple-600 h-2.5 rounded-full" style="width: 0%"></div>
|
44 |
+
</div>
|
45 |
+
<p id="progress-text" class="text-sm text-gray-600 mt-1">Uploading: 0%</p>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
+
|
49 |
+
<!-- Gallery Grid -->
|
50 |
+
<div id="gallery-grid" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
|
51 |
+
<!-- Sample images (would be loaded from storage in real implementation) -->
|
52 |
+
<div class="gallery-item bg-white rounded-lg overflow-hidden shadow">
|
53 |
+
<img src="https://source.unsplash.com/random/300x300/?nature" alt="Gallery image" class="w-full h-48 object-cover">
|
54 |
+
<div class="p-3">
|
55 |
+
<p class="text-sm text-gray-600">Uploaded: Just now</p>
|
56 |
+
</div>
|
57 |
+
</div>
|
58 |
+
<div class="gallery-item bg-white rounded-lg overflow-hidden shadow">
|
59 |
+
<img src="https://source.unsplash.com/random/300x300/?city" alt="Gallery image" class="w-full h-48 object-cover">
|
60 |
+
<div class="p-3">
|
61 |
+
<p class="text-sm text-gray-600">Uploaded: Just now</p>
|
62 |
+
</div>
|
63 |
+
</div>
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<script>
|
68 |
+
// DOM elements
|
69 |
+
const dropArea = document.getElementById('drop-area');
|
70 |
+
const fileElem = document.getElementById('fileElem');
|
71 |
+
const browseBtn = document.getElementById('browseBtn');
|
72 |
+
const galleryGrid = document.getElementById('gallery-grid');
|
73 |
+
const progressContainer = document.querySelector('.progress-container');
|
74 |
+
const progressBar = document.getElementById('progress-bar');
|
75 |
+
const progressText = document.getElementById('progress-text');
|
76 |
+
|
77 |
+
// Prevent default drag behaviors
|
78 |
+
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
79 |
+
dropArea.addEventListener(eventName, preventDefaults, false);
|
80 |
+
});
|
81 |
+
|
82 |
+
function preventDefaults(e) {
|
83 |
+
e.preventDefault();
|
84 |
+
e.stopPropagation();
|
85 |
+
}
|
86 |
+
|
87 |
+
// Highlight drop area when item is dragged over it
|
88 |
+
['dragenter', 'dragover'].forEach(eventName => {
|
89 |
+
dropArea.addEventListener(eventName, highlight, false);
|
90 |
+
});
|
91 |
+
|
92 |
+
['dragleave', 'drop'].forEach(eventName => {
|
93 |
+
dropArea.addEventListener(eventName, unhighlight, false);
|
94 |
+
});
|
95 |
+
|
96 |
+
function highlight() {
|
97 |
+
dropArea.classList.add('highlight');
|
98 |
+
}
|
99 |
+
|
100 |
+
function unhighlight() {
|
101 |
+
dropArea.classList.remove('highlight');
|
102 |
+
}
|
103 |
+
|
104 |
+
// Handle dropped files
|
105 |
+
dropArea.addEventListener('drop', handleDrop, false);
|
106 |
+
|
107 |
+
function handleDrop(e) {
|
108 |
+
const dt = e.dataTransfer;
|
109 |
+
const files = dt.files;
|
110 |
+
handleFiles(files);
|
111 |
+
}
|
112 |
+
|
113 |
+
// Browse button click
|
114 |
+
browseBtn.addEventListener('click', () => {
|
115 |
+
fileElem.click();
|
116 |
+
});
|
117 |
+
|
118 |
+
// Handle selected files
|
119 |
+
fileElem.addEventListener('change', function() {
|
120 |
+
handleFiles(this.files);
|
121 |
+
});
|
122 |
+
|
123 |
+
// Process files
|
124 |
+
function handleFiles(files) {
|
125 |
+
if (files.length === 0) return;
|
126 |
+
|
127 |
+
progressContainer.classList.remove('hidden');
|
128 |
+
|
129 |
+
// Simulate upload progress (in a real app, this would be an actual upload)
|
130 |
+
let progress = 0;
|
131 |
+
const interval = setInterval(() => {
|
132 |
+
progress += 5;
|
133 |
+
progressBar.style.width = `${progress}%`;
|
134 |
+
progressText.textContent = `Uploading: ${progress}%`;
|
135 |
+
|
136 |
+
if (progress >= 100) {
|
137 |
+
clearInterval(interval);
|
138 |
+
setTimeout(() => {
|
139 |
+
progressContainer.classList.add('hidden');
|
140 |
+
progressBar.style.width = '0%';
|
141 |
+
progressText.textContent = 'Uploading: 0%';
|
142 |
+
|
143 |
+
// Add uploaded images to gallery
|
144 |
+
for (let i = 0; i < files.length; i++) {
|
145 |
+
const file = files[i];
|
146 |
+
if (!file.type.match('image.*')) continue;
|
147 |
+
|
148 |
+
const reader = new FileReader();
|
149 |
+
reader.onload = (function(theFile) {
|
150 |
+
return function(e) {
|
151 |
+
const galleryItem = document.createElement('div');
|
152 |
+
galleryItem.className = 'gallery-item bg-white rounded-lg overflow-hidden shadow';
|
153 |
+
galleryItem.innerHTML = `
|
154 |
+
<img src="${e.target.result}" alt="Gallery image" class="w-full h-48 object-cover">
|
155 |
+
<div class="p-3">
|
156 |
+
<p class="text-sm text-gray-600">Uploaded: Just now</p>
|
157 |
+
</div>
|
158 |
+
`;
|
159 |
+
galleryGrid.insertBefore(galleryItem, galleryGrid.firstChild);
|
160 |
+
};
|
161 |
+
})(file);
|
162 |
+
reader.readAsDataURL(file);
|
163 |
+
}
|
164 |
+
}, 500);
|
165 |
+
}
|
166 |
+
}, 100);
|
167 |
+
}
|
168 |
+
|
169 |
+
// In a real implementation, you would need server-side code to:
|
170 |
+
// 1. Actually save the uploaded files to storage
|
171 |
+
// 2. Retrieve the list of images to display in the gallery
|
172 |
+
// 3. Handle potential security concerns with anonymous uploads
|
173 |
+
</script>
|
174 |
+
<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=vorstcavry/simple-galery" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
175 |
+
</html>
|