updates
This commit is contained in:
20
classes.py
20
classes.py
@@ -14,15 +14,18 @@ class ContentItem:
|
||||
logger.debug(f"Rendering {self.source_filename} to {self.target_filename}")
|
||||
try:
|
||||
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)
|
||||
image_targetfile = Path(f"{Config.OUTPUT_DIR}/{Config.STATIC_DIR}/images/{self.image_file.name}")
|
||||
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.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)
|
||||
if self.js_file and self.js_file.exists():
|
||||
shutil.copyfile(self.js_file, Path(Config.OUTPUT_DIR) / self.js_file)
|
||||
js_targetfile = Path(f"{Config.OUTPUT_DIR}/{Config.STATIC_DIR}/js/{self.js_file.name}")
|
||||
logger.debug(f"Copying {self.js_file} to {js_targetfile}")
|
||||
shutil.copyfile(self.js_file, js_targetfile)
|
||||
with self.target_filename.open("w", encoding="utf-8") as f:
|
||||
f.write(content_item_template.render(content_item = self, page_title = self.title, parent_path = '../', categories = categories))
|
||||
except Exception as e:
|
||||
@@ -40,15 +43,16 @@ class ContentItem:
|
||||
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 = [c for c in self.data.get("categories", str([])) if c != 'default']
|
||||
self.categories = [c for c in self.data.get("categories", []) if c != 'default']
|
||||
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
|
||||
cover_image_path = Path(f"{self.source_filename.parent}/{self.source_filename.stem}.jpg")
|
||||
self.image_file = cover_image_path if cover_image_path.exists() else ""
|
||||
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
|
||||
self.css_file = css_filepath if css_filepath.exists() else ""
|
||||
js_filepath = Path(f"{self.source_filename.parent}/{self.source_filename.stem}.js")
|
||||
self.js_file = js_filepath if js_filepath.exists() else ""
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user