Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -118,7 +118,7 @@ def search_spaces(search_text, category):
|
|
118 |
if search_text:
|
119 |
spaces_df = spaces_df[spaces_df['title'].str.lower().str.contains(search_text.lower())]
|
120 |
|
121 |
-
spaces = spaces_df.nlargest(
|
122 |
|
123 |
# Get category stats
|
124 |
total_spaces = len(spaces_df)
|
@@ -126,31 +126,52 @@ def search_spaces(search_text, category):
|
|
126 |
|
127 |
# Format the results as HTML with clickable links and stats
|
128 |
html_content = f"""
|
129 |
-
<div style='margin-bottom: 20px; padding: 10px; background-color: var(--color-background-primary);
|
|
|
130 |
<h3 style='color: var(--color-text-primary);'>Statistics:</h3>
|
131 |
<p style='color: var(--color-text-primary);'>Total Spaces: {total_spaces}</p>
|
132 |
<p style='color: var(--color-text-primary);'>Total Likes: {total_likes:,}</p>
|
133 |
</div>
|
134 |
-
<div style='max-height:
|
|
|
135 |
"""
|
136 |
|
137 |
for _, row in spaces.iterrows():
|
138 |
html_content += f"""
|
139 |
-
<div style='
|
140 |
-
border
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
<p style='color: var(--color-text-primary); margin: 8px 0;'>
|
145 |
<span style='background-color: var(--color-accent-soft);
|
146 |
-
padding: 2px 8px;
|
|
|
|
|
147 |
{row['category']}
|
148 |
</span>
|
149 |
</p>
|
150 |
-
<p style='color: var(--color-text-primary);
|
|
|
|
|
|
|
|
|
151 |
</div>
|
152 |
"""
|
153 |
-
|
|
|
154 |
return html_content
|
155 |
|
156 |
# Create the Gradio interface
|
|
|
118 |
if search_text:
|
119 |
spaces_df = spaces_df[spaces_df['title'].str.lower().str.contains(search_text.lower())]
|
120 |
|
121 |
+
spaces = spaces_df.nlargest(30, 'likes')[['title', 'likes', 'url', 'category']]
|
122 |
|
123 |
# Get category stats
|
124 |
total_spaces = len(spaces_df)
|
|
|
126 |
|
127 |
# Format the results as HTML with clickable links and stats
|
128 |
html_content = f"""
|
129 |
+
<div style='margin-bottom: 20px; padding: 10px; background-color: var(--color-background-primary);
|
130 |
+
border: 1px solid var(--color-border-primary); border-radius: 5px;'>
|
131 |
<h3 style='color: var(--color-text-primary);'>Statistics:</h3>
|
132 |
<p style='color: var(--color-text-primary);'>Total Spaces: {total_spaces}</p>
|
133 |
<p style='color: var(--color-text-primary);'>Total Likes: {total_likes:,}</p>
|
134 |
</div>
|
135 |
+
<div style='max-height: 800px; overflow-y: auto;'>
|
136 |
+
<div style='display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 10px;'>
|
137 |
"""
|
138 |
|
139 |
for _, row in spaces.iterrows():
|
140 |
html_content += f"""
|
141 |
+
<div style='padding: 15px;
|
142 |
+
border: 1px solid var(--color-border-primary);
|
143 |
+
border-radius: 5px;
|
144 |
+
background-color: var(--color-background-primary);
|
145 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
146 |
+
display: flex;
|
147 |
+
flex-direction: column;
|
148 |
+
height: 100%;'>
|
149 |
+
<h3 style='margin-top: 0; margin-bottom: 10px;'>
|
150 |
+
<a href='{row['url']}' target='_blank'
|
151 |
+
style='color: #2196F3;
|
152 |
+
text-decoration: none;
|
153 |
+
font-weight: bold;'>{row['title']}</a>
|
154 |
+
</h3>
|
155 |
+
<div style='height: 1px;
|
156 |
+
background: linear-gradient(to right, transparent, var(--color-border-primary), transparent);
|
157 |
+
margin: 10px 0;'></div>
|
158 |
<p style='color: var(--color-text-primary); margin: 8px 0;'>
|
159 |
<span style='background-color: var(--color-accent-soft);
|
160 |
+
padding: 2px 8px;
|
161 |
+
border-radius: 12px;
|
162 |
+
font-size: 0.9em;'>
|
163 |
{row['category']}
|
164 |
</span>
|
165 |
</p>
|
166 |
+
<p style='color: var(--color-text-primary);
|
167 |
+
margin-top: auto;
|
168 |
+
padding-top: 10px;'>
|
169 |
+
❤️ {row['likes']:,} likes
|
170 |
+
</p>
|
171 |
</div>
|
172 |
"""
|
173 |
+
|
174 |
+
html_content += "</div></div>"
|
175 |
return html_content
|
176 |
|
177 |
# Create the Gradio interface
|