benjamin5607 commited on
Commit
49f12e1
ยท
verified ยท
1 Parent(s): 8e01cf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -15
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
- if(!visitedPlaces.includes(name)) {
399
- visitedPlaces.push(name);
400
- localStorage.setItem('visitedPlaces', JSON.stringify(visitedPlaces));
 
 
 
401
  alert("โœˆ๏ธ Stamped on Passport!");
402
  } else { alert("You already visited here!"); }
403
  }
404
 
405
- function openPassport() { document.getElementById('passport-page').style.transform = 'translateX(0%)'; const grid = document.getElementById('stamp-grid'); grid.innerHTML = ""; for(let c in PLACE_DB) { PLACE_DB[c].forEach(p => { const active = visitedPlaces.includes(p.name); const div = document.createElement('div'); div.className = 'stamp' + (active ? ' active' : ''); div.innerHTML = active ? `๐Ÿท<br><b>${p.name}</b>` : `โœˆ๏ธ`; grid.appendChild(div); }); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- if(c.toLowerCase().includes(q)) { const p = PLACE_DB[c][0]; if(p.lat && p.lon) { worldMap.setView([p.lat, p.lon], 10); return; } }
444
- for(let p of PLACE_DB[c]) { if(p.name.toLowerCase().includes(q)) { if(p.lat && p.lon) { worldMap.setView([p.lat, p.lon], 16); return; } } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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."); }