第一次上传 (#312)

This commit is contained in:
jkjkil4
2026-03-14 02:52:26 +08:00
committed by GitHub
parent eefcc2565e
commit 7e206ec6ec
42 changed files with 525 additions and 0 deletions

40
J/jkjkil4/src/descs.txt Normal file
View File

@@ -0,0 +1,40 @@
[2023-11-10-(1).jpg]
这是我的第一套女装qwq虽然说是比较廉价的款式但是毕竟是第一套嘛一切的开始
[2024-01-04-(1).jpg]
试了一下浅色的款式
[2024-04-21-(1).jpg]
又买了一套浅色的款式,这套会可爱一些呢
[2025-02-03-(1).jpg]
偏向日常的尝试
[2025-02-22-(1).jpg]
群友穿不下的女仆装就送我了owo
[2025-04-08-(1).jpg]
闺蜜给我挑的衣服,很好看!也挺适合穿出门的
[2025-04-25-(1).jpg]
尝试在闺蜜和同学的陪同下出门...因为怕社恐所以专挑在外地旅游的时候尝试TAT
最后还去旁边的商场打了舞萌(心虚)
[2025-07-07-(1).jpg]
受不了学校宿舍搬出来住了,接下来就是大拍特拍环节!
[2025-08-22-(1).jpg]
借群友衣服穿穿
[2025-08-26-(1).jpg]
偏向日常的尝试
[2025-09-27-(1).jpg]
去学校
[2025-12-13-(1).jpg]
下雪出来走走
[2026-03-11-(1).jpg]
忍不住又买了新衣服

View File

@@ -0,0 +1,120 @@
from functools import lru_cache
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parents[1]
PHOTOS_DIR = ROOT_DIR / 'photos'
DESCS_FILE = ROOT_DIR / 'src' / 'descs.txt'
OUTPUT_FILE = ROOT_DIR / 'view.md'
def extract_date_from_name(file_name: str) -> str:
if len(file_name) >= 10:
return file_name[:10]
return ''
@lru_cache(maxsize=1)
def get_descs() -> dict[str, str]:
if not DESCS_FILE.exists():
return {}
descs: dict[str, str] = {}
current_name = None
current_lines: list[str] = []
for raw_line in DESCS_FILE.read_text(encoding='utf-8').splitlines():
line = raw_line.rstrip()
if line.startswith('[') and line.endswith(']'):
if current_name is not None:
descs[current_name] = '\n'.join(current_lines).strip()
current_name = line[1:-1].strip()
current_lines = []
continue
if current_name is not None:
current_lines.append(raw_line)
if current_name is not None:
descs[current_name] = '\n'.join(current_lines).strip()
return descs
def read_optional_text(image_file: Path) -> str:
return get_descs().get(image_file.name, '')
def build_cell(image_file: Path) -> str:
date_text = extract_date_from_name(image_file.name)
note_text = read_optional_text(image_file)
lines = [
'<td width="50%">',
'',
f'![](photos/{image_file.name})',
date_text,
]
if note_text:
lines.extend([
'',
note_text,
])
lines.extend([
'',
'</td>',
])
return '\n'.join(lines)
def generate_view_md() -> str:
imgs = sorted(PHOTOS_DIR.glob('*.jpg'), key=lambda path: path.name)
lines = [
'<!-- 该文件由 generate_viewmd.py 生成,请勿手动编辑此文件 -->',
'',
'<table>',
'',
]
for index in range(0, len(imgs), 2):
left_img = imgs[index]
right_img = imgs[index + 1] if index + 1 < len(imgs) else None
lines.append('<tr>')
lines.append(build_cell(left_img))
if right_img is None:
lines.extend([
'<td width="50%">',
'',
'</td>',
])
else:
lines.append(build_cell(right_img))
lines.extend([
'</tr>',
'',
])
if index + 2 < len(imgs):
lines.extend([
'<tr><td><br></td></tr>',
'',
])
lines.append('</table>')
lines.append('')
return '\n'.join(lines)
def main() -> None:
output = generate_view_md()
OUTPUT_FILE.write_text(output, encoding='utf-8')
if __name__ == '__main__':
main()