updates
This commit is contained in:
34
classes.py
34
classes.py
@@ -11,19 +11,23 @@ from jinja_env import env, content_item_template, index_template
|
|||||||
class ContentItem:
|
class ContentItem:
|
||||||
def render_content(self):
|
def render_content(self):
|
||||||
logger.debug(f"Rendering {self.source_filename} to {self.target_filename}")
|
logger.debug(f"Rendering {self.source_filename} to {self.target_filename}")
|
||||||
if self.image_file and self.image_file.exists():
|
try:
|
||||||
logger.debug(f"Copying {self.image_file} to {Path(Config.OUTPUT_DIR) / self.image_file}")
|
logger.debug(f"Title: {self.title}")
|
||||||
shutil.copyfile(self.image_file, Path(Config.OUTPUT_DIR) / self.image_file)
|
if self.image_file and self.image_file.exists():
|
||||||
self.image_file = f"{self.image_file.stem}.jpg"
|
logger.debug(f"Copying {self.image_file} to {Path(Config.OUTPUT_DIR) / self.image_file}")
|
||||||
if self.css_file and self.css_file.exists():
|
shutil.copyfile(self.image_file, Path(Config.OUTPUT_DIR) / self.image_file)
|
||||||
css_targetfile = Path(f"{Config.OUTPUT_DIR}/{Config.STATIC_DIR}/css/{self.css_file.name}")
|
self.image_file = f"{self.image_file.stem}.jpg"
|
||||||
logger.debug(f"Copying {self.css_file} to {css_targetfile}")
|
if self.css_file and self.css_file.exists():
|
||||||
shutil.copyfile(self.css_file, css_targetfile)
|
css_targetfile = Path(f"{Config.OUTPUT_DIR}/{Config.STATIC_DIR}/css/{self.css_file.name}")
|
||||||
self.css_file = css_targetfile
|
logger.debug(f"Copying {self.css_file} to {css_targetfile}")
|
||||||
if self.js_file and self.js_file.exists():
|
shutil.copyfile(self.css_file, css_targetfile)
|
||||||
shutil.copyfile(self.js_file, Path(Config.OUTPUT_DIR) / self.js_file)
|
self.css_file = css_targetfile
|
||||||
with self.target_filename.open("w", encoding="utf-8") as f:
|
if self.js_file and self.js_file.exists():
|
||||||
f.write(content_item_template.render(content_item = self, page_title = self.title))
|
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))
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
|
||||||
def parse_content(self):
|
def parse_content(self):
|
||||||
logger.debug(f"Parsing file {self.source_filename}")
|
logger.debug(f"Parsing file {self.source_filename}")
|
||||||
@@ -59,8 +63,8 @@ class ContentItem:
|
|||||||
"description: ''\n",
|
"description: ''\n",
|
||||||
"author: ''\n",
|
"author: ''\n",
|
||||||
"categories: ['default']\n",
|
"categories: ['default']\n",
|
||||||
"hidden: 'False'\n",
|
"hidden: False\n",
|
||||||
"omit_second_title: 'False'\n",
|
"omit_second_title: False\n",
|
||||||
"---\n",
|
"---\n",
|
||||||
"\n\n\n"
|
"\n\n\n"
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
<!-- <div class="row row-cols-1 row-cols-md-3 row-cols-xxl-5 g-4 px-1 py-2"> -->
|
<!-- <div class="row row-cols-1 row-cols-md-3 row-cols-xxl-5 g-4 px-1 py-2"> -->
|
||||||
<div class="container-fluid content-row">
|
<div class="container-fluid content-row">
|
||||||
<div class="row">
|
<div class="row justify-content-start">
|
||||||
{% for content_item in content_items %}
|
{% for content_item in content_items %}
|
||||||
<div class="d-flex justify-content-center mb-4">
|
<div class="d-flex justify-content-center mx-2 mb-4">
|
||||||
<div class="card h-100 rounded mx-1 my-3" style="width: 100%; max-width: 400px;">
|
<div class="card h-100 rounded mx-1 my-3" style="width: 400px;">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
{% if content_item.image_file %}
|
{% if content_item.image_file %}
|
||||||
<img src="content/{{ content_item.image_file }}" alt="{{ content_item.title }}" class="card-img-top img-fluid mx-auto d-block object-fit-scale rounded" style="max-height: 200px; width: auto;">
|
<img src="content/{{ content_item.image_file }}" alt="{{ content_item.title }}" class="card-img-top img-fluid mx-auto d-block object-fit-scale rounded" style="max-height: 200px; width: auto;">
|
||||||
|
|||||||
Reference in New Issue
Block a user