feat: cleaned the logs and copy static
This commit is contained in:
parent
9859229101
commit
d412d983bd
@ -114,7 +114,6 @@ class ArticleOverview:
|
|||||||
self.slug = self.directory.name
|
self.slug = self.directory.name
|
||||||
|
|
||||||
self.article_written = self.directory.stat().st_mtime
|
self.article_written = self.directory.stat().st_mtime
|
||||||
print(self.article_written)
|
|
||||||
|
|
||||||
self.location_in_tree: List[str] = location_in_tree or []
|
self.location_in_tree: List[str] = location_in_tree or []
|
||||||
self.location_in_tree.append(self.slug)
|
self.location_in_tree.append(self.slug)
|
||||||
@ -145,6 +144,8 @@ class ArticleOverview:
|
|||||||
self.article_translations.sort(key=lambda a: a.priority, reverse=True)
|
self.article_translations.sort(key=lambda a: a.priority, reverse=True)
|
||||||
self.overview_cards = "\n".join(a.get_overview_card() for a in self.article_translations)
|
self.overview_cards = "\n".join(a.get_overview_card() for a in self.article_translations)
|
||||||
|
|
||||||
|
logger.info("found %s at %s with the translations %s", self.slug, ".".join(list(self.location_in_tree)), ",".join(self.article_translations_map.keys()))
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
# builds the tree structure to the dist directory
|
# builds the tree structure to the dist directory
|
||||||
self.dist_path.mkdir(parents=True, exist_ok=True)
|
self.dist_path.mkdir(parents=True, exist_ok=True)
|
||||||
@ -183,39 +184,6 @@ class ArticleOverview:
|
|||||||
return replace_values(TEMPLATE.overview, self._get_values())
|
return replace_values(TEMPLATE.overview, self._get_values())
|
||||||
|
|
||||||
|
|
||||||
def copy_static():
|
|
||||||
src = str(Path(config.setup.source_directory, "static"))
|
|
||||||
dst = str(Path(config.setup.dist_directory, "static"))
|
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(src):
|
|
||||||
logger.warn("The static folder '%s' wasn't defined.", src)
|
|
||||||
return
|
|
||||||
|
|
||||||
logger.info("copying static files from '%s' to '%r'", src, dst)
|
|
||||||
|
|
||||||
os.makedirs(dst, exist_ok=True)
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(src):
|
|
||||||
if any(p.startswith(".") for p in Path(root).parts):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Compute relative path from the source root
|
|
||||||
rel_path = os.path.relpath(root, src)
|
|
||||||
dest_dir = os.path.join(dst, rel_path)
|
|
||||||
|
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
for file in files:
|
|
||||||
if file.startswith("."):
|
|
||||||
continue
|
|
||||||
|
|
||||||
src_file = os.path.join(root, file)
|
|
||||||
dest_file = os.path.join(dest_dir, file)
|
|
||||||
shutil.copy2(src_file, dest_file)
|
|
||||||
|
|
||||||
|
|
||||||
# GLOBALS
|
# GLOBALS
|
||||||
logger = logging.getLogger("stsg.build")
|
logger = logging.getLogger("stsg.build")
|
||||||
TEMPLATE = Template(Path(config.setup.source_directory, "templates"))
|
TEMPLATE = Template(Path(config.setup.source_directory, "templates"))
|
||||||
@ -223,17 +191,19 @@ ARTICLE_LAKE: Dict[str, ArticleOverview] = {}
|
|||||||
ARTICLE_REFERENCE_VALUES: DefaultDict[str, Dict[str, str]] = defaultdict(dict)
|
ARTICLE_REFERENCE_VALUES: DefaultDict[str, Dict[str, str]] = defaultdict(dict)
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
logger.info("building static page")
|
logger.info("starting build process...")
|
||||||
|
|
||||||
copy_static()
|
logger.info("copying static folder...")
|
||||||
|
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"))
|
||||||
|
|
||||||
# build article reverence values
|
# build article reverence values
|
||||||
for article_overview in ARTICLE_LAKE.values():
|
for article_overview in ARTICLE_LAKE.values():
|
||||||
logger.info("found article %s", article_overview.slug)
|
|
||||||
|
|
||||||
ARTICLE_REFERENCE_VALUES[""].update(article_overview.get_article_values())
|
ARTICLE_REFERENCE_VALUES[""].update(article_overview.get_article_values())
|
||||||
for language_code, at in article_overview.article_translations_map.items():
|
for language_code, at in article_overview.article_translations_map.items():
|
||||||
ARTICLE_REFERENCE_VALUES[language_code].update(at.get_article_values())
|
ARTICLE_REFERENCE_VALUES[language_code].update(at.get_article_values())
|
||||||
|
|
||||||
|
logger.info("writing page tree...")
|
||||||
tree.build()
|
tree.build()
|
Loading…
x
Reference in New Issue
Block a user