From ed7ddb2dc7ec8b6d957125d0b889583a2b66417f Mon Sep 17 00:00:00 2001 From: Jim Shepich III Date: Mon, 2 Feb 2026 13:35:53 -0500 Subject: [PATCH] Moved home to index; added order to blog tag selector --- index.php | 47 -------------------------------- jimsite/blog.py | 34 +++++++++++------------ site/pages/{home.md => index.md} | 0 3 files changed, 17 insertions(+), 64 deletions(-) delete mode 100644 index.php rename site/pages/{home.md => index.md} (100%) diff --git a/index.php b/index.php deleted file mode 100644 index dc0525b..0000000 --- a/index.php +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - <?php - echo $page->name." | Jim Shepich"; - ?> - - -
- Jim Shepich III -
- -
- link)){ - echo ""; - //If the directory assigns the page to an external link, redirect to that location. - } - - if(isset($page->iframe)){ - echo ""; - //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. - } - - ?> -
- - - - diff --git a/jimsite/blog.py b/jimsite/blog.py index a596b82..5ec4c16 100644 --- a/jimsite/blog.py +++ b/jimsite/blog.py @@ -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]): diff --git a/site/pages/home.md b/site/pages/index.md similarity index 100% rename from site/pages/home.md rename to site/pages/index.md