benjamin5607 commited on
Commit
f86d6c4
ยท
verified ยท
1 Parent(s): e937907

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -31
app.py CHANGED
@@ -24,7 +24,7 @@ st.markdown("""
24
  """, unsafe_allow_html=True)
25
 
26
  # ==========================================
27
- # 2. ๋ฐ์ดํ„ฐ ๋กœ๋“œ ๋ฐ ์ •์ œ
28
  # ==========================================
29
  PLACE_DB = {}
30
  try:
@@ -33,6 +33,10 @@ try:
33
  response.encoding = 'utf-8'
34
  df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
35
 
 
 
 
 
36
  for col in df.select_dtypes(include=['object']).columns:
37
  df[col] = df[col].astype(str).str.replace(r'[\r\n\t]+', ' ', regex=True).str.replace('"', '\\"').str.replace("'", "\\'")
38
 
@@ -51,7 +55,7 @@ db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
51
  db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
52
 
53
  # ==========================================
54
- # 3. ํ†ตํ•ฉ ํ”„๋ก ํŠธ์—”๋“œ (๋ผ๋ฒจ๋ง ์ •๋ฐ€ ์ˆ˜์ • ๋ฒ„์ „)
55
  # ==========================================
56
  html_template = """
57
  <!DOCTYPE html>
@@ -63,28 +67,31 @@ html_template = """
63
  <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
64
  <style>
