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:
|
||||
def render_content(self):
|
||||
logger.debug(f"Rendering {self.source_filename} to {self.target_filename}")
|
||||
if self.image_file and self.image_file.exists():
|
||||
logger.debug(f"Copying {self.image_file} to {Path(Config.OUTPUT_DIR) / self.image_file}")
|
||||
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():
|
||||
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))
|
||||
try:
|
||||
logger.debug(f"Title: {self.title}")
|
||||
if self.image_file and self.image_file.exists():
|
||||
logger.debug(f"Copying {self.image_file} to {Path(Config.OUTPUT_DIR) / self.image_file}")
|
||||
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():
|
||||
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))
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
def parse_content(self):
|
||||
logger.debug(f"Parsing file {self.source_filename}")
|
||||
@@ -59,8 +63,8 @@ class ContentItem:
|
||||
"description: ''\n",
|
||||
"author: ''\n",
|
||||
"categories: ['default']\n",
|
||||
"hidden: 'False'\n",
|
||||
"omit_second_title: 'False'\n",
|
||||
"hidden: False\n",
|
||||
"omit_second_title: False\n",
|
||||
"---\n",
|
||||
"\n\n\n"
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user