commit e04ea1dd27fd7b230e22344d0e1d09c7d85c437a Author: kunthawat Date: Thu Aug 6 13:50:48 2026 +0700 Mirror www.mitsuthailand.com as static site with dynamic URLs - Full static mirror of the YellowPages/Drupal site (39 pages + all assets) - All URLs rewritten to relative/domain-agnostic form (works on any domain) - RFQ + request-quotation + contact forms converted to email (FormSubmit.co) - Google Maps embed replaced with static Google Maps iframe - nginx Dockerfile + config for EasyPanel deployment - mirror.py/rewrite.py/cleanup.py tooling for re-crawling updates diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81c1452 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.pyc +mirror_log*.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c10529 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Static mirror of www.mitsuthailand.com (บริษัท มิตซูชัยพร จำกัด ศูนย์มิตซูบิชิ สมุทรสาคร) +# Serves the mirrored static site with nginx. +# Host: lightweight, no backend. Works on any domain (all URLs are relative). + +FROM nginx:1.27-alpine + +# Remove default nginx site +RUN rm -rf /usr/share/nginx/html/* + +# Copy the mirrored static site +COPY site/ /usr/share/nginx/html/ + +# Custom nginx config: SPA-style clean URLs handled by directory/index.html, +# plus reasonable caching for assets. +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ + CMD wget -q -O /dev/null http://localhost/ || exit 1 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..0765b4b --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# มิตซูชัยพร สมุทรสาคร — เว็บไซต์สแตติก (Static Site) + +เว็บโคลนของ **www.mitsuthailand.com** (บริษัท มิตซูชัยพร จำกัด ศูนย์มิตซูบิชิ สมุทรสาคร) +สร้างเป็น **static site** เพื่อย้ายออกจาก host เดิม (YellowPages / Drupal) ที่จะหมดอายุ +โดย **โหลดโค้ด + รูปภาพทั้งหมดไว้ในเครื่องแล้ว** และปรับ URL ให้เป็น **relative / dynamic** +เพื่อเปลี่ยนโดเมนได้โดยไม่ต้องแก้ไฟล์ + +--- + +## 📁 โครงสร้าง + +``` +. +├── site/ ← ตัวเว็บที่พร้อม deploy (static) +│ ├── index.html ← หน้าแรก +│ ├── catalog/ ← รายการสินค้า (item), แบรนด์ (brand), keyword +│ ├── contactus/ about-us/ footer/ rfq/ ← หน้าติดต่อ/ฟอร์ม +│ ├── sites/ ← CSS/JS/รูป (mirror โครงสร้างเดิม) +│ └── assets/external/ ← รูปจาก media.yellowpages.co.th (โหลดมาแล้ว) +├── Dockerfile ← ใช้ deploy บน EasyPanel/Docker (nginx) +├── nginx.conf ← config nginx (serve static, cache assets) +├── mirror.py common.py rewrite.py ← ตัว crawl + rewrite (ใช้ใหม่เมื่ออยาก update) +└── repair.py ← ซ่อม path อ้างอิงหลัง crawl +``` + +## 🚀 Deploy (Docker / EasyPanel) + +Build image แล้วชี้ port 80: + +```bash +docker build -t mitsu-chaiyaporn . +docker run -d -p 8080:80 mitsu-chaiyaporn +``` + +บน EasyPanel: สร้าง Service แบบ Dockerfile → ใส่ path ของ repo นี้ → เลือก `Dockerfile` +→ deploy ได้เลย (nginx เซิร์ฟ static ใน `/usr/share/nginx/html`) + +**เปลี่ยนโดเมนได้เลย** — ทุก URL ใน `site/` เป็น relative path ทั้งหมด ไม่มีโดเมนตายตัว +(ยกเว้นลิงก์ภายนอก เช่น Line/Facebook/Google Maps ที่ตั้งใจชี้ไปภายนอก) + +--- + +## ✉️ ฟอร์มส่งอีเมล + +เดิมฟอร์มขอใบเสนอราคา (RFQ) / ติดต่อ ส่งข้อมูลไปยังหลังบ้าน Drupal ที่จะตายพร้อม host เก่า +จึงแปลงให้ส่งเป็น **อีเมล** ผ่าน [FormSubmit.co](https://formsubmit.co) (ไม่ต้องมี backend): + +- ตัวรับเมล: ตั้งค่าได้ใน `rewrite.py` → `FORM_RECIPIENT` + ```python + FORM_RECIPIENT = "mail@mitsuchaiyaporn.com" # ← เปลี่ยนเป็นอีเมลที่ต้องการรับ + ``` +- หลังแก้ ต้อง**ยืนยันอีเมล**ครั้งแรกที่ formsubmit.co (กดลิงก์ที่ส่งไป) ฟอร์มถึงใช้งานได้ +- เปลี่ยนแล้ว re-deploy (หรือรัน `rewrite` ใหม่) ก็พอ + +--- + +## 🔄 Update เว็บใหม่ (เมื่อเนื้อหาบนเว็บเดิมเปลี่ยน) + +1. รัน mirror ใหม่ (โหลดหน้า + asset ล่าสุด): + ```bash + PYTHONPATH= python3 mirror.py + PYTHONPATH= python3 repair.py + ``` +2. ตรวจ path อ้างอิง (`repair.py` จะแก้ชื่อไฟล์ที่เผื่อไว้เอง) +3. Commit + push ขึ้น Gitea → deploy + +> หมายเหตุ: ทำได้เฉพาะตอนต้นทาง (www.mitsuthailand.com) ยังออนไลน์อยู่ + +--- + +## ⚠️ สิ่งที่โคลนแล้ว "ใช้ไม่ได้" เหมือนเดิม + +- **Google Maps embed** ในหน้าติดต่อ อ้างอิง API ของ YellowPages ที่จะตาย — แนะนำแทนที่ + ด้วย iframe Google Maps จริง (พิกัด 13.557229, 100.289162) +- **ฟอร์ม RFQ/contact** ไม่ได้ส่งเข้าหลังบ้าน Drupal แล้ว แต่ส่งเป็นอีเมลแทน (ข้างบน) +- ลิงก์ `/lp/...` (preview สำเนา) ถูกตัดทิ้ง เนื่องจากซ้ำกับหน้าเดิม + +## 🔑 ข้อมูลติดต่อ (คงไว้จากเว็บเดิม) + +- โทร: 034-836-738 ต่อ 9 / 034-422-230 +- Line ID: @823bhcbq +- Facebook: facebook.com/mitsuchaiyaporn +- ที่อยู่: 923/249 ถนนเอกชัย ตำบลมหาชัย อำเภอเมืองสมุทรสาคร สมุทรสาคร 74000 +- เปิดบริการ: ศูนย์บริการ จ-ส 08:00-17:00 / ฝ่ายขาย ทุกวัน 08:00-17:00 diff --git a/cleanup.py b/cleanup.py new file mode 100644 index 0000000..1cb55e4 --- /dev/null +++ b/cleanup.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python3 +""" +Final cleanup pass: + 1. Convert all still-backend forms (request-quotation forms posting to dead /lp/ + or mitsuthailand backend) to FormSubmit email submission. + 2. Replace the dying YellowPages googlemap embed with a proper Google Maps iframe. + 3. Neutralize dead /lp/www.mitsuthailand.com/... back-links to the local page (or home). +""" +import os, re, sys, urllib.parse + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from common import OUT_DIR, BASE_HOST + +FORM_RECIPIENT = "mail@mitsuchaiyaporn.com" # keep in sync with rewrite.py +MAP_COORDS = "13.557229094780995,100.28916297408983" + + +def convert_forms(html): + """Rewrite any
whose action points at a dead backend (not local search, + not already-formsubmit, not empty) to FormSubmit.""" + def repl(m): + open_tag, inner, close = m.group(1), m.group(2), m.group(3) + am = re.search(r'action="([^"]*)"', open_tag) + if not am: + return m.group(0) + action = am.group(1) + low = action.lower() + # skip local search form and already-converted + if "/catalog/search" in low: + return m.group(0) + if "formsubmit" in low or low.startswith(("http", "//")) and "mitsuthailand" not in low and "lp/" not in low: + # only convert ones pointing at dead host + pass + if "formsubmit" in low: + return m.group(0) + # Anything still pointing at mitsuthailand backend or /lp/ -> email form + new_open = '' + hidden = ('' + '' + '') + # ensure a submit button exists (append one if the form has none) + if "