import os import re path = r'z:\source\forgejo\spotnotes.app\static\assets\js\map.js' with open(path, 'r', encoding='utf-8') as f: content = f.read() new_render = """ const shareToken = note.share_token || ''; const shareBtn = ``; const dateStr = new Date(note.created_at).toLocaleString(); const padColor = (note.notepad && note.notepad.color) ? note.notepad.color : '#3388ff'; const directionsBtn = `πŸ—ΊοΈ Directions`; if (showFull) { const icon = L.divIcon({ className: '', html: `
${window.SpotNotes.escapeHtml(note.title)}
${window.SpotNotes.escapeHtml(note.content)}
${dateStr}
${directionsBtn} ${shareBtn} ${actionBtns}
`, iconSize: [200, 'auto'], iconAnchor: [100, 0] }); marker = L.marker([note.lat, note.lng], { icon: icon }); } else { const svgIcon = L.divIcon({ className: 'custom-div-icon', html: `
`, iconSize: [20, 20], iconAnchor: [10, 10], popupAnchor: [0, -10] }); marker = L.marker([note.lat, note.lng], { icon: svgIcon }); marker.bindPopup(`${window.SpotNotes.escapeHtml(note.title)}
${window.SpotNotes.escapeHtml(note.content)}
${dateStr}
${directionsBtn} ${shareBtn} ${actionBtns}`); }""" # Extract old chunk to replace old_chunk_start = "const shareToken = note.share_token || '';" old_chunk_end = "marker.bindPopup(`${window.SpotNotes.escapeHtml(note.title)}
${window.SpotNotes.escapeHtml(note.content)}
${dateStr}
${directionsBtn} ${shareBtn} ${actionBtns}`);\n }" pattern = re.escape(old_chunk_start) + r'.*?' + re.escape(old_chunk_end) content = re.sub(pattern, new_render, content, flags=re.DOTALL) with open(path, 'w', encoding='utf-8') as f: f.write(content) print('Marker logic updated with colors.')