Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,6 @@ SHEET_URL = os.environ.get("PRIVATE_SHEET_URL", "").strip()
|
|
| 20 |
if not SHEET_URL and "PRIVATE_SHEET_URL" in st.secrets:
|
| 21 |
SHEET_URL = st.secrets["PRIVATE_SHEET_URL"].strip()
|
| 22 |
|
| 23 |
-
# ์ํ ํ์
|
| 24 |
with st.sidebar:
|
| 25 |
st.write("### ๐ง System Status")
|
| 26 |
if GROQ_API_KEY and len(GROQ_API_KEY) > 10:
|
|
@@ -82,7 +81,7 @@ db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
|
|
| 82 |
db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
|
| 83 |
|
| 84 |
# ==========================================
|
| 85 |
-
# ๐ฅ๏ธ 3. ํตํฉ ํ๋ก ํธ์๋ (
|
| 86 |
# ==========================================
|
| 87 |
html_template = """
|
| 88 |
<!DOCTYPE html>
|
|
@@ -139,10 +138,7 @@ html_template = """
|
|
| 139 |
.msg.bot { align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }
|
| 140 |
.msg.user { align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }
|
| 141 |
.reco-btn { display: block; margin-top: 8px; padding: 10px; background: var(--gold); color: black !important; border-radius: 10px; font-weight: bold; text-decoration: none; font-size: 12px; cursor: pointer; border:none; width: 100%; text-align: center; }
|
| 142 |
-
|
| 143 |
-
/* [๋ณต๊ตฌ] ํ์
๋ฒํผ ์คํ์ผ */
|
| 144 |
.popup-btn { background: var(--gold); color: black; border: none; padding: 6px 12px; border-radius: 5px; font-weight: bold; font-size: 11px; cursor: pointer; width: 100%; margin-top: 5px; }
|
| 145 |
-
.popup-btn:hover { opacity: 0.9; }
|
| 146 |
.leaflet-popup-content-wrapper { background: #1a1a1a; color: white; border: 1px solid var(--gold); }
|
| 147 |
.leaflet-popup-content { margin: 10px; }
|
| 148 |
|
|
@@ -181,7 +177,7 @@ html_template = """
|
|
| 181 |
<div id="world-map-page" class="page">
|
| 182 |
<div class="nav-bar"><button onclick="closeMap()">๐ HOME</button></div>
|
| 183 |
<div class="map-search-container">
|
| 184 |
-
<input id="map-input" class="map-search-input" type="text" placeholder="Search City or Place..." onkeydown="if(event.key==='Enter') searchMap()">
|
| 185 |
<button class="map-loc-btn" onclick="panToUser()">โ</button>
|
| 186 |
</div>
|
| 187 |
<div id="full-map" style="width:100%; height:100%;"></div>
|
|
@@ -395,17 +391,37 @@ html_template = """
|
|
| 395 |
}
|
| 396 |
|
| 397 |
function markVisited(name) {
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
|
|
|
|
|
|
|
|
|
| 401 |
alert("โ๏ธ Stamped on Passport!");
|
| 402 |
} else { alert("You already visited here!"); }
|
| 403 |
}
|
| 404 |
|
| 405 |
-
function openPassport() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
function closePassport() { document.getElementById('passport-page').style.transform = 'translateX(-100%)'; }
|
| 407 |
|
| 408 |
-
// [๋ณต๊ตฌ ์๋ฃ] ์ง๋ ํ์
์นด๋: ์ค๋ช
+ AI๋ฆฌ๋ทฐ ๋ฒํผ + ์ง๋ ๋ฒํผ
|
| 409 |
function openMap() {
|
| 410 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 411 |
if(!worldMap) {
|
|
@@ -415,7 +431,6 @@ html_template = """
|
|
| 415 |
if(p.lat && p.lon) {
|
| 416 |
const lbl = p.label || p.category || "";
|
| 417 |
const desc = p['desc_'+currentLang.toLowerCase()] || p.desc_ko || "";
|
| 418 |
-
// ์ค๋ช
์ ๋๋ฌด ๊ธธ๋ฉด ์๋ผ์ ๋ณด์ฌ์ค (UI ๊นจ์ง ๋ฐฉ์ง)
|
| 419 |
const shortDesc = desc.length > 50 ? desc.substring(0, 50) + "..." : desc;
|
| 420 |
|
| 421 |
const popupContent = `
|
|
@@ -437,13 +452,36 @@ html_template = """
|
|
| 437 |
|
| 438 |
function closeMap() { document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }
|
| 439 |
|
|
|
|
| 440 |
function searchMap() {
|
| 441 |
const q = document.getElementById('map-input').value.toLowerCase();
|
|
|
|
|
|
|
|
|
|
| 442 |
for(let c in PLACE_DB) {
|
| 443 |
-
|
| 444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
}
|
| 446 |
-
alert("Not Found");
|
| 447 |
}
|
| 448 |
|
| 449 |
function panToUser() { if(userLat && userLon) worldMap.setView([userLat, userLon], 14); else alert("GPS missing."); }
|
|
|
|
| 20 |
if not SHEET_URL and "PRIVATE_SHEET_URL" in st.secrets:
|
| 21 |
SHEET_URL = st.secrets["PRIVATE_SHEET_URL"].strip()
|
| 22 |
|
|
|
|
| 23 |
with st.sidebar:
|
| 24 |
st.write("### ๐ง System Status")
|
| 25 |
if GROQ_API_KEY and len(GROQ_API_KEY) > 10:
|
|
|
|
| 81 |
db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
|
| 82 |
|
| 83 |
# ==========================================
|
| 84 |
+
# ๐ฅ๏ธ 3. ํตํฉ ํ๋ก ํธ์๋ (๊ฒ์ ๋ก์ง ๊ฐํ & ์คํฌํ ๋๊ธฐํ)
|
| 85 |
# ==========================================
|
| 86 |
html_template = """
|
| 87 |
<!DOCTYPE html>
|
|
|
|
| 138 |
.msg.bot { align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }
|
| 139 |
.msg.user { align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }
|
| 140 |
.reco-btn { display: block; margin-top: 8px; padding: 10px; background: var(--gold); color: black !important; border-radius: 10px; font-weight: bold; text-decoration: none; font-size: 12px; cursor: pointer; border:none; width: 100%; text-align: center; }
|
|
|
|
|
|
|
| 141 |
.popup-btn { background: var(--gold); color: black; border: none; padding: 6px 12px; border-radius: 5px; font-weight: bold; font-size: 11px; cursor: pointer; width: 100%; margin-top: 5px; }
|
|
|
|
| 142 |
.leaflet-popup-content-wrapper { background: #1a1a1a; color: white; border: 1px solid var(--gold); }
|
| 143 |
.leaflet-popup-content { margin: 10px; }
|
| 144 |
|
|
|
|
| 177 |
<div id="world-map-page" class="page">
|
| 178 |
<div class="nav-bar"><button onclick="closeMap()">๐ HOME</button></div>
|
| 179 |
<div class="map-search-container">
|
| 180 |
+
<input id="map-input" class="map-search-input" type="text" placeholder="Search City, Address or Place..." onkeydown="if(event.key==='Enter') searchMap()">
|
| 181 |
<button class="map-loc-btn" onclick="panToUser()">โ</button>
|
| 182 |
</div>
|
| 183 |
<div id="full-map" style="width:100%; height:100%;"></div>
|
|
|
|
| 391 |
}
|
| 392 |
|
| 393 |
function markVisited(name) {
|
| 394 |
+
// [ํจ์น] ์คํฌํ ๋๊ธฐํ ๋ก์ง ๊ฐํ (์ต์ ๊ฐ ๋ค์ ๋ก๋)
|
| 395 |
+
let vp = JSON.parse(localStorage.getItem('visitedPlaces') || '[]');
|
| 396 |
+
if(!vp.includes(name)) {
|
| 397 |
+
vp.push(name);
|
| 398 |
+
localStorage.setItem('visitedPlaces', JSON.stringify(vp));
|
| 399 |
+
visitedPlaces = vp; // ๋ฉ๋ชจ๋ฆฌ ๋ณ์ ์ฆ์ ๋๊ธฐํ
|
| 400 |
alert("โ๏ธ Stamped on Passport!");
|
| 401 |
} else { alert("You already visited here!"); }
|
| 402 |
}
|
| 403 |
|
| 404 |
+
function openPassport() {
|
| 405 |
+
document.getElementById('passport-page').style.transform = 'translateX(0%)';
|
| 406 |
+
// [ํจ์น] ์ฌ๊ถ ์ด ๋๋ง๋ค ๋ก์ปฌ์คํ ๋ฆฌ์ง์์ ์ต์ ๋ฐ์ดํฐ ๊ฐ์ ๋ก๋
|
| 407 |
+
visitedPlaces = JSON.parse(localStorage.getItem('visitedPlaces') || '[]');
|
| 408 |
+
|
| 409 |
+
const grid = document.getElementById('stamp-grid');
|
| 410 |
+
grid.innerHTML = "";
|
| 411 |
+
|
| 412 |
+
for(let c in PLACE_DB) {
|
| 413 |
+
PLACE_DB[c].forEach(p => {
|
| 414 |
+
const active = visitedPlaces.includes(p.name);
|
| 415 |
+
const div = document.createElement('div');
|
| 416 |
+
div.className = 'stamp' + (active ? ' active' : '');
|
| 417 |
+
div.innerHTML = active ? `๐ท<br><b>${p.name}</b>` : `โ๏ธ`;
|
| 418 |
+
grid.appendChild(div);
|
| 419 |
+
});
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
function closePassport() { document.getElementById('passport-page').style.transform = 'translateX(-100%)'; }
|
| 424 |
|
|
|
|
| 425 |
function openMap() {
|
| 426 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 427 |
if(!worldMap) {
|
|
|
|
| 431 |
if(p.lat && p.lon) {
|
| 432 |
const lbl = p.label || p.category || "";
|
| 433 |
const desc = p['desc_'+currentLang.toLowerCase()] || p.desc_ko || "";
|
|
|
|
| 434 |
const shortDesc = desc.length > 50 ? desc.substring(0, 50) + "..." : desc;
|
| 435 |
|
| 436 |
const popupContent = `
|
|
|
|
| 452 |
|
| 453 |
function closeMap() { document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }
|
| 454 |
|
| 455 |
+
// [ํจ์น] ๊ฒ์ ๊ธฐ๋ฅ ๊ฐํ: ์ด๋ฆ, ์ฃผ์, ์ค๋ช
, ๋์์ด๋ฆ(ํค๊ฐ) ๋ชจ๋ ๊ฒ์
|
| 456 |
function searchMap() {
|
| 457 |
const q = document.getElementById('map-input').value.toLowerCase();
|
| 458 |
+
if(!q) return;
|
| 459 |
+
|
| 460 |
+
let found = false;
|
| 461 |
for(let c in PLACE_DB) {
|
| 462 |
+
// 1. ๋๋ผ/๋์ ์ด๋ฆ ์ฒดํฌ
|
| 463 |
+
if(c.toLowerCase().includes(q)) {
|
| 464 |
+
// ํด๋น ๋์์ ์ฒซ ๋ฒ์งธ ์ฅ์๋ก ์ด๋
|
| 465 |
+
if(PLACE_DB[c].length > 0 && PLACE_DB[c][0].lat && PLACE_DB[c][0].lon) {
|
| 466 |
+
worldMap.setView([PLACE_DB[c][0].lat, PLACE_DB[c][0].lon], 12);
|
| 467 |
+
found = true; break;
|
| 468 |
+
}
|
| 469 |
+
}
|
| 470 |
+
// 2. ์ฅ์ ์์ธ ์ฒดํฌ
|
| 471 |
+
for(let p of PLACE_DB[c]) {
|
| 472 |
+
// ์ด๋ฆ + ์ฃผ์ + ์ค๋ช
์ ๋ชจ๋ ํฉ์ณ์ ๊ฒ์
|
| 473 |
+
const content = (p.name + " " + (p.address||"") + " " + (p.desc_ko||"")).toLowerCase();
|
| 474 |
+
if(content.includes(q)) {
|
| 475 |
+
if(p.lat && p.lon) {
|
| 476 |
+
worldMap.setView([p.lat, p.lon], 16);
|
| 477 |
+
L.popup().setLatLng([p.lat, p.lon]).setContent(`<b>${p.name}</b>`).openOn(worldMap);
|
| 478 |
+
found = true; break;
|
| 479 |
+
}
|
| 480 |
+
}
|
| 481 |
+
}
|
| 482 |
+
if(found) break;
|
| 483 |
}
|
| 484 |
+
if(!found) alert("Not Found");
|
| 485 |
}
|
| 486 |
|
| 487 |
function panToUser() { if(userLat && userLon) worldMap.setView([userLat, userLon], 14); else alert("GPS missing."); }
|