Some checks failed
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml) - 部署模式: rsync Python 檔案至 188 → docker restart (volume mount) - Dockerfile/requirements 變動時自動重建 Docker image - 部署通知: Telegram (開始/成功/失敗) - 健康檢查: https://mo.wooo.work/health (最多 5 次重試) - 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
137 lines
4.1 KiB
Python
137 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
將導航列改為藍色調主題
|
|
"""
|
|
import os
|
|
import re
|
|
from pathlib import Path
|
|
|
|
def apply_blue_navbar(file_path):
|
|
"""將導航列改為藍色調主題"""
|
|
try:
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
original_content = content
|
|
|
|
# 將黑色導航列改為藍色主題(使用 navbar-dark 配合自定義背景)
|
|
content = re.sub(
|
|
r'<nav class="navbar navbar-expand-xl navbar-dark bg-dark([^"]*)"',
|
|
r'<nav class="navbar navbar-expand-xl navbar-dark bg-primary\1"',
|
|
content
|
|
)
|
|
|
|
# 檢查是否已經有導航列的自定義樣式
|
|
if 'navbar-dark.bg-primary' not in content and '.navbar {' in content:
|
|
# 在第一個 .navbar { 之前添加藍色主題樣式
|
|
blue_navbar_style = """ /* Blue Navbar Theme */
|
|
.navbar-dark.bg-primary {
|
|
background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%) !important;
|
|
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
|
|
}
|
|
|
|
.navbar-dark .navbar-brand {
|
|
color: #ffffff !important;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link {
|
|
color: rgba(255, 255, 255, 0.9) !important;
|
|
font-weight: 500;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link:hover {
|
|
color: #ffffff !important;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link.active {
|
|
color: #ffffff !important;
|
|
background: rgba(255, 255, 255, 0.15);
|
|
border-radius: 6px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar-dark .navbar-text {
|
|
color: rgba(255, 255, 255, 0.8) !important;
|
|
}
|
|
|
|
"""
|
|
# 在第一個 .navbar { 之前插入
|
|
content = content.replace(' .navbar {', blue_navbar_style + ' .navbar {', 1)
|
|
elif 'navbar-dark.bg-primary' not in content:
|
|
# 如果沒有 .navbar { 則在 </style> 之前添加
|
|
blue_navbar_style = """
|
|
/* Blue Navbar Theme */
|
|
.navbar-dark.bg-primary {
|
|
background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%) !important;
|
|
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
|
|
}
|
|
|
|
.navbar-dark .navbar-brand {
|
|
color: #ffffff !important;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link {
|
|
color: rgba(255, 255, 255, 0.9) !important;
|
|
font-weight: 500;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link:hover {
|
|
color: #ffffff !important;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link.active {
|
|
color: #ffffff !important;
|
|
background: rgba(255, 255, 255, 0.15);
|
|
border-radius: 6px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar-dark .navbar-text {
|
|
color: rgba(255, 255, 255, 0.8) !important;
|
|
}
|
|
"""
|
|
content = content.replace('</style>', blue_navbar_style + ' </style>')
|
|
|
|
# 只有內容改變時才寫入
|
|
if content != original_content:
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
return True
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"處理 {file_path} 時發生錯誤: {e}")
|
|
return False
|
|
|
|
def main():
|
|
"""主程序"""
|
|
base_dir = Path(__file__).parent
|
|
html_files = list(base_dir.glob("*.html"))
|
|
|
|
updated_count = 0
|
|
|
|
print(f"找到 {len(html_files)} 個 HTML 文件")
|
|
print("=" * 60)
|
|
|
|
for html_file in html_files:
|
|
if apply_blue_navbar(html_file):
|
|
print(f"✅ 已更新: {html_file.name}")
|
|
updated_count += 1
|
|
else:
|
|
print(f"⏭️ 跳過: {html_file.name}")
|
|
|
|
print("=" * 60)
|
|
print(f"✅ 完成!共更新 {updated_count} 個文件為藍色主題")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|