65
  :root { --gold: #d4af37; --dark: #0a0a0a; --text: #e0e0e0; }
66
- body { margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', sans-serif; overflow: hidden; }
67
  .page { position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s ease; display: flex; flex-direction: column; }
68
 
 
69
  .top-nav { height: 60px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; z-index: 500; }
70
  .passport-btn { font-size: 26px; cursor: pointer; background: rgba(255,215,0,0.1); padding: 8px; border-radius: 15px; border: 1px solid rgba(212,175,55,0.3); }
71
  .lang-switcher { display: flex; gap: 6px; }
72
  .lang-btn { background: rgba(0,0,0,0.6); border: 1px solid #444; color: #888; padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 11px; }
73
  .lang-btn.active { background: var(--gold); color: black; font-weight: bold; border-color: var(--gold); }
74
 
 
75
  .type-filter-container { width: 100%; padding: 10px 0; overflow-x: auto; display: flex; gap: 8px; justify-content: center; scrollbar-width: none; }
76
  .type-btn { padding: 8px 16px; border-radius: 20px; font-size: 11px; font-weight: bold; background: #1a1a1a; color: #777; border: 1px solid #333; white-space: nowrap; cursor: pointer; }
77
  .type-btn.selected { background: var(--gold); color: black; border-color: var(--gold); }
78
 
 
79
  .place-list-container { flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; }
80
  .place-card { background: #161616; border: 1px solid #2a2a2a; border-radius: 18px; padding: 20px; margin-bottom: 15px; position: relative; }
81
- .pc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
82
  .pc-name { font-size: 19px; font-weight: bold; color: var(--gold); line-height: 1.2; flex: 1; }
83
 
84
- /* ๋ผ๋ฒจ ๋””์ž์ธ ์ˆ˜์ •: DB ๋ฐ์ดํ„ฐ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅ */
85
  .pc-label {
86
- font-size: 10px; padding: 4px 10px; border-radius: 8px;
87
- background: rgba(212,175,55,0.15); color: var(--gold);
88
  border: 1px solid var(--gold); font-weight: 900; white-space: nowrap;
89
  }
90
 
@@ -93,9 +100,8 @@ html_template = """
93
 
94
  .bartender-btn { position: fixed; bottom: 30%; right: 20px; width: 85px; height: 85px; border-radius: 50%; background-image: url('IMAGE_DATA'); background-size: cover; border: 3px solid var(--gold); z-index: 999; box-shadow: 0 0 20px rgba(212, 175, 55, 0.5); }
95
 
96
- #world-map-page { background: #000; z-index: 2000; transform: translateY(100%); }
97
- #passport-page { background: #0f0f1b; z-index: 5000; transform: translateX(-100%); }
98
- #chat-page { background: #000; z-index: 3000; transform: translateY(100%); }
99
  #detail-page { background: #0a0a0a; z-index: 4000; transform: translateX(100%); }
100
  .nav-bar { height: 60px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #222; }
101
  </style>
@@ -114,7 +120,7 @@ html_template = """
114
 
115
  <div style="text-align:center; padding: 5px 0 15px 0;">
116
  <div style="color:var(--gold); font-size: 26px; font-weight: 900; letter-spacing: 4px;">DRUNKEN PLANE</div>
117
- <button onclick="openMap()" style="margin-top:10px; padding:12px 25px; background:var(--gold); border:none; border-radius:30px; font-weight:bold; cursor:pointer;">๐Ÿ—บ๏ธ EXPLORE WORLD MAP</button>
118
  </div>
119
 
120
  <center><select id="country-select" style="width:85%; max-width:400px; padding:12px; background:#111; border:1px solid var(--gold); color:white; border-radius:10px;" onchange="selectCountry(this.value)"></select></center>
@@ -124,10 +130,10 @@ html_template = """
124
  <div class="bartender-btn" onclick="openChat()"></div>
125
  </div>
126
 
127
- <div id="passport-page" class="page"><div class="nav-bar"><button onclick="closePassport()">โ†</button> PASSPORT</div><div id="stamp-grid" class="stamp-grid"></div></div>
128
  <div id="world-map-page" class="page"><div class="nav-bar"><button onclick="closeMap()">๐Ÿ  HOME</button></div><div id="full-map" style="width:100%; height:100%;"></div></div>
129
  <div id="chat-page" class="page"><div class="nav-bar"><button onclick="closeChat()">โ†</button> Emily</div><div id="chat-messages" style="flex:1; overflow-y:auto; padding:20px;"></div></div>
130
- <div id="detail-page" class="page"><div class="nav-bar"><button onclick="closeDetail()">โ†</button> Report</div><div id="repo-content" style="padding:20px;"></div></div>
131
 
132
  <script>
133
  function b64DecodeUnicode(str) { return decodeURIComponent(atob(str).split('').map(function(c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }).join('')); }
@@ -150,13 +156,7 @@ html_template = """
150
  renderFilters();
151
  };
152
 
153
- function setLanguage(l, el) {
154
- currentLang = l;
155
- document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
156
- el.classList.add('active');
157
- renderFilters(); renderList();
158
- }
159
-
160
  function renderFilters() {
161
  const box = document.getElementById('filter-box'); box.innerHTML = "";
162
  const t = TRANSLATIONS[currentLang];
@@ -166,38 +166,48 @@ html_template = """
166
  box.appendChild(btn);
167
  });
168
  }
169
-
170
  function selectCountry(c) { selectedCountry = c; renderList(); }
171
 
172
  function renderList() {
173
  const list = document.getElementById('place-list'); list.innerHTML = "";
174
  const countryPlaces = PLACE_DB[selectedCountry] || [];
175
- const filtered = countryPlaces.filter(p => selectedType === "All" || p.category.includes(selectedType) || p.category === selectedType);
176
  const t = TRANSLATIONS[currentLang];
177
 
178
  filtered.forEach(p => {
179
  const card = document.createElement('div'); card.className = 'place-card';
180
- const desc = p['desc_'+currentLang.toLowerCase()] || p.desc_en || p.desc_ko || "Discovering heritage...";
181
-
182
- // [์ˆ˜์ •] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋ผ๋ฒจ(category) ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ
183
- const dbLabel = p.category || "";
184
 
185
  card.innerHTML = `
186
  <div class="pc-header">
187
  <div class="pc-name">${p.name}</div>
188
- <div class="pc-label">${dbLabel}</div>
189
  </div>
190
  <div class="pc-desc">${desc}</div>
191
  <div style="display:flex; gap:10px; margin-top:15px;">
192
- <button class="btn-action" style="background:var(--gold); color:black;" onclick="openReview('${p.name.replace(/'/g, "\\\\'")}', '${selectedCountry}')">${t.aiBtn}</button>
193
- <button class="btn-action" style="background:#333; color:white;" onclick="window.open('http://googleusercontent.com/maps.google.com/3{p.name}', '_blank')">${t.mapBtn}</button>
194
  </div>`;
195
  list.appendChild(card);
196
  });
197
  }
198
 
199
- // --- ๊ธฐ๋Šฅ ํ•จ์ˆ˜๋“ค (์ด์ „๊ณผ ๋™์ผ) ---
200
- function openPassport() { document.getElementById('passport-page').style.transform = 'translateX(0%)'; }
 
 
 
 
 
 
 
 
 
 
 
 
201
  function closePassport() { document.getElementById('passport-page').style.transform = 'translateX(-100%)'; }
202
  function openMap() { document.getElementById('world-map-page').style.transform = 'translateY(0%)'; }
203
  function closeMap() { document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }
 
24
  """, unsafe_allow_html=True)
25
 
26
  # ==========================================
27
+ # 2. ๋ฐ์ดํ„ฐ ๋กœ๋“œ ๋ฐ ์ •์ œ (L์—ด label ํ•„๋“œ ํ™•๋ณด)
28
  # ==========================================
29
  PLACE_DB = {}
30
  try:
 
33
  response.encoding = 'utf-8'
34
  df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
35
 
36
+ # ๊ณต๋ฐฑ ์ œ๊ฑฐ ๋ฐ ์†Œ๋ฌธ์ž ๋ณ€ํ™˜์œผ๋กœ ์ปฌ๋Ÿผ ๋งค์นญ ์ •ํ™•๋„ ํ–ฅ์ƒ
37
+ df.columns = df.columns.str.strip()
38
+
39
+ # JS ์—๋Ÿฌ ๋ฐฉ์ง€๋ฅผ ์œ„ํ•œ ํ…์ŠคํŠธ ์ •์ œ
40
  for col in df.select_dtypes(include=['object']).columns:
41
  df[col] = df[col].astype(str).str.replace(r'[\r\n\t]+', ' ', regex=True).str.replace('"', '\\"').str.replace("'", "\\'")
42
 
 
55
  db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
56
 
57
  # ==========================================
58
+ # 3. ํ†ตํ•ฉ ํ”„๋ก ํŠธ์—”๋“œ (Label ์ปฌ๋Ÿผ ์ง๊ฒฐ ๋ฒ„์ „)
59
  # ==========================================
60
  html_template = """
61
  <!DOCTYPE html>
 
67
  <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
68
  <style>
69
  :root { --gold: #d4af37; --dark: #0a0a0a; --text: #e0e0e0; }
70
+ body { margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', 'Apple SD Gothic Neo', sans-serif; overflow: hidden; }
71
  .page { position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s ease; display: flex; flex-direction: column; }
72
 
73
+ /* ๋„ค๋น„๊ฒŒ์ด์…˜ */
74
  .top-nav { height: 60px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; z-index: 500; }
75
  .passport-btn { font-size: 26px; cursor: pointer; background: rgba(255,215,0,0.1); padding: 8px; border-radius: 15px; border: 1px solid rgba(212,175,55,0.3); }
76
  .lang-switcher { display: flex; gap: 6px; }
77
  .lang-btn { background: rgba(0,0,0,0.6); border: 1px solid #444; color: #888; padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 11px; }
78
  .lang-btn.active { background: var(--gold); color: black; font-weight: bold; border-color: var(--gold); }
79
 
80
+ /* ํ•„ํ„ฐ */
81
  .type-filter-container { width: 100%; padding: 10px 0; overflow-x: auto; display: flex; gap: 8px; justify-content: center; scrollbar-width: none; }
82
  .type-btn { padding: 8px 16px; border-radius: 20px; font-size: 11px; font-weight: bold; background: #1a1a1a; color: #777; border: 1px solid #333; white-space: nowrap; cursor: pointer; }
83
  .type-btn.selected { background: var(--gold); color: black; border-color: var(--gold); }
84
 
85
+ /* ์นด๋“œ ๋ฐ ๋ผ๋ฒจ */
86
  .place-list-container { flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; }
87
  .place-card { background: #161616; border: 1px solid #2a2a2a; border-radius: 18px; padding: 20px; margin-bottom: 15px; position: relative; }
88
+ .pc-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
89
  .pc-name { font-size: 19px; font-weight: bold; color: var(--gold); line-height: 1.2; flex: 1; }
90
 
91
+ /* [์ค‘์š”] L์—ด label ๋ฐ์ดํ„ฐ ์ „์šฉ ์Šคํƒ€์ผ */
92
  .pc-label {
93
+ font-size: 11px; padding: 4px 10px; border-radius: 10px;
94
+ background: rgba(212, 175, 55, 0.15); color: var(--gold);
95
  border: 1px solid var(--gold); font-weight: 900; white-space: nowrap;
96
  }
97
 
 
100
 
101
  .bartender-btn { position: fixed; bottom: 30%; right: 20px; width: 85px; height: 85px; border-radius: 50%; background-image: url('IMAGE_DATA'); background-size: cover; border: 3px solid var(--gold); z-index: 999; box-shadow: 0 0 20px rgba(212, 175, 55, 0.5); }
102
 
103
+ #world-map-page, #passport-page, #chat-page { background: #000; z-index: 2000; transform: translateY(100%); }
104
+ #passport-page { transform: translateX(-100%); background: #0f0f1b; }
 
105
  #detail-page { background: #0a0a0a; z-index: 4000; transform: translateX(100%); }
106
  .nav-bar { height: 60px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #222; }
107
  </style>
 
120
 
121
  <div style="text-align:center; padding: 5px 0 15px 0;">
122
  <div style="color:var(--gold); font-size: 26px; font-weight: 900; letter-spacing: 4px;">DRUNKEN PLANE</div>
123
+ <button onclick="openMap()" style="margin-top:12px; padding:12px 25px; background:var(--gold); border:none; border-radius:30px; font-weight:bold; cursor:pointer;">๐Ÿ—บ๏ธ EXPLORE WORLD MAP</button>
124
  </div>
125
 
126
  <center><select id="country-select" style="width:85%; max-width:400px; padding:12px; background:#111; border:1px solid var(--gold); color:white; border-radius:10px;" onchange="selectCountry(this.value)"></select></center>
 
130
  <div class="bartender-btn" onclick="openChat()"></div>
131
  </div>
132
 
133
+ <div id="passport-page" class="page"><div class="nav-bar"><button onclick="closePassport()">โ†</button> MY PASSPORT</div><div id="stamp-grid" class="stamp-grid" style="overflow-y:auto;"></div></div>
134
  <div id="world-map-page" class="page"><div class="nav-bar"><button onclick="closeMap()">๐Ÿ  HOME</button></div><div id="full-map" style="width:100%; height:100%;"></div></div>
135
  <div id="chat-page" class="page"><div class="nav-bar"><button onclick="closeChat()">โ†</button> Emily</div><div id="chat-messages" style="flex:1; overflow-y:auto; padding:20px;"></div></div>
136
+ <div id="detail-page" class="page"><div class="nav-bar"><button onclick="closeDetail()">โ†</button> Review</div><div id="repo-content" style="padding:20px; white-space:pre-wrap;"></div></div>
137
 
138
  <script>
139
  function b64DecodeUnicode(str) { return decodeURIComponent(atob(str).split('').map(function(c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }).join('')); }
 
156
  renderFilters();
157
  };
158
 
159
+ function setLanguage(l, el) { currentLang = l; document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active')); el.classList.add('active'); renderFilters(); renderList(); }
 
 
 
 
 
 
160
  function renderFilters() {
161
  const box = document.getElementById('filter-box'); box.innerHTML = "";
162
  const t = TRANSLATIONS[currentLang];
 
166
  box.appendChild(btn);
167
  });
168
  }
 
169
  function selectCountry(c) { selectedCountry = c; renderList(); }
170
 
171
  function renderList() {
172
  const list = document.getElementById('place-list'); list.innerHTML = "";
173
  const countryPlaces = PLACE_DB[selectedCountry] || [];
174
+ const filtered = countryPlaces.filter(p => selectedType === "All" || (p.category && p.category.includes(selectedType)));
175
  const t = TRANSLATIONS[currentLang];
176
 
177
  filtered.forEach(p => {
178
  const card = document.createElement('div'); card.className = 'place-card';
179
+ // [L์—ด label ํ•„๋“œ ์‚ฌ์šฉ] label์ด ๋น„์–ด์žˆ์œผ๋ฉด category๋ผ๋„ ๋ณด์—ฌ์ฃผ๋„๋ก ์•ˆ์ „์žฅ์น˜
180
+ const displayLabel = p.label || p.category || "";
181
+ const desc = p['desc_'+currentLang.toLowerCase()] || p.desc_ko || "Exploring alcohol heritage...";
 
182
 
183
  card.innerHTML = `
184
  <div class="pc-header">
185
  <div class="pc-name">${p.name}</div>
186
+ <div class="pc-label">${displayLabel}</div>
187
  </div>
188
  <div class="pc-desc">${desc}</div>
189
  <div style="display:flex; gap:10px; margin-top:15px;">
190
+ <button class="btn-action" style="background:var(--gold); color:black;" onclick="openReview('${p.name}', '${selectedCountry}')">${t.aiBtn}</button>
191
+ <button class="btn-action" style="background:#333; color:white;" onclick="window.open('http://googleusercontent.com/maps.google.com/4{p.name}', '_blank')">${t.mapBtn}</button>
192
  </div>`;
193
  list.appendChild(card);
194
  });
195
  }
196
 
197
+ // ์—ฌ๊ถŒ ๋ฐ ์Šคํ…œํ”„ ๋กœ์ง
198
+ function openPassport() {
199
+ document.getElementById('passport-page').style.transform = 'translateX(0%)';
200
+ const grid = document.getElementById('stamp-grid'); grid.innerHTML = "";
201
+ for(let c in PLACE_DB) {
202
+ PLACE_DB[c].forEach(p => {
203
+ const active = visitedPlaces.includes(p.name);
204
+ const div = document.createElement('div'); div.className = 'stamp' + (active ? ' active' : '');
205
+ div.innerHTML = active ? `๐Ÿท<br><b>${p.name}</b>` : `โœˆ๏ธ`;
206
+ grid.appendChild(div);
207
+ });
208
+ }
209
+ }
210
+
211
  function closePassport() { document.getElementById('passport-page').style.transform = 'translateX(-100%)'; }
212
  function openMap() { document.getElementById('world-map-page').style.transform = 'translateY(0%)'; }
213
  function closeMap() { document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }