Remove accidentally committed python scripts
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
import os
|
||||
|
||||
files = ['kemiskinan.html', 'spbu.html', 'jalan.html', 'persil.html']
|
||||
tabs = ['kemiskinan', 'spbu', 'jalan', 'persil']
|
||||
|
||||
old_nav = ''' <div class="nav-tabs" role="tablist" aria-label="Fitur utama">
|
||||
<button class="nav-tab active" onclick="switchTab('kemiskinan')">Kemiskinan</button>
|
||||
<button class="nav-tab" onclick="switchTab('spbu')">SPBU</button>
|
||||
<button class="nav-tab" onclick="switchTab('jalan')">Jalan</button>
|
||||
<button class="nav-tab" onclick="switchTab('persil')">Persil</button>
|
||||
</div>'''
|
||||
|
||||
for file, active_tab in zip(files, tabs):
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
new_nav_lines = [' <div class="nav-tabs" role="tablist" aria-label="Fitur utama">']
|
||||
labels = ['Kemiskinan', 'SPBU', 'Jalan', 'Persil']
|
||||
for t, l in zip(tabs, labels):
|
||||
cls = 'nav-tab active' if t == active_tab else 'nav-tab'
|
||||
new_nav_lines.append(f' <a href="{t}.html" style="text-decoration: none;" class="{cls}">{l}</a>')
|
||||
new_nav_lines.append(' </div>')
|
||||
new_nav = '\n'.join(new_nav_lines)
|
||||
|
||||
content = content.replace(old_nav, new_nav)
|
||||
|
||||
old_init = '''<script>
|
||||
renderPanel('kemiskinan');
|
||||
preloadFeatureLayers();
|
||||
</script>'''
|
||||
new_init = f'''<script>
|
||||
initPage('{active_tab}');
|
||||
</script>'''
|
||||
content = content.replace(old_init, new_init)
|
||||
|
||||
content = content.replace('<div class="brand-title">WebGIS Poverty</div>', '<a href="index.html" style="text-decoration:none; color:inherit"><div class="brand-title">WebGIS Poverty</div></a>')
|
||||
|
||||
with open(file, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
@@ -1,28 +0,0 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
files = ['kemiskinan.html', 'spbu.html', 'jalan.html', 'persil.html']
|
||||
|
||||
for file in files:
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 1. Remove nav-tabs block
|
||||
# Use regex to find and remove the div with class="nav-tabs" and its contents
|
||||
nav_tabs_pattern = re.compile(r'<div class="nav-tabs"[^>]*>.*?</div>', re.DOTALL)
|
||||
content = nav_tabs_pattern.sub('', content)
|
||||
|
||||
# 2. Add back button in panel-head
|
||||
panel_head_str = '<div id="panel-head">\n <h2 id="panel-title">'
|
||||
back_btn_html = '''<div id="panel-head">
|
||||
<a href="index.html" class="btn btn-ghost btn-sm" style="margin-bottom: 12px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none;">
|
||||
<span style="font-size: 14px;">←</span> Kembali ke Beranda
|
||||
</a>
|
||||
<h2 id="panel-title">'''
|
||||
|
||||
# Only replace if not already replaced
|
||||
if 'Kembali ke Beranda' not in content:
|
||||
content = content.replace(panel_head_str, back_btn_html)
|
||||
|
||||
with open(file, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
Reference in New Issue
Block a user