From 802f8022d090489ae0e8077b6f4e31bd694dc191 Mon Sep 17 00:00:00 2001 From: SG Date: Sun, 22 Jun 2025 12:12:36 +0300 Subject: [PATCH] audio player added --- classes.py | 7 +++++++ themes/default/templates/content_item.html | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/classes.py b/classes.py index 5fa5913..df466b5 100644 --- a/classes.py +++ b/classes.py @@ -24,6 +24,11 @@ class ContentItem: logger.debug(f"Copying {self.image_file} to {image_targetfile}") shutil.copyfile(self.image_file, image_targetfile) self.image_file = f"{self.image_file.stem}.jpg" + if self.audio_file and self.audio_file.exists(): + audio_targetfile = Path(f"{config.output_dir}/{config.static_dir}/audio/{self.audio_file.name}") + logger.debug(f"Copying {self.audio_file} to {audio_targetfile}") + shutil.copyfile(self.audio_file, audio_targetfile) + self.audio_file = f"{self.audio_file.stem}.mp3" if self.css_file and self.css_file.exists(): css_targetfile = Path(f"{config.output_dir}/{config.static_dir}/css/{self.css_file.name}") logger.debug(f"Copying {self.css_file} to {css_targetfile}") @@ -55,6 +60,8 @@ class ContentItem: self.html = markdown.markdown(self.data.content) cover_image_path = Path(f"{self.source_file.parent}/{self.source_file.stem}.jpg") self.image_file = cover_image_path if cover_image_path.exists() else "" + audio_filepath = Path(f"{self.source_file.parent}/{self.source_file.stem}.mp3") + self.audio_file = audio_filepath if audio_filepath.exists() else "" css_filepath = Path(f"{self.source_file.parent}/{self.source_file.stem}.css") self.css_file = css_filepath if css_filepath.exists() else "" js_filepath = Path(f"{self.source_file.parent}/{self.source_file.stem}.js") diff --git a/themes/default/templates/content_item.html b/themes/default/templates/content_item.html index 25f7f29..509a821 100644 --- a/themes/default/templates/content_item.html +++ b/themes/default/templates/content_item.html @@ -15,7 +15,18 @@ {% if not content_item.omit_second_title %}

{{ content_item.title }}

{% endif %} +
{{ content_item.html | safe }}
+ + {% if content_item.audio_file %} +
+ +
+ {% endif %} +
{% for category in content_item.categories %} {{ category }}