Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -128,19 +128,67 @@ def html(cards, pg, total):
|
|
128 |
.date{margin-top:4px;font-size:.85rem;color:#777;}
|
129 |
.frame{position:relative;width:100%;padding-top:60%;overflow:hidden;}
|
130 |
.frame iframe{position:absolute;top:0;left:0;width:142.857%;height:142.857%;
|
131 |
-
transform:scale(.7);transform-origin:top left;border:0;}
|
132 |
.foot{padding:14px 24px;background:rgba(255,255,255,.85);backdrop-filter:blur(8px);text-align:right;}
|
133 |
.link{font-size:.85rem;font-weight:600;color:#4a6dd8;text-decoration:none;}
|
134 |
.cnt{text-align:center;font-size:.85rem;color:#555;margin:10px 0 40px;}
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
h=css+"<div class='grid'>"
|
137 |
for c in cards:
|
138 |
date=datetime.datetime.fromtimestamp(int(c["ts"])).strftime("%Y-%m-%d")
|
139 |
h+=f"""
|
140 |
<div class='card'>
|
141 |
<div class='hdr'><p class='ttl'>{c['title']}</p><p class='date'>{date}</p></div>
|
142 |
-
<div class='frame'
|
143 |
-
|
|
|
|
|
|
|
144 |
<div class='foot'><a class='link' href="{c['url']}" target="_blank">์๋ณธโ</a></div>
|
145 |
</div>"""
|
146 |
h+="</div><p class='cnt'>Page "+str(pg)+" / "+str(total)+"</p>"
|
|
|
128 |
.date{margin-top:4px;font-size:.85rem;color:#777;}
|
129 |
.frame{position:relative;width:100%;padding-top:60%;overflow:hidden;}
|
130 |
.frame iframe{position:absolute;top:0;left:0;width:142.857%;height:142.857%;
|
131 |
+
transform:scale(.7);transform-origin:top left;border:0;opacity:0;transition:opacity 0.3s;}
|
132 |
.foot{padding:14px 24px;background:rgba(255,255,255,.85);backdrop-filter:blur(8px);text-align:right;}
|
133 |
.link{font-size:.85rem;font-weight:600;color:#4a6dd8;text-decoration:none;}
|
134 |
.cnt{text-align:center;font-size:.85rem;color:#555;margin:10px 0 40px;}
|
135 |
+
/* ์ถ๊ฐ - iframe ์ค๋ฅ ์ํ ์ฒ๋ฆฌ */
|
136 |
+
.frame-error {position:absolute;top:0;left:0;width:100%;height:100%;
|
137 |
+
display:flex;align-items:center;justify-content:center;
|
138 |
+
background:#f8f8f8;color:#666;font-size:14px;text-align:center;
|
139 |
+
padding:20px;box-sizing:border-box;flex-direction:column;}
|
140 |
+
.frame-error-icon {font-size:36px;margin-bottom:12px;color:#999;}
|
141 |
+
</style>
|
142 |
+
|
143 |
+
<script>
|
144 |
+
// iframe ๋ก๋ ์ค๋ฅ ์ฒ๋ฆฌ ํจ์
|
145 |
+
function handleIframeError(iframe) {
|
146 |
+
const container = iframe.parentNode;
|
147 |
+
iframe.style.display = 'none';
|
148 |
+
const errorDiv = document.createElement('div');
|
149 |
+
errorDiv.className = 'frame-error';
|
150 |
+
errorDiv.innerHTML = '<div class="frame-error-icon">๐</div>' +
|
151 |
+
'<div>์ด ์ฝํ
์ธ ๋ iframe์ผ๋ก ํ์ํ ์ ์์ต๋๋ค.</div>' +
|
152 |
+
'<div>๋ณด์ ์ค์ ์ผ๋ก ์ธํด ์ฐจ๋จ๋์์ต๋๋ค.</div>' +
|
153 |
+
'<div style="margin-top:10px;font-size:12px;color:#999;">์๋ ์๋ณธ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ์ ํญ์์ ์ด์ด๋ณด์ธ์.</div>';
|
154 |
+
container.appendChild(errorDiv);
|
155 |
+
}
|
156 |
+
|
157 |
+
// iframe ๋ก๋ ์ฑ๊ณต ์ฒ๋ฆฌ
|
158 |
+
function handleIframeLoad(iframe) {
|
159 |
+
iframe.style.opacity = 1;
|
160 |
+
}
|
161 |
+
|
162 |
+
// iframe ๋ก๋ ์ํ ํ์ธ
|
163 |
+
document.addEventListener('DOMContentLoaded', function() {
|
164 |
+
// ๋ชจ๋ iframe์ error ํธ๋ค๋ฌ ์ถ๊ฐ
|
165 |
+
const frames = document.querySelectorAll('iframe');
|
166 |
+
frames.forEach(frame => {
|
167 |
+
frame.addEventListener('error', function() {
|
168 |
+
handleIframeError(this);
|
169 |
+
});
|
170 |
+
|
171 |
+
// 5์ด ํ์๋ ๋ก๋๋์ง ์์ผ๋ฉด ์ค๋ฅ๋ก ๊ฐ์ฃผ
|
172 |
+
setTimeout(function() {
|
173 |
+
if(frame.style.opacity !== '1') {
|
174 |
+
handleIframeError(frame);
|
175 |
+
}
|
176 |
+
}, 5000);
|
177 |
+
});
|
178 |
+
});
|
179 |
+
</script>"""
|
180 |
+
|
181 |
h=css+"<div class='grid'>"
|
182 |
for c in cards:
|
183 |
date=datetime.datetime.fromtimestamp(int(c["ts"])).strftime("%Y-%m-%d")
|
184 |
h+=f"""
|
185 |
<div class='card'>
|
186 |
<div class='hdr'><p class='ttl'>{c['title']}</p><p class='date'>{date}</p></div>
|
187 |
+
<div class='frame'>
|
188 |
+
<iframe src="{c['url']}" loading="lazy"
|
189 |
+
allow="accelerometer; camera; encrypted-media; gyroscope;"
|
190 |
+
onload="handleIframeLoad(this)"></iframe>
|
191 |
+
</div>
|
192 |
<div class='foot'><a class='link' href="{c['url']}" target="_blank">์๋ณธโ</a></div>
|
193 |
</div>"""
|
194 |
h+="</div><p class='cnt'>Page "+str(pg)+" / "+str(total)+"</p>"
|