feat: properly building additional keywords
This commit is contained in:
parent
dc61a7ee92
commit
c45cebe497
@ -4,8 +4,9 @@ import shutil
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import markdown
|
import markdown
|
||||||
from typing import Optional, Union, Dict, Generator, List
|
from typing import Optional, Union, Dict, Generator, List, DefaultDict
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
from .config import SOURCE_DIRECTORY, DIST_DIRECTORY, LANGUAGE_INFORMATION, ARTICLE_PREVIEW_LENGTH, DEFAULT_LANGUAGE
|
from .config import SOURCE_DIRECTORY, DIST_DIRECTORY, LANGUAGE_INFORMATION, ARTICLE_PREVIEW_LENGTH, DEFAULT_LANGUAGE
|
||||||
|
|
||||||
@ -157,10 +158,7 @@ class ArticleOverview:
|
|||||||
"article_overview_cards": self.overview_cards,
|
"article_overview_cards": self.overview_cards,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_article_values(self, language_code: Optional[str] = None) -> Dict[str, str]:
|
def get_article_values(self) -> Dict[str, str]:
|
||||||
if language_code in self.article_translations_map:
|
|
||||||
return self.article_translations_map[language_code].get_article_values()
|
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
for key, value in self._get_values().items():
|
for key, value in self._get_values().items():
|
||||||
res[key + ":" + self.slug] = value
|
res[key + ":" + self.slug] = value
|
||||||
@ -208,13 +206,20 @@ def copy_static():
|
|||||||
logger = logging.getLogger("stsg.build")
|
logger = logging.getLogger("stsg.build")
|
||||||
TEMPLATE = Template(Path(SOURCE_DIRECTORY, "templates"))
|
TEMPLATE = Template(Path(SOURCE_DIRECTORY, "templates"))
|
||||||
ARTICLE_LAKE: Dict[str, ArticleOverview] = {}
|
ARTICLE_LAKE: Dict[str, ArticleOverview] = {}
|
||||||
|
ARTICLE_REFERENCE_VALUES: DefaultDict[str, Dict[str, str]] = defaultdict(dict)
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
logger.info("building static page")
|
logger.info("building static page")
|
||||||
|
|
||||||
copy_static()
|
copy_static()
|
||||||
tree = ArticleOverview(directory=Path(SOURCE_DIRECTORY, "pages"))
|
tree = ArticleOverview(directory=Path(SOURCE_DIRECTORY, "pages"))
|
||||||
|
|
||||||
|
# build article reverence values
|
||||||
|
for article_overview in ARTICLE_LAKE.values():
|
||||||
|
ARTICLE_REFERENCE_VALUES[None].update(article_overview.get_article_values())
|
||||||
|
for language_code, at in article_overview.article_translations_map.items():
|
||||||
|
ARTICLE_REFERENCE_VALUES[language_code].update(at.get_article_values())
|
||||||
|
|
||||||
print(ARTICLE_LAKE)
|
print(ARTICLE_REFERENCE_VALUES)
|
||||||
|
|
||||||
tree.build()
|
tree.build()
|
Loading…
x
Reference in New Issue
Block a user