feat: update charity project assets, add livestream media, and clean up temporary migration scripts
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
public class UpdateLivestreamTemplate10 {
|
||||
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 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2, 16px); 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 { 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 { 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 .ls-thumbnail { width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 2; cursor: pointer; }\n" +
|
||||
".ls-poster .ls-thumbnail img { width: 100%; height: 100%; object-fit: cover; }\n" +
|
||||
".ls-play-btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 70px; height: 70px; background: rgba(192, 39, 45, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3; transition: transform 0.2s, background 0.2s; }\n" +
|
||||
".ls-play-btn:hover { transform: translate(-50%, -50%) scale(1.1); background: #c0272d; }\n" +
|
||||
".ls-play-btn::after { content: ''; display: block; border-style: solid; border-width: 12px 0 12px 20px; border-color: transparent transparent transparent #fff; margin-left: 5px; }\n" +
|
||||
".ls-video-embed { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 1; }\n" +
|
||||
".ls-video-embed iframe { width: 100%; height: 100%; border: none; }\n" +
|
||||
"\n" +
|
||||
"/* ── Responsive ── */\n" +
|
||||
"@media (max-width: 900px) {\n" +
|
||||
" .ls-wrapper { grid-template-columns: 1fr; border-left: none; border-top: 5px solid #c0272d; }\n" +
|
||||
" .ls-left { padding: 28px 20px 24px; }\n" +
|
||||
" .ls-right { min-height: 260px; position: relative; }\n" +
|
||||
" .ls-poster { position: relative; }\n" +
|
||||
" .ls-poster .ls-thumbnail 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" +
|
||||
" .ls-play-btn { width: 50px; height: 50px; }\n" +
|
||||
" .ls-play-btn::after { border-width: 9px 0 9px 15px; }\n" +
|
||||
"}\n" +
|
||||
"</style>\n" +
|
||||
"\n" +
|
||||
"<div class=\"cc--component-container cc--tabbed-media-content ls-section\">\n" +
|
||||
" <div class=\"c--component c--tabbed-media-content\">\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" +
|
||||
" <div class=\"ls-thumbnail\" onclick=\"playLsVideo('ls-panel-{{index}}')\">\n" +
|
||||
" <img src=\"{{featuredImageUrl}}\" alt=\"{{title}}\" loading=\"lazy\">\n" +
|
||||
" <div class=\"ls-play-btn\"></div>\n" +
|
||||
" </div>\n" +
|
||||
" <div class=\"ls-video-embed\" id=\"ls-video-{{index}}\">\n" +
|
||||
" {{{metaDescriptionRaw}}}\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" {{/each}}\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
"</div>\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){\n" +
|
||||
" p.classList.remove('active');\n" +
|
||||
" // Pause video when switching tab\n" +
|
||||
" var iframe = p.querySelector('iframe');\n" +
|
||||
" if(iframe) { \n" +
|
||||
" var src = iframe.src;\n" +
|
||||
" iframe.src = src;\n" +
|
||||
" }\n" +
|
||||
" });\n" +
|
||||
" var poster = document.querySelector('.ls-poster[data-poster=\"'+tabId+'\"]');\n" +
|
||||
" if(poster) poster.classList.add('active');\n" +
|
||||
"}\n" +
|
||||
"function playLsVideo(tabId) {\n" +
|
||||
" var poster = document.querySelector('.ls-poster[data-poster=\"'+tabId+'\"]');\n" +
|
||||
" if(poster) {\n" +
|
||||
" var thumb = poster.querySelector('.ls-thumbnail');\n" +
|
||||
" var embed = poster.querySelector('.ls-video-embed');\n" +
|
||||
" var iframe = embed.querySelector('iframe');\n" +
|
||||
" if (thumb) thumb.style.display = 'none';\n" +
|
||||
" if (embed) {\n" +
|
||||
" embed.style.display = 'block';\n" +
|
||||
" embed.style.zIndex = '4';\n" +
|
||||
" // Add autoplay parameter to iframe src if not present\n" +
|
||||
" if (iframe && iframe.src.indexOf('autoplay=1') === -1) {\n" +
|
||||
" if (iframe.src.indexOf('?') > -1) iframe.src += '&autoplay=1';\n" +
|
||||
" else iframe.src += '?autoplay=1';\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user