diff --git a/generate.py b/generate.py index 92d2aba..e8425d7 100644 --- a/generate.py +++ b/generate.py @@ -2,6 +2,7 @@ """Renders my blog.""" import glob import os +import re import shutil from datetime import datetime @@ -39,7 +40,7 @@ class Page(TypedDict): # Brief introductory comment above at the start of a page author_comment: NotRequired[str] # YYYY-MM-DD date of the page - date: str + date: NotRequired[str] # A brief summary of the page excerpt: str # The rendered HTML of the page @@ -50,7 +51,7 @@ class Page(TypedDict): skip: NotRequired[bool] # The URL slug of the page slug: str - # The path to the source document of the page + # The path containing the source document of the page src: str # The template to use to render the page template: NotRequired[str] @@ -130,7 +131,7 @@ def save_html(pages: list[Page]): """Save every page as an HTML document.""" for page in pages: in_tree = page["src"] - out_tree = join(OUT_DIR, os.path.basename(in_tree)) + out_tree = join(OUT_DIR, page["slug"]) print("Saving", out_tree) tmpl_name = page.get("template", "page.mako") @@ -185,9 +186,14 @@ def execute(self, path: str, page: Page): # if "author_comment" in page: # page["author_comment"] = self.md.convert(page["author_comment"]) page["src"] = path - page["slug"] = os.path.basename(path) + page["slug"] = self._build_page_slug(page) page["html"] = html + def _build_page_slug(self, page: Page): + """Build a slug for the page using the non-date portion of the subdirector.""" + slug = os.path.basename(page["src"]) + return m.group(1) if (m := re.match(r"\d{8}-(.*)", slug)) is not None else slug + def _build_excerpt(self, text: str): """Build an excerpt from the first non-blank line after the first blank line separating the metadata from the content of the doc.""" diff --git a/pages/yes-this-too-shall-pass/index.md b/pages/20070601-yes-this-too-shall-pass/index.md similarity index 100% rename from pages/yes-this-too-shall-pass/index.md rename to pages/20070601-yes-this-too-shall-pass/index.md diff --git a/pages/oh-the-places-youll-go/index.md b/pages/20070617-oh-the-places-youll-go/index.md similarity index 100% rename from pages/oh-the-places-youll-go/index.md rename to pages/20070617-oh-the-places-youll-go/index.md diff --git a/pages/dapper/index.md b/pages/20070707-dapper/index.md similarity index 100% rename from pages/dapper/index.md rename to pages/20070707-dapper/index.md diff --git a/pages/android-speech-synth-where-are-you/index.md b/pages/20071218-android-speech-synth-where-are-you/index.md similarity index 100% rename from pages/android-speech-synth-where-are-you/index.md rename to pages/20071218-android-speech-synth-where-are-you/index.md diff --git a/pages/spatial-pulseaudio/index.md b/pages/20080101-spatial-pulseaudio/index.md similarity index 100% rename from pages/spatial-pulseaudio/index.md rename to pages/20080101-spatial-pulseaudio/index.md diff --git a/pages/validate-your-accessibility/index.md b/pages/20080116-validate-your-accessibility/index.md similarity index 100% rename from pages/validate-your-accessibility/index.md rename to pages/20080116-validate-your-accessibility/index.md diff --git a/pages/maze-day-2008/index.md b/pages/20080430-maze-day-2008/index.md similarity index 100% rename from pages/maze-day-2008/index.md rename to pages/20080430-maze-day-2008/index.md diff --git a/pages/python-weak-references/index.md b/pages/20080430-python-weak-references/index.md similarity index 100% rename from pages/python-weak-references/index.md rename to pages/20080430-python-weak-references/index.md diff --git a/pages/rich-audio-muds/index.md b/pages/20080529-rich-audio-muds/index.md similarity index 100% rename from pages/rich-audio-muds/index.md rename to pages/20080529-rich-audio-muds/index.md diff --git a/pages/clique/index.md b/pages/20080801-clique/index.md similarity index 100% rename from pages/clique/index.md rename to pages/20080801-clique/index.md diff --git a/pages/tidbit-dohrobot-initialization/index.md b/pages/20090313-tidbit-dohrobot-initialization/index.md similarity index 100% rename from pages/tidbit-dohrobot-initialization/index.md rename to pages/20090313-tidbit-dohrobot-initialization/index.md diff --git a/pages/spaceship/index.md b/pages/20090524-spaceship/index.md similarity index 100% rename from pages/spaceship/index.md rename to pages/20090524-spaceship/index.md diff --git a/pages/creating-an-accessible-internationalized-dojo-rating-widget/index.md b/pages/20090828-creating-an-accessible-internationalized-dojo-rating-widget/index.md similarity index 100% rename from pages/creating-an-accessible-internationalized-dojo-rating-widget/index.md rename to pages/20090828-creating-an-accessible-internationalized-dojo-rating-widget/index.md diff --git a/pages/gtkbuilderglade-on-ironpython/index.md b/pages/20090828-gtkbuilderglade-on-ironpython/index.md similarity index 100% rename from pages/gtkbuilderglade-on-ironpython/index.md rename to pages/20090828-gtkbuilderglade-on-ironpython/index.md diff --git a/pages/pyttsx/index.md b/pages/20091122-pyttsx/index.md similarity index 100% rename from pages/pyttsx/index.md rename to pages/20091122-pyttsx/index.md diff --git a/pages/spaceship-code-at-github/index.md b/pages/20091128-spaceship-code-at-github/index.md similarity index 100% rename from pages/spaceship-code-at-github/index.md rename to pages/20091128-spaceship-code-at-github/index.md diff --git a/pages/ken-burns-effect-in-dojo/index.md b/pages/20091130-ken-burns-effect-in-dojo/index.md similarity index 100% rename from pages/ken-burns-effect-in-dojo/index.md rename to pages/20091130-ken-burns-effect-in-dojo/index.md diff --git a/pages/jsonic-speech-and-sound-using-html5/index.md b/pages/20100510-jsonic-speech-and-sound-using-html5/index.md similarity index 100% rename from pages/jsonic-speech-and-sound-using-html5/index.md rename to pages/20100510-jsonic-speech-and-sound-using-html5/index.md diff --git a/pages/uncopenweb-on-github/index.md b/pages/20100926-uncopenweb-on-github/index.md similarity index 100% rename from pages/uncopenweb-on-github/index.md rename to pages/20100926-uncopenweb-on-github/index.md diff --git a/pages/new-hosting-blog-cleanup/index.md b/pages/20101222-new-hosting-blog-cleanup/index.md similarity index 100% rename from pages/new-hosting-blog-cleanup/index.md rename to pages/20101222-new-hosting-blog-cleanup/index.md diff --git a/pages/switch-to-blogofile/index.md b/pages/20101226-switch-to-blogofile/index.md similarity index 100% rename from pages/switch-to-blogofile/index.md rename to pages/20101226-switch-to-blogofile/index.md diff --git a/pages/til-python-operator/index.md b/pages/20101227-til-python-operator/index.md similarity index 100% rename from pages/til-python-operator/index.md rename to pages/20101227-til-python-operator/index.md diff --git a/pages/til-pip-git/index.md b/pages/20101228-til-pip-git/index.md similarity index 100% rename from pages/til-pip-git/index.md rename to pages/20101228-til-pip-git/index.md diff --git a/pages/pyttsx-on-github/index.md b/pages/20101231-pyttsx-on-github/index.md similarity index 100% rename from pages/pyttsx-on-github/index.md rename to pages/20101231-pyttsx-on-github/index.md diff --git a/pages/virtualenv-bootstrapping/index.md b/pages/20110102-virtualenv-bootstrapping/index.md similarity index 100% rename from pages/virtualenv-bootstrapping/index.md rename to pages/20110102-virtualenv-bootstrapping/index.md diff --git a/pages/scp-backward/index.md b/pages/20110110-scp-backward/index.md similarity index 100% rename from pages/scp-backward/index.md rename to pages/20110110-scp-backward/index.md diff --git a/pages/handlerbag-on-github/index.md b/pages/20110123-handlerbag-on-github/index.md similarity index 100% rename from pages/handlerbag-on-github/index.md rename to pages/20110123-handlerbag-on-github/index.md diff --git a/pages/til-dojo-deferred-errbacks/index.md b/pages/20110206-til-dojo-deferred-errbacks/index.md similarity index 100% rename from pages/til-dojo-deferred-errbacks/index.md rename to pages/20110206-til-dojo-deferred-errbacks/index.md diff --git a/pages/til-virtualenv-supervisord/index.md b/pages/20110214-til-virtualenv-supervisord/index.md similarity index 100% rename from pages/til-virtualenv-supervisord/index.md rename to pages/20110214-til-virtualenv-supervisord/index.md diff --git a/pages/introducing-open-coweb/index.md b/pages/20110425-introducing-open-coweb/index.md similarity index 100% rename from pages/introducing-open-coweb/index.md rename to pages/20110425-introducing-open-coweb/index.md diff --git a/pages/my-ipad-is-my-copilot/index.md b/pages/20110605-my-ipad-is-my-copilot/index.md similarity index 100% rename from pages/my-ipad-is-my-copilot/index.md rename to pages/20110605-my-ipad-is-my-copilot/index.md diff --git a/pages/my-ipad-is-my-copilot/instapaper-article.jpg b/pages/20110605-my-ipad-is-my-copilot/instapaper-article.jpg similarity index 100% rename from pages/my-ipad-is-my-copilot/instapaper-article.jpg rename to pages/20110605-my-ipad-is-my-copilot/instapaper-article.jpg diff --git a/pages/my-ipad-is-my-copilot/instapaper-home.png b/pages/20110605-my-ipad-is-my-copilot/instapaper-home.png similarity index 100% rename from pages/my-ipad-is-my-copilot/instapaper-home.png rename to pages/20110605-my-ipad-is-my-copilot/instapaper-home.png diff --git a/pages/two-years/index.md b/pages/20130507-two-years/index.md similarity index 100% rename from pages/two-years/index.md rename to pages/20130507-two-years/index.md diff --git a/pages/two-years/j4.jpg b/pages/20130507-two-years/j4.jpg similarity index 100% rename from pages/two-years/j4.jpg rename to pages/20130507-two-years/j4.jpg diff --git a/pages/watch-vagrant-changes/index.md b/pages/20131107-watch-vagrant-changes/index.md similarity index 100% rename from pages/watch-vagrant-changes/index.md rename to pages/20131107-watch-vagrant-changes/index.md diff --git a/pages/password-store-osx/index.md b/pages/20140108-password-store-osx/index.md similarity index 100% rename from pages/password-store-osx/index.md rename to pages/20140108-password-store-osx/index.md diff --git a/pages/a-reveal.js-docker-base-image-with-onbuild/index.md b/pages/20140220-a-reveal.js-docker-base-image-with-onbuild/index.md similarity index 100% rename from pages/a-reveal.js-docker-base-image-with-onbuild/index.md rename to pages/20140220-a-reveal.js-docker-base-image-with-onbuild/index.md diff --git a/pages/whispers-of-test-failures/index.md b/pages/20140419-whispers-of-test-failures/index.md similarity index 100% rename from pages/whispers-of-test-failures/index.md rename to pages/20140419-whispers-of-test-failures/index.md diff --git a/pages/docker-registry-softlayer-object-storage/index.md b/pages/20140622-docker-registry-softlayer-object-storage/index.md similarity index 100% rename from pages/docker-registry-softlayer-object-storage/index.md rename to pages/20140622-docker-registry-softlayer-object-storage/index.md diff --git a/pages/my-blog-on-docker-ipython/index.ipynb b/pages/20140713-my-blog-on-docker-ipython/index.ipynb similarity index 100% rename from pages/my-blog-on-docker-ipython/index.ipynb rename to pages/20140713-my-blog-on-docker-ipython/index.ipynb diff --git a/pages/my-blog-on-docker-ipython/index.md b/pages/20140713-my-blog-on-docker-ipython/index.md similarity index 100% rename from pages/my-blog-on-docker-ipython/index.md rename to pages/20140713-my-blog-on-docker-ipython/index.md diff --git a/pages/exploration-of-airline-on-time-performance/index.ipynb b/pages/20141021-exploration-of-airline-on-time-performance/index.ipynb similarity index 100% rename from pages/exploration-of-airline-on-time-performance/index.ipynb rename to pages/20141021-exploration-of-airline-on-time-performance/index.ipynb diff --git a/pages/exploration-of-airline-on-time-performance/index.md b/pages/20141021-exploration-of-airline-on-time-performance/index.md similarity index 100% rename from pages/exploration-of-airline-on-time-performance/index.md rename to pages/20141021-exploration-of-airline-on-time-performance/index.md diff --git a/pages/control-read-write-access-docker-private-registry/index.md b/pages/20150207-control-read-write-access-docker-private-registry/index.md similarity index 100% rename from pages/control-read-write-access-docker-private-registry/index.md rename to pages/20150207-control-read-write-access-docker-private-registry/index.md diff --git a/pages/4-ways-to-extend-jupyter-notebook/index.md b/pages/20150719-4-ways-to-extend-jupyter-notebook/index.md similarity index 100% rename from pages/4-ways-to-extend-jupyter-notebook/index.md rename to pages/20150719-4-ways-to-extend-jupyter-notebook/index.md diff --git a/pages/code-hiding-on-nbviewer/index.md b/pages/20160408-code-hiding-on-nbviewer/index.md similarity index 100% rename from pages/code-hiding-on-nbviewer/index.md rename to pages/20160408-code-hiding-on-nbviewer/index.md diff --git a/pages/bluemix-insights-for-weather/index.md b/pages/20160414-bluemix-insights-for-weather/index.md similarity index 100% rename from pages/bluemix-insights-for-weather/index.md rename to pages/20160414-bluemix-insights-for-weather/index.md diff --git a/pages/flatten-nested-json-with-pandas/index.ipynb b/pages/20160609-flatten-nested-json-with-pandas/index.ipynb similarity index 100% rename from pages/flatten-nested-json-with-pandas/index.ipynb rename to pages/20160609-flatten-nested-json-with-pandas/index.ipynb diff --git a/pages/flatten-nested-json-with-pandas/index.md b/pages/20160609-flatten-nested-json-with-pandas/index.md similarity index 100% rename from pages/flatten-nested-json-with-pandas/index.md rename to pages/20160609-flatten-nested-json-with-pandas/index.md diff --git a/pages/jupyter-tidbit-run-ipynb-files/index.md b/pages/20180821-jupyter-tidbit-run-ipynb-files/index.md similarity index 100% rename from pages/jupyter-tidbit-run-ipynb-files/index.md rename to pages/20180821-jupyter-tidbit-run-ipynb-files/index.md diff --git a/pages/jupyter-tidbit-run-ipynb-files/index.yml b/pages/20180821-jupyter-tidbit-run-ipynb-files/index.yml similarity index 100% rename from pages/jupyter-tidbit-run-ipynb-files/index.yml rename to pages/20180821-jupyter-tidbit-run-ipynb-files/index.yml diff --git a/pages/jupyter-tidbit-clear-outputs/index.md b/pages/20180822-jupyter-tidbit-clear-outputs/index.md similarity index 100% rename from pages/jupyter-tidbit-clear-outputs/index.md rename to pages/20180822-jupyter-tidbit-clear-outputs/index.md diff --git a/pages/jupyter-tidbit-binder-from-browser/index.md b/pages/20180823-jupyter-tidbit-binder-from-browser/index.md similarity index 100% rename from pages/jupyter-tidbit-binder-from-browser/index.md rename to pages/20180823-jupyter-tidbit-binder-from-browser/index.md diff --git a/pages/jupyter-tidbit-kernels-for-text-files/index.md b/pages/20180824-jupyter-tidbit-kernels-for-text-files/index.md similarity index 100% rename from pages/jupyter-tidbit-kernels-for-text-files/index.md rename to pages/20180824-jupyter-tidbit-kernels-for-text-files/index.md diff --git a/pages/jupyter-tidbit-run-and-say-done/index.md b/pages/20180827-jupyter-tidbit-run-and-say-done/index.md similarity index 100% rename from pages/jupyter-tidbit-run-and-say-done/index.md rename to pages/20180827-jupyter-tidbit-run-and-say-done/index.md diff --git a/pages/jupyter-tidbit-run-notebook-headlessly/index.md b/pages/20180905-jupyter-tidbit-run-notebook-headlessly/index.md similarity index 100% rename from pages/jupyter-tidbit-run-notebook-headlessly/index.md rename to pages/20180905-jupyter-tidbit-run-notebook-headlessly/index.md diff --git a/pages/jupyter-tidbit-ipython-slists/index.md b/pages/20180915-jupyter-tidbit-ipython-slists/index.md similarity index 100% rename from pages/jupyter-tidbit-ipython-slists/index.md rename to pages/20180915-jupyter-tidbit-ipython-slists/index.md diff --git a/pages/jupyter-tidbit-display-handles/index.md b/pages/20181103-jupyter-tidbit-display-handles/index.md similarity index 100% rename from pages/jupyter-tidbit-display-handles/index.md rename to pages/20181103-jupyter-tidbit-display-handles/index.md diff --git a/pages/jupyter-tidbit-config-paths/index.md b/pages/20190203-jupyter-tidbit-config-paths/index.md similarity index 100% rename from pages/jupyter-tidbit-config-paths/index.md rename to pages/20190203-jupyter-tidbit-config-paths/index.md diff --git a/pages/jupyter-tidbit-image-gallery/index.md b/pages/20191112-jupyter-tidbit-image-gallery/index.md similarity index 100% rename from pages/jupyter-tidbit-image-gallery/index.md rename to pages/20191112-jupyter-tidbit-image-gallery/index.md