feat: implement page/post duplication, add event layout, auto-extract featured images, and include HTML escaping for templates.

This commit is contained in:
2026-07-14 09:08:09 +07:00
parent 5513448738
commit 1b905d8c60
23 changed files with 522 additions and 123 deletions
+33
View File
@@ -0,0 +1,33 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FixPosts {
public static void main(String[] args) {
try {
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/sisvietnam", "sisvietnam", "sisvietnam");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT id, content FROM sis_post WHERE featured_image IS NULL");
Pattern p = Pattern.compile("<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>");
int count = 0;
while (rs.next()) {
String content = rs.getString("content");
if (content != null) {
Matcher m = p.matcher(content);
if (m.find()) {
String imgUrl = m.group(1);
Statement updateStmt = conn.createStatement();
updateStmt.executeUpdate("UPDATE sis_post SET featured_image = '" + imgUrl + "' WHERE id = " + rs.getLong("id"));
count++;
}
}
}
System.out.println("Updated " + count + " posts with featured images from content.");
} catch (Exception e) {
e.printStackTrace();
}
}
}