updates
This commit is contained in:
15
classes.py
15
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 = "<a href=" + f"{self.subdir}/{self.slug}.html" + "> ...read more</a>"
|
||||
self.preview = self.html[:300] + self.url
|
||||
self.preview = self.data.content.replace('\n', '<br>')[: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)
|
||||
|
||||
@@ -11,3 +11,4 @@ class Config:
|
||||
CONTENT_DIR = 'content'
|
||||
STATIC_DIR = 'static'
|
||||
HEADER_IMAGE = 'static/header.jpg'
|
||||
THEME = "default"
|
||||
BIN
static/images/1x1.png
Normal file
BIN
static/images/1x1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 B |
BIN
static/images/1x1.png.1
Normal file
BIN
static/images/1x1.png.1
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 B |
@@ -2,8 +2,8 @@
|
||||
{% extends "default.html" %}
|
||||
|
||||
{% block head_includes %}
|
||||
{% if content_item.custom_css %}
|
||||
<link href="{{ content_item.custom_css }}">
|
||||
{% if content_item.css_file %}
|
||||
<link rel="stylesheet" href="/{{ content_item.css_file }}">
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
{% block head_includes %}
|
||||
{% endblock %}
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
<body>
|
||||
<div class="top_header">
|
||||
<div >
|
||||
|
||||
@@ -9,17 +9,23 @@
|
||||
{% block content %}
|
||||
|
||||
<!-- <div class="row row-cols-1 row-cols-md-3 row-cols-xxl-5 g-4 px-1 py-2"> -->
|
||||
<div class="container-fluid">
|
||||
<div class="row justify-content-center">
|
||||
<div class="container-fluid content-row">
|
||||
<div class="row">
|
||||
{% for content_item in content_items %}
|
||||
<div class="d-flex justify-content-center mb-4">
|
||||
<div class="card h-100 rounded mx-1 my-3" style="width: 100%; max-width: 400px;">
|
||||
<div class="card-header bg-dark">
|
||||
<div class="card-header">
|
||||
{% 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;">
|
||||
{% else %}
|
||||
<img src="static/images/1x1.png" alt="{{ content_item.title }}" class="card-img-top img-fluid mx-auto d-block object-fit-scale rounded" style="height: 200px; width: auto;">
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title"><a class="text-decoration-none text-body" href="content/{{ content_item.slug}}.html ">{{ content_item.title }}</a></h5>
|
||||
<p class="card-text mb-3">{{ content_item.preview | safe}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user