import os path = "core/templates/core/project_detail.html" with open(path, "r") as f: html = f.read() # 1. Add top bar buttons (Layout, Zoom, etc) buttons_to_add = """
""" html = html.replace('', buttons_to_add + '\n ') # 2. Add emoji logic emoji_script = """ const categoryEmojis = { 'Strategy': '🎯', 'Product': '📦', 'Market': '🌍', 'Operations': '⚙️', 'Finance': '💰', 'General': '💡' }; function getNodeEmoji(category) { let cat = category || 'General'; for (let key in categoryEmojis) { if (cat.toLowerCase().includes(key.toLowerCase())) { return categoryEmojis[key]; } } return '💡'; // default emoji } """ html = html.replace('function getNodeColor(category) {', emoji_script + '\n function getNodeColor(category) {') # update node array to include emoji html = html.replace('label: "{{ node.title|escapejs }}",', 'label: getNodeEmoji("{{ node.category|escapejs }}") + " " + "{{ node.title|escapejs }}",') # 3. Add script functions for zoom and layout scripts_to_add = """ function zoomIn() { if (network) { const scale = network.getScale() * 1.5; network.moveTo({ scale: scale, animation: { duration: 300, easingFunction: 'easeInOutQuad' } }); } } function zoomOut() { if (network) { const scale = network.getScale() / 1.5; network.moveTo({ scale: scale, animation: { duration: 300, easingFunction: 'easeInOutQuad' } }); } } function changeLayout(layoutType) { if (layoutType === 'hierarchical') { network.setOptions({ layout: { hierarchical: { enabled: true, direction: 'UD', sortMethod: 'directed', nodeSpacing: 200, levelSeparation: 150 } }, physics: { hierarchicalRepulsion: { nodeDistance: 200 } } }); } else { network.setOptions({ layout: { hierarchical: { enabled: false } }, physics: { solver: 'forceAtlas2Based', forceAtlas2Based: { gravitationalConstant: -100, centralGravity: 0.01, springLength: 150, springConstant: 0.08 }, maxVelocity: 50, minVelocity: 0.1, timestep: 0.5, stabilization: { iterations: 150 } } }); } } """ hTml = html.replace('// Export Map function', scripts_to_add + '\n // Export Map function') with open(path, "w") as f: f.write(html) print("Updated HTML!")