feat: add commit SHA marker at top-right corner of each page
This commit is contained in:
parent
668a22b5ff
commit
8237131242
@ -275,8 +275,8 @@ def generate_grade_page(final_grade):
|
||||
'''
|
||||
|
||||
|
||||
def get_css_styles(watermark_text=""):
|
||||
"""获取 PDF 样式,包含水印"""
|
||||
def get_css_styles(watermark_text="", commit_sha=""):
|
||||
"""获取 PDF 样式,包含水印和版本标记"""
|
||||
|
||||
# 水印样式
|
||||
watermark_css = ""
|
||||
@ -311,11 +311,24 @@ def get_css_styles(watermark_text=""):
|
||||
}}
|
||||
'''
|
||||
|
||||
# 版本标记(右上角)
|
||||
commit_marker = ""
|
||||
if commit_sha:
|
||||
short_sha = commit_sha[:7] if len(commit_sha) > 7 else commit_sha
|
||||
commit_marker = f'''
|
||||
@top-right {{
|
||||
content: "{short_sha}";
|
||||
font-size: 8pt;
|
||||
color: #999;
|
||||
font-family: 'Consolas', 'Monaco', monospace;
|
||||
}}
|
||||
'''
|
||||
|
||||
return f'''
|
||||
@page {{
|
||||
size: A4;
|
||||
margin: 2cm 2.5cm;
|
||||
|
||||
{commit_marker}
|
||||
@bottom-center {{
|
||||
content: counter(page);
|
||||
font-size: 10pt;
|
||||
@ -704,7 +717,7 @@ def create_full_html(args, final_grade, student_info):
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Java程序设计 - 期末大作业报告</title>
|
||||
<style>{get_css_styles(watermark_text)}</style>
|
||||
<style>{get_css_styles(watermark_text, commit_sha)}</style>
|
||||
</head>
|
||||
<body>
|
||||
{generate_cover_page(student_id, student_name, class_name)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user