diff --git a/lexipython/build.py b/lexipython/build.py index 75903d0..a8ea3f5 100644 --- a/lexipython/build.py +++ b/lexipython/build.py @@ -28,11 +28,21 @@ class LexiconPage: total_kwargs = {**self.kwargs, **kwargs} return self.skeleton.format(**total_kwargs) -def build_contents_page(page, articles, index_list): +def article_matches_index(index_type, pattern, article): + if index_type == "char": + return utils.titlesort(article.title)[0].upper() in pattern.upper() + if index_type == "prefix": + return article.title.startswith(pattern) + if index_type == "etc": + return True + raise ValueError("Unknown index type: '{}'".format(index_type)) + +def build_contents_page(config, page, articles): """ Builds the full HTML of the contents page. """ content = "
" + # Head the contents page with counts of written and phantom articles phantom_count = len([article for article in articles if article.player is None]) if phantom_count == 0: @@ -40,32 +50,68 @@ def build_contents_page(page, articles, index_list): else: content += "

There are {0} entries, {1} written and {2} phantom.

\n".format( len(articles), len(articles) - phantom_count, phantom_count) + # Prepare article links link_by_title = {article.title : "{0}".format( article.title, article.title_filesafe, " class=\"phantom\"" if article.player is None else "") for article in articles} - # Write the articles in alphabetical order - content += utils.load_resource("contents.html") - content += "
\n