From 301d6f441e7f809c8c6126bd12d1f18740b4d454 Mon Sep 17 00:00:00 2001 From: masterpmi Date: Thu, 23 Jul 2026 11:08:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20build.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/build.py b/build.py index 1642583..b4ff6db 100644 --- a/build.py +++ b/build.py @@ -29,6 +29,12 @@ TEMPLATE = """ .person-details {{ color: #555; font-size: 0.95em; }} .back-link {{ display: inline-block; margin-bottom: 20px; color: #003366; text-decoration: none; }} .back-link:hover {{ text-decoration: underline; }} + .pdf-link {{ display: inline-flex; align-items: center; padding: 8px 16px; background: #003366; color: white; text-decoration: none; border-radius: 4px; margin: 10px 0; }} + .pdf-link:hover {{ background: #004080; }} + .pdf-link::before {{ content: ""; margin-right: 8px; }} + .pdf-list {{ list-style: none; padding: 0; }} + .pdf-list li {{ margin: 10px 0; padding: 10px; background: #f9f9f9; border-left: 4px solid #003366; }} + img {{ max-width: 100%; height: auto; display: block; margin: 20px auto; }} @@ -38,6 +44,7 @@ TEMPLATE = """ Главная Новости Сотрудники + Публикации
@@ -50,7 +57,6 @@ TEMPLATE = """ """ def parse_front_matter(text): - """Простой парсер для извлечения метаданных из начала файла""" if text.strip().startswith('---'): parts = text.split('---', 2) if len(parts) >= 3: @@ -87,7 +93,7 @@ def main(): for md_file in news_files: build_page(md_file, Path(f'public/news/{md_file.stem}.html'), md_file.stem.replace('-', ' ').title()) - # 3. Страница сотрудников (с группировкой и ссылками!) + # 3. Страница сотрудников staff_by_lab = {} unassigned = [] @@ -105,7 +111,6 @@ def main(): if position: details.append(position) details_str = ", ".join(details) - # Создаем ссылку на персональную страницу person_html = f'''
{details_str}
@@ -118,7 +123,6 @@ def main(): staff_by_lab[lab] = [] staff_by_lab[lab].append(person_html) - # Формируем HTML для страницы сотрудников staff_html = "

Наши сотрудники

" lab_order = [ @@ -147,27 +151,47 @@ def main(): with open('public/staff.html', 'w', encoding='utf-8') as f: f.write(TEMPLATE.format(title="Сотрудники", content=staff_html)) - # 4. Создаем индивидуальные страницы для каждого сотрудника + # 4. Персональные страницы сотрудников for md_file in Path('content/staff').glob('*.md'): with open(md_file, 'r', encoding='utf-8') as f: meta, body = parse_front_matter(f.read()) name = meta.get('name', md_file.stem.replace('-', ' ').title()) - - # Добавляем ссылку "Назад к списку" в начало страницы full_content = f'← Назад к списку сотрудников\n{body}' html_content = markdown.markdown(full_content, extensions=['fenced_code', 'tables']) with open(Path(f'public/staff/{md_file.stem}.html'), 'w', encoding='utf-8') as f: f.write(TEMPLATE.format(title=name, content=html_content)) - # 5. Копирование статических файлов (картинки) + # 5. Страница с публикациями (PDF-файлы) + pdf_files = sorted(Path('static/pdf').glob('*.pdf')) + if pdf_files: + pdf_list_html = "

Научные публикации и документы

    " + for pdf in pdf_files: + # Получаем название из имени файла или из метаданных (если есть) + title = pdf.stem.replace('-', ' ').replace('_', ' ').title() + size_mb = pdf.stat().st_size / (1024 * 1024) + pdf_list_html += f""" +
  • + {title} + ({size_mb:.1f} MB) +
  • """ + pdf_list_html += "
" + + with open('public/publications.html', 'w', encoding='utf-8') as f: + f.write(TEMPLATE.format(title="Публикации", content=pdf_list_html)) + else: + # Если PDF пока нет, создаем заглушку + with open('public/publications.html', 'w', encoding='utf-8') as f: + f.write(TEMPLATE.format(title="Публикации", content="

Публикации

В этом разделе скоро появятся научные публикации и документы.

")) + + # 6. Копирование статических файлов (картинки, PDF, CSS) if Path('static').exists(): shutil.rmtree('public/static', ignore_errors=True) shutil.copytree('static', 'public/static') - print("✅ Статические файлы скопированы") + print("✅ Статические файлы скопированы (включая PDF)") - print("✅ Сайт успешно собран! Сотрудники сгруппированы и кликабельны.") + print("✅ Сайт успешно собран!") if __name__ == '__main__': main() \ No newline at end of file