From 2e93be718489076aae6e9d80f5dad88ec1843d52 Mon Sep 17 00:00:00 2001 From: SG Date: Tue, 10 Jun 2025 23:11:10 +0300 Subject: [PATCH] updates --- classes.py | 15 ++++++++++----- config.py | 3 ++- static/images/1x1.png | Bin 0 -> 95 bytes static/images/1x1.png.1 | Bin 0 -> 95 bytes templates/content_item.html | 4 ++-- templates/default.html | 6 +++--- templates/index.html | 12 +++++++++--- 7 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 static/images/1x1.png create mode 100644 static/images/1x1.png.1 diff --git a/classes.py b/classes.py index d2434fe..d158113 100644 --- a/classes.py +++ b/classes.py @@ -16,31 +16,36 @@ class ContentItem: shutil.copyfile(self.image_file, Path(Config.OUTPUT_DIR) / self.image_file) self.image_file = f"{self.image_file.stem}.jpg" if self.css_file and self.css_file.exists(): - shutil.copyfile(self.css_file,Path(Config.OUTPUT_DIR) / self.css_file) + 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}") + shutil.copyfile(self.css_file, css_targetfile) + self.css_file = css_targetfile if self.js_file and self.js_file.exists(): shutil.copyfile(self.js_file, Path(Config.OUTPUT_DIR) / self.js_file) with self.target_filename.open("w", encoding="utf-8") as f: f.write(content_item_template.render(content_item = self, page_title = self.title)) def parse_content(self): + logger.debug(f"Parsing file {self.source_filename}") try: self.source_filename = Path(self.source_filename) - logger.debug(f"Parsing item {self.source_filename}") self.subdir = self.source_filename.parent self.slug = self.source_filename.stem self.target_filename = Path(f"{Config.OUTPUT_DIR}/{self.source_filename.parent}/{self.source_filename.stem}.html") self.data = frontmatter.load(self.source_filename) - self.html = markdown.markdown(self.data.content.replace('\n', ' \n')) self.url = " ...read more" - self.preview = self.html[:300] + self.url + self.preview = self.data.content.replace('\n', '
')[:300] + self.url self.title = self.data.get("title", self.slug) self.omit_second_title = self.data.get("omit_second_title", False) self.date = self.data.get("date", "2000-01-01T00:00:00+03:00") self.categories = self.data.get("categories", str([])) self.hidden = self.data.get("hidden", str(False)) + self.data.content = self.data.content.replace('\n', ' \n') + self.html = markdown.markdown(self.data.content) cover_image_path = Path(self.source_filename.parent) / Path(self.source_filename.stem + ".jpg") self.image_file = cover_image_path if cover_image_path.exists() else None - self.css_file = Path(self.source_filename.stem + ".css") if Path(self.source_filename.stem + ".css").exists() else None + css_filepath = Path(f"{self.source_filename.parent}/{self.source_filename.stem}.css") + self.css_file = css_filepath if css_filepath.exists() else None self.js_file = Path(self.source_filename.stem + ".js") if Path(self.source_filename.stem + ".js").exists else None except Exception as e: logger.error(e) diff --git a/config.py b/config.py index 24dd35f..3cd1cea 100644 --- a/config.py +++ b/config.py @@ -10,4 +10,5 @@ class Config: TEMPLATES_DIR = 'templates' CONTENT_DIR = 'content' STATIC_DIR = 'static' - HEADER_IMAGE = 'static/header.jpg' \ No newline at end of file + HEADER_IMAGE = 'static/header.jpg' + THEME = "default" \ No newline at end of file diff --git a/static/images/1x1.png b/static/images/1x1.png new file mode 100644 index 0000000000000000000000000000000000000000..1914264c08781d1f30ee0b8482bccf44586f2dc1 GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?ju0VQumF+E%TuG2$FoVOh l8)-lem#2$k2*>s01R$Gz9%CSj!PC{xWt~$(697H@6ZHT9 literal 0 HcmV?d00001 diff --git a/static/images/1x1.png.1 b/static/images/1x1.png.1 new file mode 100644 index 0000000000000000000000000000000000000000..1914264c08781d1f30ee0b8482bccf44586f2dc1 GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?ju0VQumF+E%TuG2$FoVOh l8)-lem#2$k2*>s01R$Gz9%CSj!PC{xWt~$(697H@6ZHT9 literal 0 HcmV?d00001 diff --git a/templates/content_item.html b/templates/content_item.html index b45666f..49c35a4 100644 --- a/templates/content_item.html +++ b/templates/content_item.html @@ -2,8 +2,8 @@ {% extends "default.html" %} {% block head_includes %} - {% if content_item.custom_css %} - + {% if content_item.css_file %} + {% endif %} {% endblock %} diff --git a/templates/default.html b/templates/default.html index 0f171fb..470ef39 100644 --- a/templates/default.html +++ b/templates/default.html @@ -12,7 +12,7 @@ position: relative; height: 250px; background: rgb(70, 70, 124); - background-image: url("{{ header_image }}"); + background-image: url("/public/static/header.jpg"); background-size: cover; background-position: center; display: flex; @@ -63,10 +63,10 @@ font-size: 1.1rem; line-height: 1.6; } + {% block head_includes %} {% endblock %} - - +
diff --git a/templates/index.html b/templates/index.html index 3610502..ab56e7a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,17 +9,23 @@ {% block content %} -
-
+
+
{% for content_item in content_items %} +
-
+
+ {% if content_item.image_file %} {{ content_item.title }} + {% else %} + {{ content_item.title }} + {% endif %}
{{ content_item.title }}

{{ content_item.preview | safe}}

+
{% endfor %}