diff options
author | Mike Gerwitz <mtg@gnu.org> | 2019-01-08 01:07:25 -0500 |
---|---|---|
committer | Mike Gerwitz <mtg@gnu.org> | 2019-01-16 23:44:24 -0500 |
commit | 9916ad55dc841dda824cdc3baace3606703c5637 (patch) | |
tree | 72c82399a028ea37be5c376623b66654df90f9cf /src | |
parent | b182ea79b3a7ac07f673870edab1bd3d6074c618 (diff) | |
download | thoughts-9916ad55dc841dda824cdc3baace3606703c5637.tar.gz thoughts-9916ad55dc841dda824cdc3baace3606703c5637.tar.bz2 thoughts-9916ad55dc841dda824cdc3baace3606703c5637.zip |
Generate slug from post filenames
Rather than having Pandoc generate the id, which has the potential to change
over time and cause 404s, let's just generate the slug from the filename so
that the ids will never change. This also solves the awkward question of
what the filename should be, since it was previously something arbitrary.
This mass rename was accomplished via this simple shell script:
for p in *.meta; do
slug=$( recsel -P slug "$p" | xargs basename )
mv -v "${p/.meta/.md}" "${p:0:10}-$slug.md"
done
with minor manual tweaks where I saw fit. Of course, now I have some pretty
long filenames, which is undesirable.
The next step is to compare it with the slugs currently on mikegerwitz.com
and make them match. That's the next commit, and should be pretty simple.
Diffstat (limited to 'src')
-rw-r--r-- | src/papers.rec | 14 | ||||
-rwxr-xr-x | src/post2meta | 8 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/papers.rec b/src/papers.rec index 966c6ec..137a620 100644 --- a/src/papers.rec +++ b/src/papers.rec @@ -1,6 +1,6 @@ id: git-horror-story type: post -ref: 2012-05-22-git-horror-story +ref: 2012-05-22-a-git-horror-story-repository-integrity-with-signed-commits id: coope type: latex @@ -14,7 +14,7 @@ pubdate: 2013-05-13 id: national-uproar type: post -ref: 2013-06-10-national-uproar +ref: 2013-06-10-national-uproar-a-comprehensive-overview-of-the-nsa-leaks-and-revelations id: gnu-kwindows type: post @@ -22,20 +22,20 @@ ref: 2016-04-06-gnu-kwindows id: gitlab-gitorious-freesw type: post -ref: 2015-05-20-gitlab-gitorious-freesw +ref: 2015-05-20-gitlab-gitorious-and-free-software id: copyleft-vs-community type: post -ref: 2013-08-13-copyleft-vs-community +ref: 2013-08-13-freebsd-clang-and-gcc-copyleft-vs-community id: re-fsf-waste-away type: post -ref: 2013-01-26-re-fsf-waste-high-priority +ref: 2013-01-26-re-fsf-wastes-away-another-high-priority-project id: vlc-lgpl type: post -ref: 2012-11-17-vlc-lgpl +ref: 2012-11-17-vlcs-move-to-lgpl id: re-skype-let-spy type: post -ref: 2013-01-30-re-skype-let-spy +ref: 2013-01-30-re-who-does-skype-let-spy diff --git a/src/post2meta b/src/post2meta index c50c97e..f00a483 100755 --- a/src/post2meta +++ b/src/post2meta @@ -50,9 +50,11 @@ main && /^<h1 / { # Grab the generated id from the header and use it to # generate a complete slug. - printf "slug: %s/%s\n", \ - gensub( /^([0-9]+)-([0-9]+).*$/, "\\1/\\2", "", name[0] ), \ - gensub( /^<h[^>]+ id="([^"]+)".*$/, "\\1", "" ) + printf "slug: %s\n", \ + gensub( /^([0-9]+)-([0-9]+)-[0-9]+-(.*)\.[a-z]+$/, + "\\1/\\2/\\3", + "", + name[0] ) # Skip the date line immediately following the header and grab the first # line of the abstract. |