Moved home to index; added order to blog tag selector

This commit is contained in:
Jim Shepich III 2026-02-02 13:35:53 -05:00
parent b24256a59e
commit ed7ddb2dc7
3 changed files with 17 additions and 64 deletions

View File

@ -1,47 +0,0 @@
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<script src="scripts/vendor/jquery-3.6.0.min.js"></script>
<script src="https://kit.fontawesome.com/09beb7ae4a.js" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="styles/reset.css">
<link rel="stylesheet" type="text/css" href="styles/common.css">
<link rel="stylesheet" type="text/css" href="styles/layout.css">
<link rel="stylesheet" type="text/css" href="styles/theme.css">
<?php include 'scripts/query_handler.php';?>
<title><?php
echo $page->name." | Jim Shepich";
?></title>
</head>
<body>
<header id="main-header" class="no-highlight">
<span class="silver-text">Jim Shepich III</span>
</header>
<nav id="main-navbar" class="no-highlight">
<?php include 'scripts/nav.php';?>
</nav>
<main>
<?php
if(isset($page->link)){
echo "<script>window.location.href = '".$page->link."'</script>";
//If the directory assigns the page to an external link, redirect to that location.
}
if(isset($page->iframe)){
echo "<iframe id='content' src='pages/".$page->file."'></iframe>";
//If the directory says to embed the page in an iframe, then do that.
} else {
echo file_get_contents(__DIR__ ."/pages/".$page->file);
//Otherwise, just write the HTML of the page in the content area.
}
?>
</main>
<footer>
<div id="socials" class="silver-text"><?php include 'scripts/footer.php';?></div>
</footer>
</body>
<script src="scripts/resize.js"></script>
</html>

View File

@ -7,11 +7,22 @@ from .articles import ArticleMetadata, Article, format_article_tags
from .templating import format_html_template, TemplateSelections
def build_tag_index(index: dict[str, Article]) -> dict[str, list[str]]:
def build_tag_index(index: dict[str, Article], wildcard ='*') -> dict[str, list[Article]]:
'''Creates an inverted index mapping each article tag to a postings list of articles
with said tag.'''
tag_index = {}
for article in index.values():
# Index the articles in ascending order of original publication date.
for article in sorted(index.values(), key = lambda a: a.metadata.date):
# Add all articles to the wildcard tag's postings list.
if wildcard is not None:
tag_index[wildcard] = (tag_index.get(wildcard,[])) + [article]
# Add the article to each of its tags' posting lists.
for tag in article.metadata.tags:
tag_index[tag] = (tag_index.get(tag,[])) + [article]
tag_index[tag] = (tag_index.get(tag,[])) + [article]
return tag_index
@ -51,7 +62,9 @@ def build_blog_archive(
display: list-item!important;
}}}}
''']
for tag, articles in ({'*': [*index.keys()]} | tag_index).items():
# Add tag selector options in descending order of article count.
for tag, articles in sorted(tag_index.items(), key = lambda item : -len(item[1])):
tag_selector_options.append(format_html_template(
template_selections['tag_selector_option'],
tag_name = tag,
@ -92,19 +105,6 @@ def build_blog_archive(
with open(f'{site.web_root.rstrip('/')}/archive.html', 'w') as f:
f.write(archive_html_page)
# TODO: create a tag inventory page, as well as individual browse-by-tag pages.
# def build_tag_inventory(
# site: SiteConfig,
# index: dict[str, tuple[str, str]],
# tag_index: dict[str, list[str]],
# template_selections: TemplateSelections
# ):
# tag_
def build_rss_feed(site: SiteConfig, index: dict[str, Article]):