feat: implement swiper slider, tabbed livestream, and table extension plugins with schema updates for settings content

This commit is contained in:
2026-07-25 18:26:29 +07:00
parent 0eb7bd5863
commit 54e420499f
374 changed files with 16434 additions and 495 deletions
-1
View File
@@ -3,7 +3,6 @@ import java.nio.file.Files;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.stream.Collectors;
+37
View File
@@ -0,0 +1,37 @@
import re
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/Đào tạo tại UMC.html', 'r', encoding='utf-8') as f:
html = f.read()
body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.IGNORECASE | re.DOTALL)
content = body_match.group(1) if body_match else html
# Remove header and footer
content = re.sub(r'<header.*?</header>', '', content, flags=re.IGNORECASE | re.DOTALL)
content = re.sub(r'<footer.*?</footer>', '', content, flags=re.IGNORECASE | re.DOTALL)
# Swiper 1: Gallery
# Find: <div class="relative md:flex md:items-center md:gap-x-2 plugin-swiper-slider plugin-swiper-slider-gallery"> ... </div> (or similar)
# Since the original HTML doesn't have plugin classes, let's look for btn-navigation-cap-chung-chi-prev
# Wait, the first swiper has `swiper-pagination-training-gallery`.
# Its container is `<div class="relative ...">` containing it.
# Let's replace the whole block by splitting.
def replace_block(text, marker, replacement):
# Find the block containing the marker
parts = text.split(marker)
if len(parts) > 1:
before = parts[0]
# backtrack to the nearest <div class="relative md:flex
start_idx = before.rfind('<div class="relative md:flex')
if start_idx == -1:
start_idx = before.rfind('<div class="relative')
after = parts[1]
# find the end of this div block. This is hard without a parser.
# But we can just use a regex if we know the structure.
return text
return text
# Instead of complex regex, let's just create a new dao-tao.html structure by extracting the known sections.
# Actually, the user wants the exact layout. I will write a script to just use JSDOM in Node.js to properly manipulate the DOM.
+89
View File
@@ -0,0 +1,89 @@
import re
import io
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/Đào tạo tại UMC.html', 'r', encoding='utf-8') as f:
html = f.read()
# Extract body
body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.IGNORECASE | re.DOTALL)
content = body_match.group(1) if body_match else html
# Remove header/footer
content = re.sub(r'<header.*?</header>', '', content, flags=re.IGNORECASE | re.DOTALL)
content = re.sub(r'<footer.*?</footer>', '', content, flags=re.IGNORECASE | re.DOTALL)
# Also remove script tags at the bottom to avoid conflicts
content = re.sub(r'<script.*?</script>', '', content, flags=re.IGNORECASE | re.DOTALL)
# Find swiper-wrappers and replace their content.
# Since it's all in one line, we can use regex to find `<div class="swiper-wrapper"> ... </div>` inside the swiper.
# Wait, this is dangerous because of nested divs.
# Instead, since we know there are 5 swipers in the file:
# 1. Gallery
# 2. Chứng chỉ
# 3. Giấy chứng nhận
# 4. Quá trình thực hành (xac-nhan-thuc-hanh)
# 5. Hình ảnh thực hành (thuc-hanh / training-practical)
# A safer approach is to split the content by `<div class="swiper-wrapper">`
parts = content.split('<div class="swiper-wrapper">')
if len(parts) >= 6:
new_content = parts[0]
slugs = ['gallery', 'chung-chi', 'giay-chung-nhan', 'xac-nhan-thuc-hanh', 'hinh-anh-thuc-hanh']
for i in range(1, len(parts)):
# Find the closing </div> of the swiper-wrapper.
# This is the first </div> that balances the wrapper, or since we know it's a list of <div class="swiper-slide">,
# we can just find the end of the last swiper-slide.
part = parts[i]
# We know each wrapper is closed by </div>.
# But there are nested divs.
# A simple hack: look for the end of the last slide which is followed by </div>.
# Actually, let's just find the first `</div>` that belongs to the wrapper.
# Since the slider items end, the wrapper ends with `</div>`.
# Let's count `<div` and `</div` to find the matching closing tag.
div_count = 1
pos = 0
while div_count > 0 and pos < len(part):
next_open = part.find('<div', pos)
next_close = part.find('</div', pos)
if next_close == -1:
break
if next_open != -1 and next_open < next_close:
div_count += 1
pos = next_open + 4
else:
div_count -= 1
pos = next_close + 6
slug = slugs[i-1] if (i-1) < len(slugs) else "unknown"
replacement = f"\n<th:block th:utext=\"${{@hookManager.applyFilters('swiper_slider_items', '{slug}')}}\"></th:block>\n"
new_content += '<div class="swiper-wrapper">' + replacement + part[pos:]
else:
new_content = content
print("Warning: Did not find exactly 5 swipers. Found", len(parts) - 1)
template = f"""<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{{fragments/layout(bodyClass='umass-platform-homepage path-frontpage page-node-type-homepage homepage transparent-header')}}">
<head>
<title>Đào tạo tại UMC</title>
</head>
<body>
<div layout:fragment="content">
{new_content}
</div>
</body>
</html>
"""
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_main/src/main/resources/templates/dao-tao.html', 'w', encoding='utf-8') as f:
f.write(template)
print("Created dao-tao.html successfully!")
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
View File
+1
View File
@@ -0,0 +1 @@
[{"slug": "gallery", "name": "Gallery Đào Tạo", "items": [{"title": "image-6", "imageUrl": "./Đào tạo tại UMC_files/image-6.jpeg", "linkUrl": "#", "description": ""}, {"title": "image-5", "imageUrl": "./Đào tạo tại UMC_files/image-5.jpeg", "linkUrl": "#", "description": ""}, {"title": "image-4", "imageUrl": "./Đào tạo tại UMC_files/image-4.jpeg", "linkUrl": "#", "description": ""}, {"title": "image-3", "imageUrl": "./Đào tạo tại UMC_files/image-3.jpeg", "linkUrl": "#", "description": ""}, {"title": "image-2", "imageUrl": "./Đào tạo tại UMC_files/image-2.jpeg", "linkUrl": "#", "description": ""}, {"title": "image-1", "imageUrl": "./Đào tạo tại UMC_files/image-1.jpeg", "linkUrl": "#", "description": ""}]}, {"slug": "chung-chi", "name": "Đào tạo cấp chứng chỉ", "items": [{"title": "CHƯƠNG TRÌNH CHỨNG CHỈ ĐÀO TẠO KỸ THUẬT CHUYÊN MÔN: NỘI SOI DẠ DÀY, NỘI SOI ĐẠI TRÀNG VÀ NỘI SOI ĐIỀU TRỊ CƠ BẢN, KHÓA 02", "imageUrl": "./Đào tạo tại UMC_files/N%E1%BB%98I-SOI-D%E1%BA%A0-D%C3%80Y,-N%E1%BB%98I-SOI-%C4%90%E1%BA%A0I-TR%C3%80NG-V%C3%80-N%E1%BB%98I-SOI-%C4%90I%E1%BB%80U-TR%E1%BB%8A-C%C6%.gif", "linkUrl": "#", "description": ""}, {"title": "CHƯƠNG TRÌNH CHỨNG CHỈ ĐÀO TẠO KỸ THUẬT CHUYÊN MÔN: HỒI SỨC NGOẠI THẦN KINH CƠ BẢN, KHÓA 05", "imageUrl": "./Đào tạo tại UMC_files/745940994_1567151031863709_1131070052084530832_n.jpeg", "linkUrl": "#", "description": ""}]}, {"slug": "giay-chung-nhan", "name": "Đào tạo cấp giấy chứng nhận", "items": [{"title": "Lớp: PHẪU THUẬT NỘI SOI CẮT DẠ DÀY", "imageUrl": "./Đào tạo tại UMC_files/PTNS2707.jpeg", "linkUrl": "#", "description": ""}, {"title": "Lớp: ĐIỀU DƯỠNG DỤNG CỤ TRONG PHẪU THUẬT (MỔ MỞ) NÂNG CAO", "imageUrl": "./Đào tạo tại UMC_files/DD%2003-14.jpeg", "linkUrl": "#", "description": ""}, {"title": "Lớp: ĐIỀU DƯỠNG, KỸ THUẬT Y TRONG THỰC HÀNH LÂM SÀNG BỆNH LÝ SA SÚT TRÍ TUỆ, KHÓA 01", "imageUrl": "./Đào tạo tại UMC_files/chieusinhdieuduong-0308.gif", "linkUrl": "#", "description": ""}]}, {"slug": "xac-nhan-thuc-hanh", "name": "Xác nhận quá trình thực hành", "items": [{"title": "Chương trình thực hành 12 tháng Bác sĩ y khoa", "imageUrl": "./Đào tạo tại UMC_files/CT_Thuc%20hanh%2012%20thang_13122025.jpeg", "linkUrl": "#", "description": ""}, {"title": "Chương trình thực hành lâm sàng cho Hộ sinh", "imageUrl": "./Đào tạo tại UMC_files/Avatar%20Ho%20sinh%206M.png", "linkUrl": "#", "description": ""}, {"title": "Chương trình thực hành 06 tháng để cấp giấy phép hành nghề khám bệnh, chữa bệnh đối với chức danh Kỹ thuật y năm 2026", "imageUrl": "./Đào tạo tại UMC_files/Ky-thuat-y-6-thang_15042025.jpeg", "linkUrl": "#", "description": ""}, {"title": "Chương trình đào tạo thực hành lâm sàng cho điều dưỡng", "imageUrl": "./Đào tạo tại UMC_files/Avatar%20Dieu%20duong%206M.jpeg", "linkUrl": "#", "description": ""}]}, {"slug": "hinh-anh-thuc-hanh", "name": "Hình ảnh thực hành", "items": [{"title": "training 3", "imageUrl": "./Đào tạo tại UMC_files/training-3.jpeg", "linkUrl": "#", "description": ""}, {"title": "training 4", "imageUrl": "./Đào tạo tại UMC_files/training-4.jpeg", "linkUrl": "#", "description": ""}]}]
+59
View File
@@ -0,0 +1,59 @@
import re
import json
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/Đào tạo tại UMC.html', 'r', encoding='utf-8') as f:
html = f.read()
parts = html.split('<div class="swiper-wrapper">')
groups = []
slugs = ['gallery', 'chung-chi', 'giay-chung-nhan', 'xac-nhan-thuc-hanh', 'hinh-anh-thuc-hanh']
names = ['Gallery Đào Tạo', 'Đào tạo cấp chứng chỉ', 'Đào tạo cấp giấy chứng nhận', 'Xác nhận quá trình thực hành', 'Hình ảnh thực hành']
for i in range(1, len(parts)):
part = parts[i]
slug = slugs[i-1] if (i-1) < len(slugs) else f"unknown-{i}"
name = names[i-1] if (i-1) < len(names) else f"Unknown {i}"
# We only care about the slides for this swiper.
# The swiper ends with `<div class="swiper-pagination` or `btn-navigation` or `</section>`
# We can just extract all `<div class="swiper-slide` up to the end of the wrapper.
# Since we can't easily parse DOM, we'll just extract all <img> tags inside `swiper-slide` that appear before the next wrapper.
# Actually, we can split by `swiper-slide`
slides_html = part.split('class="swiper-slide')
items = []
for j in range(1, len(slides_html)):
slide = slides_html[j]
# find image
img_match = re.search(r'<img[^>]*src="([^"]+)"', slide)
img_url = img_match.group(1) if img_match else ""
# find title - it's usually inside <h3...> or just alt text.
# Let's check heading-5
title_match = re.search(r'<h3[^>]*>(.*?)</h3>', slide, re.IGNORECASE | re.DOTALL)
if title_match:
title = re.sub(r'<[^>]+>', '', title_match.group(1)).strip()
else:
alt_match = re.search(r'<img[^>]*alt="([^"]*)"', slide)
title = alt_match.group(1) if alt_match else ""
items.append({
"title": title,
"imageUrl": img_url,
"linkUrl": "#",
"description": ""
})
# Filter empty
items = [it for it in items if it['imageUrl']]
groups.append({
"slug": slug,
"name": name,
"items": items
})
print(json.dumps(groups, ensure_ascii=False))
+30
View File
@@ -0,0 +1,30 @@
import json
with open('data.json', 'r', encoding='utf-8') as f:
data = json.load(f)
# Fix image urls
for group in data:
for item in group['items']:
if item['imageUrl'].startswith('./'):
item['imageUrl'] = '/' + item['imageUrl'][2:]
json_str = json.dumps(data, ensure_ascii=False)
escaped_json = json_str.replace('"', '\\"')
java_file = '/home/x79/sisvietnamvn_01/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/plugins/swiperslider/SwiperSliderPlugin.java'
with open(java_file, 'r', encoding='utf-8') as f:
content = f.read()
# Replace the sample data string
import re
new_content = re.sub(
r'String sampleData = "[^"]+";',
f'String sampleData = "{escaped_json}";',
content
)
with open(java_file, 'w', encoding='utf-8') as f:
f.write(new_content)
print("Injected JSON into Java plugin.")
+21
View File
@@ -0,0 +1,21 @@
import re
import json
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/Đào tạo tại UMC.html', 'r', encoding='utf-8') as f:
html = f.read()
# Try to extract the main content. It's usually inside <div id="content"> or <main>
# Looking at typical Tailwind pages, let's extract everything inside <body> </body>
body_match = re.search(r'<body[^>]*>(.*)</body>', html, re.IGNORECASE | re.DOTALL)
if body_match:
content = body_match.group(1)
else:
content = html
# We know there are 4 Swiper instances. Let's find them.
# A swiper usually has `<div class="swiper swiper-initialized ..."> ... </div>`
# It's a bit tricky to parse nested divs with regex.
# Let's extract the slider images using regex on `swiper-slide`
slides = re.findall(r'<div class="swiper-slide[^>]*>.*?<img[^>]*src="([^"]+)"[^>]*>.*?</div>', html, re.IGNORECASE | re.DOTALL)
print(f"Found {len(slides)} slides with images.")
+26
View File
@@ -0,0 +1,26 @@
import re
import json
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/Đào tạo tại UMC.html', 'r', encoding='utf-8') as f:
html = f.read()
# 1. Extract <body> content
body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.IGNORECASE | re.DOTALL)
if body_match:
body_content = body_match.group(1)
else:
body_content = html
# We will replace the whole div that contains the swiper.
# Looking at standard Swiper HTML:
# <div class="relative md:flex md:items-center md:gap-x-2..."> ... </div>
# or something similar.
# Since we just want to replace the Swiper Sliders, let's find the container block.
# Actually, the user has 4 Swiper Sliders. We can just find the `<div class="swiper swiper-initialized ..."` and replace its parent block.
# To be safe, let's just find the `swiper` divs and extract their data.
slides_data = []
# This is a bit complex without BeautifulSoup. I'll just use a basic string split approach.
parts = html.split('class="swiper swiper-initialized')
print(f"Found {len(parts)} parts")