Compare commits
5 Commits
d412d983bd
...
afefce0a11
Author | SHA1 | Date | |
---|---|---|---|
afefce0a11 | |||
334c82d098 | |||
ddd536c958 | |||
ae5ba0d044 | |||
83133218a4 |
@ -16,6 +16,7 @@
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="{article_overview_url}">
|
||||
<strong>{article_language_flag} {article_title}</strong>
|
||||
<span>{article_datetime}</span>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -2,7 +2,11 @@
|
||||
<a href="{article_url}" hreflang="{article_language_code}" class="card mb-4" style="color: inherit; text-decoration: none;">
|
||||
<div class="card-content">
|
||||
<p class="title">{article_language_flag} {article_title} </p>
|
||||
<p class="content">{article_preview}</p>
|
||||
<p class="content">
|
||||
{article_preview}
|
||||
<br />
|
||||
<time>{article_datetime}</time>
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
@ -7,6 +7,8 @@ import markdown
|
||||
from typing import Optional, Union, Dict, Generator, List, DefaultDict
|
||||
from bs4 import BeautifulSoup
|
||||
from collections import defaultdict
|
||||
import toml
|
||||
import datetime
|
||||
|
||||
from . import config
|
||||
|
||||
@ -82,6 +84,7 @@ class ArticleTranslation:
|
||||
"article_overview_url": self.article_overview.url,
|
||||
"article_slug": self.article_overview.slug,
|
||||
"article_title": self.title,
|
||||
"article_datetime": self.article_overview.article_written.strftime(config.formatting.datetime_format),
|
||||
"article_language_name": self.language_name,
|
||||
"article_language_code": self.language_code,
|
||||
"article_language_flag": self.language_flag,
|
||||
@ -109,13 +112,19 @@ class ArticleTranslation:
|
||||
|
||||
|
||||
class ArticleOverview:
|
||||
def __init__(self, directory: Path, location_in_tree: Optional[List[str]] = None):
|
||||
def __init__(self, directory: Path, location_in_tree: Optional[List[str]] = None, is_root: bool = False):
|
||||
self.directory = directory
|
||||
self.slug = self.directory.name
|
||||
|
||||
self.article_written = self.directory.stat().st_mtime
|
||||
article_config = {}
|
||||
if (self.directory / "index.toml").exists():
|
||||
article_config = toml.load(self.directory / "index.toml")
|
||||
|
||||
self.slug = article_config.get("name", self.directory.name)
|
||||
|
||||
self.article_written = datetime.datetime.fromisoformat(article_config["datetime"]) if "datetime" in article_config else datetime.datetime.fromtimestamp(self.directory.stat().st_mtime)
|
||||
|
||||
self.location_in_tree: List[str] = location_in_tree or []
|
||||
if not is_root:
|
||||
self.location_in_tree.append(self.slug)
|
||||
self.url = "/" + "/".join(self.location_in_tree)
|
||||
self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree)
|
||||
@ -130,6 +139,9 @@ class ArticleOverview:
|
||||
self.article_translations_map: Dict[str, ArticleTranslation] = {}
|
||||
|
||||
for c in self.directory.iterdir():
|
||||
if c.name == "index.toml":
|
||||
continue
|
||||
|
||||
if c.is_file():
|
||||
at = ArticleTranslation(c, self)
|
||||
self.article_translations.append(at)
|
||||
@ -163,6 +175,7 @@ class ArticleOverview:
|
||||
"article_url": self.url,
|
||||
"article_title": self.slug,
|
||||
"article_slug": self.slug,
|
||||
"article_datetime": self.article_written.strftime(config.formatting.datetime_format),
|
||||
"article_overview_url": self.url,
|
||||
"article_overview_cards": self.overview_cards,
|
||||
}
|
||||
@ -197,7 +210,7 @@ def build():
|
||||
shutil.copytree(Path(config.setup.source_directory, "static"), Path(config.setup.dist_directory, "static"), dirs_exist_ok=True)
|
||||
|
||||
logger.info("reading page tree...")
|
||||
tree = ArticleOverview(directory=Path(config.setup.source_directory, "articles"))
|
||||
tree = ArticleOverview(directory=Path(config.setup.source_directory, "articles"), is_root=True)
|
||||
|
||||
# build article reverence values
|
||||
for article_overview in ARTICLE_LAKE.values():
|
||||
|
Loading…
x
Reference in New Issue
Block a user