118 lines
5.7 KiB
Java
118 lines
5.7 KiB
Java
import java.sql.Connection;
|
|
import java.sql.DriverManager;
|
|
import java.sql.PreparedStatement;
|
|
|
|
public class UpdateLivestreamTemplate7 {
|
|
public static void main(String[] args) {
|
|
try {
|
|
Class.forName("oracle.jdbc.OracleDriver");
|
|
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/sisvietnam", "sisvietnam", "sisvietnam");
|
|
|
|
String htmlTemplate =
|
|
"<style>\n" +
|
|
"/* ── Livestream Section ── */\n" +
|
|
".ls-section { background: #f5f5f5; padding: 40px 0; }\n" +
|
|
".ls-wrapper { max-width: 1200px; margin: 0 auto; display: flex; gap: 0; border-left: 5px solid #c0272d; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.07); border-radius: 6px; overflow: hidden; }\n" +
|
|
"\n" +
|
|
"/* Left column */\n" +
|
|
".ls-left { flex: 0 0 40%; max-width: 40%; padding: 36px 32px 32px 32px; display: flex; flex-direction: column; }\n" +
|
|
".ls-heading { font-size: 22px; font-weight: 800; color: #111; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 20px; font-family: 'Inter', 'Segoe UI', sans-serif; }\n" +
|
|
"\n" +
|
|
"/* Tabs */\n" +
|
|
".ls-tabs { display: flex; gap: 0; border-bottom: 2px solid #e0e0e0; margin-bottom: 24px; }\n" +
|
|
".ls-tab { padding: 8px 18px; font-size: 14px; font-weight: 600; color: #666; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s; text-decoration: none; white-space: nowrap; }\n" +
|
|
".ls-tab:hover { color: #c0272d; }\n" +
|
|
".ls-tab.active { color: #c0272d; border-bottom-color: #c0272d; }\n" +
|
|
"\n" +
|
|
"/* Tab panels */\n" +
|
|
".ls-panel { display: none; flex-direction: column; flex: 1; }\n" +
|
|
".ls-panel.active { display: flex; }\n" +
|
|
".ls-panel-title { font-size: 18px; font-weight: 700; color: #222; margin-bottom: 14px; line-height: 1.4; }\n" +
|
|
".ls-panel-desc { font-size: 14px; color: #555; line-height: 1.7; margin-bottom: 24px; flex: 1; }\n" +
|
|
".ls-btn { display: inline-block; padding: 10px 24px; background: #c0272d; color: #fff; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 4px; text-decoration: none; transition: background 0.2s; align-self: flex-start; }\n" +
|
|
".ls-btn:hover { background: #a01f24; }\n" +
|
|
"\n" +
|
|
"/* Right column — poster image */\n" +
|
|
".ls-right { flex: 1; min-height: 360px; position: relative; overflow: hidden; }\n" +
|
|
".ls-poster { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }\n" +
|
|
".ls-poster.active { display: block; }\n" +
|
|
".ls-poster img { width: 100%; height: 100%; object-fit: cover; }\n" +
|
|
"\n" +
|
|
"/* ── Responsive ── */\n" +
|
|
"@media (max-width: 900px) {\n" +
|
|
" .ls-wrapper { flex-direction: column; border-left: none; border-top: 5px solid #c0272d; }\n" +
|
|
" .ls-left { flex: none; max-width: 100%; padding: 28px 20px 24px; }\n" +
|
|
" .ls-right { min-height: 260px; position: relative; }\n" +
|
|
" .ls-poster { position: relative; }\n" +
|
|
" .ls-poster img { height: auto; max-height: 400px; }\n" +
|
|
"}\n" +
|
|
"@media (max-width: 600px) {\n" +
|
|
" .ls-heading { font-size: 18px; }\n" +
|
|
" .ls-tab { padding: 6px 12px; font-size: 13px; }\n" +
|
|
" .ls-panel-title { font-size: 16px; }\n" +
|
|
" .ls-panel-desc { font-size: 13px; }\n" +
|
|
" .ls-right { min-height: 200px; }\n" +
|
|
"}\n" +
|
|
"</style>\n" +
|
|
"\n" +
|
|
"<section class=\"ls-section\">\n" +
|
|
" <div class=\"ls-wrapper\">\n" +
|
|
" <!-- Left Column -->\n" +
|
|
" <div class=\"ls-left\">\n" +
|
|
" <h2 class=\"ls-heading\">Livestream Tháng 07</h2>\n" +
|
|
" <div class=\"ls-tabs\">\n" +
|
|
" {{#each livestream_posts}}\n" +
|
|
" <a href=\"javascript:void(0)\" class=\"ls-tab\" data-tab=\"ls-panel-{{index}}\" onclick=\"switchLsTab(this)\">Tuần {{title}}</a>\n" +
|
|
" {{/each}}\n" +
|
|
" </div>\n" +
|
|
" {{#each livestream_posts}}\n" +
|
|
" <div class=\"ls-panel\" id=\"ls-panel-{{index}}\">\n" +
|
|
" <h3 class=\"ls-panel-title\">{{excerpt}}</h3>\n" +
|
|
" <div class=\"ls-panel-desc\">{{content}}</div>\n" +
|
|
" <a href=\"/post/{{slug}}\" class=\"ls-btn\">Tìm Hiểu Thêm</a>\n" +
|
|
" </div>\n" +
|
|
" {{/each}}\n" +
|
|
" </div>\n" +
|
|
" <!-- Right Column — Poster -->\n" +
|
|
" <div class=\"ls-right\">\n" +
|
|
" {{#each livestream_posts}}\n" +
|
|
" <div class=\"ls-poster\" data-poster=\"ls-panel-{{index}}\">\n" +
|
|
" <img src=\"{{featuredImageUrl}}\" alt=\"{{title}}\" loading=\"lazy\">\n" +
|
|
" </div>\n" +
|
|
" {{/each}}\n" +
|
|
" </div>\n" +
|
|
" </div>\n" +
|
|
"</section>\n" +
|
|
"\n" +
|
|
"<script>\n" +
|
|
"function switchLsTab(el) {\n" +
|
|
" var tabId = el.getAttribute('data-tab');\n" +
|
|
" document.querySelectorAll('.ls-tab').forEach(function(t){t.classList.remove('active');});\n" +
|
|
" el.classList.add('active');\n" +
|
|
" document.querySelectorAll('.ls-panel').forEach(function(p){p.classList.remove('active');});\n" +
|
|
" var panel = document.getElementById(tabId);\n" +
|
|
" if(panel) panel.classList.add('active');\n" +
|
|
" document.querySelectorAll('.ls-poster').forEach(function(p){p.classList.remove('active');});\n" +
|
|
" var poster = document.querySelector('.ls-poster[data-poster=\"'+tabId+'\"]');\n" +
|
|
" if(poster) poster.classList.add('active');\n" +
|
|
"}\n" +
|
|
"document.addEventListener('DOMContentLoaded', function() {\n" +
|
|
" var first = document.querySelector('.ls-tab');\n" +
|
|
" if(first) switchLsTab(first);\n" +
|
|
"});\n" +
|
|
"</script>";
|
|
|
|
PreparedStatement updateTemplate = conn.prepareStatement(
|
|
"UPDATE sis_component_template SET html_template = ? WHERE slug = 'tabbed-livestream'"
|
|
);
|
|
updateTemplate.setString(1, htmlTemplate);
|
|
int rows = updateTemplate.executeUpdate();
|
|
System.out.println("Updated " + rows + " row(s).");
|
|
|
|
conn.close();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|