diff --git a/sisvietnamvn_main/fix_html.py b/sisvietnamvn_main/fix_html.py
new file mode 100644
index 00000000..ec6bfd65
--- /dev/null
+++ b/sisvietnamvn_main/fix_html.py
@@ -0,0 +1,103 @@
+import os
+import re
+
+script_replacement = """
+ """
+
+files = [
+ 'src/main/resources/templates/posts/full-width.html',
+ 'src/main/resources/templates/posts/livestream.html',
+ 'src/main/resources/templates/posts/sidebar.html'
+]
+
+for file_path in files:
+ with open(file_path, 'r') as f:
+ content = f.read()
+
+ # Regex to match the old Editor.js script block
+ pattern = re.compile(r'
+ """
+
+file_path = 'src/main/resources/templates/dao-tao-detail.html'
+with open(file_path, 'r') as f:
+ content = f.read()
+
+# Pattern matches from to the end of the
\ No newline at end of file
+
TT
Tên bài
Mục tiêu bài học
Số tiết học
Tổn g số
Lý thuyế t
Thực hành
Lab
Buồn g bệnh
01
Bức xạ tia x
- Trình bày được đơn vị đo bức xạ tia X, thực hiện đúng quy định kỹ thuật an toàn bức xạ tia X. - Mô tả chính xác phương pháp đo bức xạ tia X.
12
02
10
02
Nguyên lý tạo hình ảnh trên dsa và an toàn bức xạ tia x
- Mô tả được nguyên lý tạo hình ảnh trên DSA. - Vận dụng được các nguyên tắc an toàn bức xạ tia X.
22
02
20
03
Thuốc cản quang trong can thiệp nội mạch
- Phân biệt được các nhóm thuốc cản quang hiện nay. - Áp dụng đúng liều lượng thuốc cản quang trong can thiệp nội mạch, các phản ứng bất lợi của thuốc cản quang và xử trí.
22
02
20
04
Bệnh thận do thuốc cản quang
- Trình bày tiêu chuẩn chẩn đoán của bệnh thận do thuốc cản quang (CIN) - Giải thích chính xác cơ chế bệnh sinh của CIN Đánh giá được nguy cơ và xây dựng cách phòng ngừa CIN.
42
02
20
20
05
Hình ảnh Giải phẫu học của gan
- Trình bày được giải phẩu các phân thùy gan, các cấu trúc cố định gan và liên quan của gan với các tạng xung quanh.
24
04
20
\ No newline at end of file
diff --git a/sisvietnamvn_main/sisvietnam_backup.dmp b/sisvietnamvn_main/sisvietnam_backup.dmp
index de2438f1..10af5d30 100644
Binary files a/sisvietnamvn_main/sisvietnam_backup.dmp and b/sisvietnamvn_main/sisvietnam_backup.dmp differ
diff --git a/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/config/PostMigrator.java b/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/config/PostMigrator.java
index 88b6f998..ccf2c128 100644
--- a/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/config/PostMigrator.java
+++ b/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/config/PostMigrator.java
@@ -1,16 +1,12 @@
package com.sisvietnamvn.web.config;
import com.sisvietnamvn.web.domain.Post;
-import com.sisvietnamvn.web.domain.PageStatus;
import com.sisvietnamvn.web.repository.PostRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
-import java.util.Optional;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
+import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.JsonNode;
@Component
public class PostMigrator implements CommandLineRunner {
@@ -23,57 +19,110 @@ public class PostMigrator implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
- String[] slugs = {
- "can-thiep-mach-mau-than-kinh-nang-cao",
- "can-thiep-mach-mau-cac-tang-va-ngoai-bien-co-ban",
- "chuan-bi-dung-cu-va-cham-soc-benh-nhan-trong-phong-chup-mach",
- "tim-mach-can-thiep-co-ban"
- };
+ System.out.println("=== STARTING JSON TO HTML MIGRATION ===");
- String[] titles = {
- "Can thiệp mạch máu thần kinh nâng cao",
- "Can thiệp mạch máu các tạng và mạch máu ngoại biên cơ bản",
- "Chuẩn bị dụng cụ và chăm sóc bệnh nhân trong phòng chụp mạch",
- "Tim mạch can thiệp cơ bản"
- };
+ List posts = postRepository.findAll();
+ ObjectMapper mapper = new ObjectMapper();
+ int count = 0;
- System.out.println("=== STARTING MIGRATION FOR 4 COURSES ===");
-
- for (int i = 0; i < slugs.length; i++) {
- String slug = slugs[i];
- String title = titles[i];
- String path = "pdf_json_output/" + slug + ".json";
-
- if (!Files.exists(Paths.get(path))) {
- System.out.println("File not found: " + path);
- continue;
+ for (Post post : posts) {
+ String content = post.getContent();
+ if (content != null && content.trim().startsWith("{") && content.contains("\"blocks\"")) {
+ System.out.println("Migrating post: " + post.getTitle());
+ String html = convertEditorJsToHtml(content, mapper);
+ post.setContent(html);
+ postRepository.save(post);
+ count++;
}
-
- String json = new String(Files.readAllBytes(Paths.get(path)));
-
- Optional opt = postRepository.findBySlug(slug);
- Post post;
- if (opt.isPresent()) {
- post = opt.get();
- System.out.println("Updating post: " + post.getTitle());
- } else {
- System.out.println("Creating new post: " + title);
- post = new Post();
- post.setSlug(slug);
- post.setTitle(title);
- post.setStatus(PageStatus.PUBLISHED);
- post.setCreatedDate(Instant.now());
- post.setLastModifiedDate(Instant.now());
- post.setCreatedBy("admin");
- post.setLastModifiedBy("admin");
- post.setExcerpt("Khóa học " + title + " tại Bệnh viện Đa khoa Quốc tế S.I.S Cần Thơ.");
- post.setEventTime(Instant.now().plus(30 + i * 10, ChronoUnit.DAYS)); // dummy start date
- }
-
- post.setContent(json);
- postRepository.save(post);
}
- System.out.println("=== SUCCESSFULLY MIGRATED 4 COURSES ===");
+ System.out.println("=== SUCCESSFULLY MIGRATED " + count + " POSTS TO HTML ===");
+ }
+
+ private String convertEditorJsToHtml(String json, ObjectMapper mapper) {
+ try {
+ JsonNode root = mapper.readTree(json);
+ JsonNode blocks = root.get("blocks");
+ if (blocks == null || !blocks.isArray()) return json;
+
+ StringBuilder html = new StringBuilder();
+
+ for (JsonNode block : blocks) {
+ String type = block.get("type").asText();
+ JsonNode data = block.get("data");
+
+ switch(type) {
+ case "header":
+ int level = data.has("level") ? data.get("level").asInt() : 2;
+ String text = data.has("text") ? data.get("text").asText() : "";
+ html.append("").append(text).append("\n");
+ break;
+ case "paragraph":
+ String ptext = data.has("text") ? data.get("text").asText() : "";
+ html.append("
\n");
+ break;
+ case "raw":
+ String rtext = data.has("html") ? data.get("html").asText() : "";
+ html.append(rtext).append("\n");
+ break;
+ case "tabStart":
+ String ttitle = data.has("title") ? data.get("title").asText() : "Tab";
+ // Use a special class so frontend can parse it back into tabs if needed
+ html.append("