Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -73,16 +73,19 @@ def page(lst, pg):
|
|
73 |
# โโโโโโโโโโโโโโโโโโโโโ 5. URL ์ฒ๋ฆฌ ํจ์ โโโโโโโโโโโโโโโโโโโโโ
|
74 |
def process_url_for_iframe(url):
|
75 |
"""URL์ iframe์ ํ์ํ๊ธฐ ์ ํฉํ ํํ๋ก ๋ณํํฉ๋๋ค."""
|
76 |
-
# ํ๊น
ํ์ด์ค URL
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
81 |
url = url.rstrip("/")
|
82 |
-
# /embed ์ถ๊ฐ
|
83 |
url = f"{url}/embed"
|
84 |
|
85 |
-
return url
|
86 |
|
87 |
# โโโโโโโโโโโโโโโโโโโโโ 6. HTML ๊ทธ๋ฆฌ๋ โโโโโโโโโโโโโโโโโโโ
|
88 |
def html(cards, pg, total):
|
@@ -159,12 +162,14 @@ def html(cards, pg, total):
|
|
159 |
transform: scale(0.7);
|
160 |
transform-origin: top left;
|
161 |
border: 0;
|
|
|
162 |
}
|
163 |
/* ํ๊น
ํ์ด์ค iframe ํน๋ณ ์คํ์ผ */
|
164 |
.frame.huggingface iframe {
|
165 |
-
width: 100
|
166 |
-
height: 100
|
167 |
-
transform: none;
|
|
|
168 |
}
|
169 |
.foot {
|
170 |
padding: 6px 12px;
|
@@ -239,17 +244,26 @@ def html(cards, pg, total):
|
|
239 |
|
240 |
# URL ์ฒ๋ฆฌ: ํ๊น
ํ์ด์ค URL์ธ ๊ฒฝ์ฐ ํน๋ณ ์ฒ๋ฆฌ
|
241 |
url = c['url']
|
242 |
-
iframe_url = process_url_for_iframe(url)
|
243 |
|
244 |
# ํ๊น
ํ์ด์ค URL์ ํน๋ณ ํด๋์ค ์ถ๊ฐ
|
245 |
-
frame_class = "frame huggingface" if
|
246 |
|
247 |
h += f"""
|
248 |
<div class="card">
|
249 |
<div class="hdr"><p class="ttl">{c['title']}</p><p class="date">{date}</p></div>
|
250 |
-
<div class="{frame_class}"
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
<div class="foot"><a class="link" href="{url}" target="_blank">์๋ณธโ</a></div>
|
254 |
</div>"""
|
255 |
|
|
|
73 |
# โโโโโโโโโโโโโโโโโโโโโ 5. URL ์ฒ๋ฆฌ ํจ์ โโโโโโโโโโโโโโโโโโโโโ
|
74 |
def process_url_for_iframe(url):
|
75 |
"""URL์ iframe์ ํ์ํ๊ธฐ ์ ํฉํ ํํ๋ก ๋ณํํฉ๋๋ค."""
|
76 |
+
# ํ๊น
ํ์ด์ค URL ํจํด ๊ฐ์ง
|
77 |
+
is_huggingface = False
|
78 |
+
|
79 |
+
# .hf.space ๋๋ฉ์ธ ๋๋ huggingface.co ํจํด ํ์ธ
|
80 |
+
if ".hf.space" in url or "huggingface.co" in url:
|
81 |
+
is_huggingface = True
|
82 |
+
|
83 |
+
# huggingface.co/spaces ํจํด์ /embed ์ถ๊ฐ (์ด๋ฏธ ์๋ ๊ฒฝ์ฐ)
|
84 |
+
if "huggingface.co/spaces" in url and not url.endswith("/embed"):
|
85 |
url = url.rstrip("/")
|
|
|
86 |
url = f"{url}/embed"
|
87 |
|
88 |
+
return url, is_huggingface
|
89 |
|
90 |
# โโโโโโโโโโโโโโโโโโโโโ 6. HTML ๊ทธ๋ฆฌ๋ โโโโโโโโโโโโโโโโโโโ
|
91 |
def html(cards, pg, total):
|
|
|
162 |
transform: scale(0.7);
|
163 |
transform-origin: top left;
|
164 |
border: 0;
|
165 |
+
frameborder: 0;
|
166 |
}
|
167 |
/* ํ๊น
ํ์ด์ค iframe ํน๋ณ ์คํ์ผ */
|
168 |
.frame.huggingface iframe {
|
169 |
+
width: 100% !important;
|
170 |
+
height: 100% !important;
|
171 |
+
transform: none !important;
|
172 |
+
border: none !important;
|
173 |
}
|
174 |
.foot {
|
175 |
padding: 6px 12px;
|
|
|
244 |
|
245 |
# URL ์ฒ๋ฆฌ: ํ๊น
ํ์ด์ค URL์ธ ๊ฒฝ์ฐ ํน๋ณ ์ฒ๋ฆฌ
|
246 |
url = c['url']
|
247 |
+
iframe_url, is_huggingface = process_url_for_iframe(url)
|
248 |
|
249 |
# ํ๊น
ํ์ด์ค URL์ ํน๋ณ ํด๋์ค ์ถ๊ฐ
|
250 |
+
frame_class = "frame huggingface" if is_huggingface else "frame"
|
251 |
|
252 |
h += f"""
|
253 |
<div class="card">
|
254 |
<div class="hdr"><p class="ttl">{c['title']}</p><p class="date">{date}</p></div>
|
255 |
+
<div class="{frame_class}">
|
256 |
+
<iframe
|
257 |
+
src="{iframe_url}"
|
258 |
+
loading="lazy"
|
259 |
+
frameborder="0"
|
260 |
+
width="100%"
|
261 |
+
height="100%"
|
262 |
+
allowfullscreen="true"
|
263 |
+
allow="accelerometer; camera; encrypted-media; gyroscope; microphone;"
|
264 |
+
sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads">
|
265 |
+
</iframe>
|
266 |
+
</div>
|
267 |
<div class="foot"><a class="link" href="{url}" target="_blank">์๋ณธโ</a></div>
|
268 |
</div>"""
|
269 |
|