Files
sisvietnamvn_01/sisvietnamvn_main/.temp/patch_plugin.py
T

33 lines
1.2 KiB
Python

import re
html_file = "/home/x79/sisvietnamvn_01/sisvietnamvn_main/html_snippets/content_main_blocks/temp"
plugin_file = "/home/x79/sisvietnamvn_01/sisvietnamvn_main/src/main/java/com/sisvietnamvn/web/plugins/tabbedlivestream/TabbedLivestreamPlugin.java"
with open(html_file, "r") as f:
html_content = f.read()
with open(plugin_file, "r") as f:
plugin_content = f.read()
target = """ // TODO: Dán mã HTML thật của tabbed-livestream vào đây
t.setHtmlTemplate(
"<!-- Tabbed Livestream Template -->\\n" +
"<div class=\\"livestream-container\\">\\n" +
" {{#each livestream_posts}}\\n" +
" <div class=\\"livestream-item\\">\\n" +
" <a href=\\"/post/{{slug}}\\">{{title}}</a>\\n" +
" </div>\\n" +
" {{/each}}\\n" +
"</div>"
);"""
replacement = ' t.setHtmlTemplate("""\n' + html_content + '""");'
if target in plugin_content:
new_content = plugin_content.replace(target, replacement)
with open(plugin_file, "w") as f:
f.write(new_content)
print("Success")
else:
print("Target not found")