Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -48,47 +48,71 @@ def process_url_for_iframe(url):
|
|
48 |
return url, False, []
|
49 |
|
50 |
# โโโโโโโโโโโโโโโโโโโโโ 4. ์นด๋ ๊ทธ๋ฆฌ๋ HTML โโโโโโโโโโโโโโโ
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
css = r"""
|
56 |
<style>
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</style>"""
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
<div class="card">
|
85 |
-
<div class="
|
86 |
-
<iframe src="{
|
|
|
|
|
87 |
</div>
|
88 |
</div>"""
|
89 |
-
|
90 |
-
|
91 |
-
return
|
|
|
92 |
|
93 |
# โโโโโโโโโโโโโโโโโโโโโ 5. Gradio UI โโโโโโโโโโโโโโโโโโโโโ
|
94 |
def build():
|
|
|
48 |
return url, False, []
|
49 |
|
50 |
# โโโโโโโโโโโโโโโโโโโโโ 4. ์นด๋ ๊ทธ๋ฆฌ๋ HTML โโโโโโโโโโโโโโโ
|
51 |
+
# โโโโโโโโโโโโโโโโโโโโโ 6. HTML ๊ทธ๋ฆฌ๋ โโโโโโโโโโโโโโโโโโโ
|
52 |
+
def html(cards, pg, total):
|
53 |
+
if not cards:
|
54 |
+
return "<div style='text-align:center;padding:70px;color:#555;'>ํ์ํ ๋ฐฐํฌ๊ฐ ์์ต๋๋ค.</div>"
|
55 |
css = r"""
|
56 |
<style>
|
57 |
+
body{
|
58 |
+
margin:0;padding:0;font-family:Poppins,sans-serif;
|
59 |
+
background:#f0f0f0;overflow-x:hidden;overflow-y:auto;
|
60 |
+
}
|
61 |
+
.container{width:100%;padding:10px;padding-bottom:70px;box-sizing:border-box;}
|
62 |
+
.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;width:100%;}
|
63 |
+
/* ์นด๋ ์ ์ฒด๊ฐ ๊ฒ์ ํ๋ฉด โ ํ
๋๋ฆฌ๋ง ๋ ์ํ */
|
64 |
+
.card{
|
65 |
+
background:#fff;border-radius:10px;overflow:hidden;
|
66 |
+
box-shadow:0 4px 10px rgba(0,0,0,0.08);
|
67 |
+
height:420px; /* โ ์นด๋ ํค์ */
|
68 |
+
position:relative;
|
69 |
+
}
|
70 |
+
.frame{width:100%;height:100%;position:relative;overflow:hidden;}
|
71 |
+
.frame iframe{
|
72 |
+
position:absolute;top:0;left:0;
|
73 |
+
width:166.667%;height:166.667%; /* 1/0.6 = 1.6667 */
|
74 |
+
transform:scale(0.6); /* ๊ฒ์ ํ๋ฉด 60โฏ% ์ถ์ */
|
75 |
+
transform-origin:top left;
|
76 |
+
border:0;
|
77 |
+
}
|
78 |
+
/* ํ๊น
ํ์ด์ค ์๋ฒ ๋(์ด๋ฏธ ๋ด๋ถ์ ์ค์ผ์ผ๋ง๋จ)๋ ๊ทธ๋๋ก */
|
79 |
+
.frame.huggingface iframe{
|
80 |
+
width:100%!important;height:100%!important;
|
81 |
+
transform:none!important;border:none!important;
|
82 |
+
}
|
83 |
+
/* ๋ฐ์ํ ๋์ด ์กฐ์ */
|
84 |
+
@media(min-width:1200px){.card{height:560px;}}
|
85 |
+
@media(max-width:767px){
|
86 |
+
.grid{grid-template-columns:1fr;}
|
87 |
+
.card{height:480px;}
|
88 |
+
}
|
89 |
</style>"""
|
90 |
+
|
91 |
+
# โฌ(์ดํ JS ๋ฐ ์นด๋ ์์ฑ ๋ก์ง์ ๊ธฐ์กด๊ณผ ๋์ผ)โฌ
|
92 |
+
js = """
|
93 |
+
<script>
|
94 |
+
/* ... (๋์ผ) ... */
|
95 |
+
</script>
|
96 |
+
"""
|
97 |
+
|
98 |
+
h = css + js + '<div class="container"><div class="grid">'
|
99 |
+
for idx, url in enumerate(cards):
|
100 |
+
iframe_url, is_huggingface, alt_urls = process_url_for_iframe(url)
|
101 |
+
frame_class = "frame huggingface" if is_huggingface else "frame"
|
102 |
+
iframe_id = f"iframe-{idx}-{hash(url)%10000}"
|
103 |
+
alt_attr = f'data-alternate-urls="{",".join(alt_urls)}"' if alt_urls else ""
|
104 |
+
h += f"""
|
105 |
<div class="card">
|
106 |
+
<div class="{frame_class}">
|
107 |
+
<iframe id="{iframe_id}" src="{iframe_url}" loading="lazy"
|
108 |
+
sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"
|
109 |
+
data-original-url="{url}" {alt_attr}></iframe>
|
110 |
</div>
|
111 |
</div>"""
|
112 |
+
h += "</div></div>"
|
113 |
+
h += f'<div class="page-info">Page {pg} / {total}</div>'
|
114 |
+
return h
|
115 |
+
|
116 |
|
117 |
# โโโโโโโโโโโโโโโโโโโโโ 5. Gradio UI โโโโโโโโโโโโโโโโโโโโโ
|
118 |
def build():
|