Add popup-heavy generic rendering for run-002 and run-003

This commit is contained in:
2026-04-04 17:28:14 +09:00
parent 6cf4b2ec33
commit 43fa31556f
41 changed files with 446 additions and 433 deletions

View File

@@ -736,12 +736,17 @@ def _build_stage2_retry_html(ctx: PipelineContext, retry_plan: dict) -> dict:
support_title = support_topic.title if support_topic and support_topic.title else '보조 정보'
conclusion_text = _prefer_source_text(conclusion_topic, ctx.analysis.core_message if ctx.analysis else '')
intro_lines = _bulletish_lines(_prefer_source_text(intro_topic, ''), 6)
body_lines = _bulletish_lines(_prefer_source_text(body_topic, ''), 8)
support_lines = _bulletish_lines(_prefer_source_text(support_topic, ''), 8)
details = _details_blocks(raw)
detail_source = details[0] if details else _prefer_source_text(support_topic, '')
detail_popup = _popup_overlay('popup-detail', support_title, _popup_list_html(_bulletish_lines(detail_source, 14), floor=200, ceiling=560))
intro_full = _bulletish_lines(_prefer_source_text(intro_topic, ''), 12)
body_full = _bulletish_lines(_prefer_source_text(body_topic, ''), 14)
support_full = _bulletish_lines(_prefer_source_text(support_topic, ''), 12)
intro_visible = intro_full[:4]
body_visible = body_full[:4]
support_visible = support_full[:3]
intro_popup = _popup_overlay('popup-intro', intro_title, _popup_list_html(intro_full, floor=220, ceiling=640)) if len(intro_full) > len(intro_visible) else ''
body_popup = _popup_overlay('popup-body', body_title, _popup_list_html(body_full, floor=220, ceiling=680)) if len(body_full) > len(body_visible) else ''
support_popup = _popup_overlay('popup-support', support_title, _popup_list_html(support_full, floor=220, ceiling=640)) if len(support_full) > len(support_visible) else ''
image_src = _extract_image_src_from_raw(raw)
if image_src and ctx.base_path:
@@ -752,8 +757,13 @@ def _build_stage2_retry_html(ctx: PipelineContext, retry_plan: dict) -> dict:
image_src = ''
image_caption = _extract_caption_from_raw(raw) or body_title
intro_card = _section_card(intro_title, intro_lines[:5], tone='orange')
body_card = _section_card(body_title, body_lines[:6], tone='blue')
intro_card = _section_card(intro_title, intro_visible, tone='orange')
if len(intro_full) > len(intro_visible):
intro_card += _popup_button('popup-intro', '나머지 내용 보기')
body_card = _section_card(body_title, body_visible, tone='blue')
if len(body_full) > len(body_visible):
body_card += _popup_button('popup-body', '상세 본문 보기')
if image_src:
visual_block = (
@@ -763,13 +773,15 @@ def _build_stage2_retry_html(ctx: PipelineContext, retry_plan: dict) -> dict:
'</div>'
)
elif support_topic and '<DxEffect' in (support_topic.source_data or support_topic.summary or ''):
visual_block = _component_placeholder(support_title, _prefer_source_text(support_topic, '주체별 기대효과를 보조 영역에서 요약함.'))
visual_block = _component_placeholder(support_title, '주체별 기대효과 도식은 요약 카드와 팝업으로 함께 제공함.')
else:
visual_block = _section_card(support_title, support_lines[:5], tone='slate')
visual_block = _section_card(support_title, support_visible, tone='slate')
if len(support_full) > len(support_visible):
visual_block += _popup_button('popup-support', '상세 보조 내용 보기')
sidebar_inner = _section_card(support_title, support_lines[:5], tone='slate') if support_lines else _component_placeholder(support_title, _prefer_source_text(support_topic, '보조 정보가 없음.'))
if support_lines:
sidebar_inner += _popup_button('popup-detail', '상세 내용 보기')
sidebar_inner = _section_card(support_title, support_visible, tone='slate') if support_visible else _component_placeholder(support_title, _prefer_source_text(support_topic, '보조 정보가 없음.'))
if len(support_full) > len(support_visible):
sidebar_inner += _popup_button('popup-support', '상세 내용 보기')
body_html = (
'<div style="width:100%; height:100%; box-sizing:border-box; font-family:Segoe UI,sans-serif; color:#0f172a; display:flex; flex-direction:column; gap:10px;">'
@@ -778,14 +790,14 @@ def _build_stage2_retry_html(ctx: PipelineContext, retry_plan: dict) -> dict:
f'{body_card}'
f'{visual_block}'
'</div>'
f'{detail_popup}'
f'{intro_popup}{body_popup}{support_popup}'
'</div>'
)
sidebar_html = '<div style="width:100%; height:100%; box-sizing:border-box; font-family:Segoe UI,sans-serif; display:flex; flex-direction:column; gap:10px;">' + sidebar_inner + '</div>'
footer_html = '<div style="background:linear-gradient(135deg, #0b6ef3 0%, #17a6f5 100%); border-radius:10px; padding:10px 20px; text-align:center; color:#ffffff; width:100%; height:58px; display:flex; align-items:center; justify-content:center; box-sizing:border-box;">' + f'<div style="font-size:13px; font-weight:900; line-height:1.35;">{_trim_visible_copy(conclusion_text, floor=90, ceiling=240)}</div>' + '</div>'
return {'body_html': body_html, 'sidebar_html': sidebar_html, 'footer_html': footer_html, 'reasoning': 'generic retry layout for non-run001 documents: preserve original section titles, visible intro/body/support blocks, and popup detail support'}
footer_html = '<div style="background:linear-gradient(135deg, #0b6ef3 0%, #17a6f5 100%); border-radius:10px; padding:10px 20px; text-align:center; color:#ffffff; width:100%; height:58px; display:flex; align-items:center; justify-content:center; box-sizing:border-box;">' + f'<div style="font-size:13px; font-weight:900; line-height:1.35;">{_trim_visible_copy(conclusion_text, floor=120, ceiling=320)}</div>' + '</div>'
return {'body_html': body_html, 'sidebar_html': sidebar_html, 'footer_html': footer_html, 'reasoning': 'generic retry layout for non-run001 documents: preserve section titles, keep visible summary blocks, and move overflow detail into popups'}
async def _stage_2(ctx: PipelineContext, retry_plan: dict | None = None) -> PipelineContext:
analysis_dict = {
@@ -924,3 +936,4 @@ if __name__ == '__main__':