feat: implement specialty content module with expanded Page entity fields, database migrations, and data import utilities
This commit is contained in:
@@ -27,7 +27,7 @@ try:
|
||||
|
||||
# Fetch the latest 10 published posts with this tag
|
||||
sql_posts = """
|
||||
SELECT p.title, p.featured_image, p.slug, p.excerpt, p.created_date
|
||||
SELECT p.title, p.featured_image, p.slug, p.excerpt, p.created_date, p.content
|
||||
FROM sis_post p
|
||||
JOIN sis_post_tag pt ON p.id = pt.post_id
|
||||
WHERE pt.tag_id = :tag_id AND p.status = 'PUBLISHED'
|
||||
@@ -38,13 +38,24 @@ try:
|
||||
posts = cursor.fetchall()
|
||||
|
||||
import random
|
||||
import re
|
||||
|
||||
def extract_words(html_text, num_words=100):
|
||||
if not html_text:
|
||||
return ""
|
||||
if hasattr(html_text, 'read'):
|
||||
html_text = html_text.read()
|
||||
text = re.sub('<[^<]+?>', ' ', html_text)
|
||||
words = text.split()
|
||||
return " ".join(words[:num_words]) + ("..." if len(words) > num_words else "")
|
||||
|
||||
prices = ["42.400.000 VNĐ", "23.000.000 VNĐ", "32.500.000 VNĐ", "15.000.000 VNĐ", "Liên hệ"]
|
||||
badges = ["SAT", "SUN", "MON", "TUE", "WED", "THU", "FRI"]
|
||||
|
||||
items = []
|
||||
for post in posts:
|
||||
img = post[1] if post[1] else ""
|
||||
desc = post[3] if post[3] else ""
|
||||
desc = post[3] if post[3] else extract_words(post[5], 100)
|
||||
date_val = post[4]
|
||||
date_str = date_val.strftime("%d/%m/%Y") if hasattr(date_val, 'strftime') else str(date_val) if date_val else "12/09/2026"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user