From d1fdcd7598388b29199f92994d73c7ff20496b28 Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Wed, 30 Oct 2019 13:28:37 +0100 Subject: [PATCH] Add years to writings and sort based on them. --- scripts/transform-file.py | 25 +++++++++++++++++-------- site/Na.md | 1 + site/atem.md | 1 + site/digital-sikring.md | 3 +++ site/index.md | 4 +++- site/longpoem/index.md | 3 +++ site/magicng/index.md | 3 ++- site/myuniverse/index.md | 3 +++ site/nanonote/index.md | 3 +++ site/ordfinder/index.md | 3 +++ site/pvd/index.md | 3 +++ site/pygame-pycairo.md | 3 +++ site/sound-programming/index.md | 3 +++ site/stadig-digital-sikring.md | 3 +++ site/tfr/index.md | 3 +++ site/thesis/index.md | 1 + site/two-spaces.md | 3 +++ site/ugs/index.md | 3 +++ site/unhappy/index.md | 3 +++ 19 files changed, 64 insertions(+), 10 deletions(-) diff --git a/scripts/transform-file.py b/scripts/transform-file.py index 65bcd32..7d6ad06 100755 --- a/scripts/transform-file.py +++ b/scripts/transform-file.py @@ -53,7 +53,7 @@ def extract_markdown_title(filename): if filename.endswith('.md'): return os.path.basename(filename)[:-3] -def extract_markdown_abstract(filename): +def extract_markdown_yaml(filename): state = 0 with open(filename) as f: for line in f: @@ -66,7 +66,11 @@ def extract_markdown_abstract(filename): if y is None: return None else: - return y.get('abstract').strip().replace('\n', ' ') + if 'abstract' in y: + y['abstract'] = y.get('abstract').strip().replace('\n', ' ') + if 'lastupdated' in y: + y['lastupdated'] = int(y.get('lastupdated')) + return y else: yaml_block += line @@ -103,17 +107,22 @@ def markdown_to_html(input_file, output_dir): for page in pages: url, path = page ptitle = extract_markdown_title(path) - pabstract = extract_markdown_abstract(path) - pages_new.append((ptitle, pabstract, url, path)) + pyaml = extract_markdown_yaml(path) + pages_new.append((ptitle, pyaml, url, path)) - pages_new.append(('Potators', 'Do not look.', '/potator/', '/potator/')) + pages_new.append(('Potators', {'abstract': 'Do not look.', 'lastupdated': 2011}, '/potator/', '/potator/')) - pages_new.sort() + pages_new.sort(key=lambda p: (10000 - (p[1].get('lastupdated') or 10000), p[0])) md = '' for page in pages_new: - ptitle, pabstract, url, _ = page - if pabstract is None: + ptitle, pyaml, url, _ = page + if pyaml is None or pyaml.get('abstract') is None: pabstract = '(No description)' + else: + pabstract = pyaml['abstract'] + lu = pyaml.get('lastupdated') + if lu is not None: + pabstract += ' ({})'.format(lu) md += '[{}]({})\n ~ {}\n\n'.format(ptitle, url, pabstract) content = pandoc_stdin(input_base.replace('SPECIAL:ARTICLES', md)) diff --git a/site/Na.md b/site/Na.md index 73cf900..c82eb10 100644 --- a/site/Na.md +++ b/site/Na.md @@ -1,5 +1,6 @@ --- abstract: A new spoken and written language not in development. +lastupdated: 2011 --- # Na diff --git a/site/atem.md b/site/atem.md index 2e77ff2..9bce3be 100644 --- a/site/atem.md +++ b/site/atem.md @@ -1,5 +1,6 @@ --- abstract: A presentation of the new word 'atem' and why it's so desperately needed +lastupdated: 2012 --- # Atem: a new word diff --git a/site/digital-sikring.md b/site/digital-sikring.md index ef55e28..d1a376f 100644 --- a/site/digital-sikring.md +++ b/site/digital-sikring.md @@ -2,10 +2,13 @@ abstract: | A text about the failings of digital education and "copy protection". In Danish. +lastupdated: 2011 --- # Digital sikring mod gennemførsel af eksamen en realitet +*2011.* + Jeg sendte denne besked til Undervisningsministeriet som så fortalte mig at de skam nok var i gang med at gøre det nemmere for "Linus".. diff --git a/site/index.md b/site/index.md index 0cec204..740592e 100644 --- a/site/index.md +++ b/site/index.md @@ -3,7 +3,9 @@ This is the personal website of [Niels G. W. Serup](/about/niels). -## Articles +## Writings + +My writings are spurious. SPECIAL:ARTICLES diff --git a/site/longpoem/index.md b/site/longpoem/index.md index 2671549..8a40bbc 100644 --- a/site/longpoem/index.md +++ b/site/longpoem/index.md @@ -2,10 +2,13 @@ abstract: | (A Long Poem.) Et langt digt jeg skrev for noget tid siden fordi jeg ikke kan lide digte. +lastupdated: 2011 --- # Et langt digt +*2011.* + ![Forsiden](frontpage.png) [Download digtet i PDF.](longpoem.pdf) diff --git a/site/magicng/index.md b/site/magicng/index.md index ed970f3..2f14566 100644 --- a/site/magicng/index.md +++ b/site/magicng/index.md @@ -1,10 +1,11 @@ --- abstract: The Next Generation Programming Language +lastupdated: 2012 --- # MagicNG -*From 2012.* +*2012.* # Chapter 1: The Future of Yesterday diff --git a/site/myuniverse/index.md b/site/myuniverse/index.md index 36b32f0..d4d3951 100644 --- a/site/myuniverse/index.md +++ b/site/myuniverse/index.md @@ -1,9 +1,12 @@ --- abstract: I have attempted to define a universe. +lastupdated: 2013 --- # My Universe +*2013.* + Everything is much too complex, so I have defined a simpler universe. You can download v0.1 [here](myuniverse.pdf). diff --git a/site/nanonote/index.md b/site/nanonote/index.md index 826de06..a0995ac 100755 --- a/site/nanonote/index.md +++ b/site/nanonote/index.md @@ -1,9 +1,12 @@ --- abstract: I have a NanoNote. +lastupdated: 2011 --- # My NanoNote +*2011.* + ![Glorious NanoNote](glorious-nanonote.jpg) I own a [NanoNote](http://sharism.cc/). I think it's cool (though I diff --git a/site/ordfinder/index.md b/site/ordfinder/index.md index a12ec04..e076cb4 100644 --- a/site/ordfinder/index.md +++ b/site/ordfinder/index.md @@ -1,9 +1,12 @@ --- abstract: Less than perfect C code +lastupdated: 2013 --- # Old junk code: Word finder +*2013.* + ![Based on [this](https://commons.wikimedia.org/wiki/File:2001-91-1_Computer,_Laptop,_Pentagon_(5891422370).jpg), CC BY 2.0](sadcomputer.png) If you ever get tired of looking at your own junk code, take a look at this. diff --git a/site/pvd/index.md b/site/pvd/index.md index a9aaff2..d90fe6a 100644 --- a/site/pvd/index.md +++ b/site/pvd/index.md @@ -1,9 +1,12 @@ --- abstract: An old story +lastupdated: 2011 --- # Profeten, doktoren og videnskabsmanden +*2011.* + "Profeten, doktoren og videnskabsmanden" ("The Prophet, the Doctor and the Scientist") is a short nonsensical story in Danish by Niels. It is available under CC BY-SA 3.0+ as an A5-sized pdf. diff --git a/site/pygame-pycairo.md b/site/pygame-pycairo.md index 3563514..e08bac6 100644 --- a/site/pygame-pycairo.md +++ b/site/pygame-pycairo.md @@ -1,9 +1,12 @@ --- abstract: How to combine two Pythonic graphical frameworks +lastupdated: 2011 --- # Combining PyGame and PyCairo +*2011. Most likely very outdated.* + **Note:** See [http://pygame.org/wiki/CairoPygame](http://pygame.org/wiki/CairoPygame) for other examples. diff --git a/site/sound-programming/index.md b/site/sound-programming/index.md index 4131a0d..1b09325 100644 --- a/site/sound-programming/index.md +++ b/site/sound-programming/index.md @@ -1,9 +1,12 @@ --- abstract: Programming sound in Live-Sequencer and ChucK +lastupdated: 2013 --- # Sound Programming +*2013.* + Much can be programmed, and that includes sound. In the digital world, sound is typically represented by sequences of about 90 kB per second, so "printing" sound is merely a matter of printing bytes. As such, any diff --git a/site/stadig-digital-sikring.md b/site/stadig-digital-sikring.md index 49d9015..8db6fe7 100644 --- a/site/stadig-digital-sikring.md +++ b/site/stadig-digital-sikring.md @@ -2,8 +2,11 @@ abstract: | A text about the continuing failings of digital education and "copy protection". In Danish. +lastupdated: 2011 --- +*2011.* + Jeg sendte denne besked til Undervisningsministeriet som så forklarede at de var nødt til at bruge kopisikring fordi de brugte tekst, billeder og video fra eksterne kilder (såsom BBC). Det må være muligt for dem at lave bedre aftaler i diff --git a/site/tfr/index.md b/site/tfr/index.md index 255eea9..a716466 100644 --- a/site/tfr/index.md +++ b/site/tfr/index.md @@ -1,9 +1,12 @@ --- abstract: An old story +lastupdated: 2011 --- # The Trasbexian Flow Regulator +*2011.* + "The Trasbexian Flow Regulator" is a short story by Niels. It is available under CC BY-SA 3.0+ as an A5-sized 12-paged pdf. diff --git a/site/thesis/index.md b/site/thesis/index.md index 3d76f8a..a8414d4 100644 --- a/site/thesis/index.md +++ b/site/thesis/index.md @@ -1,5 +1,6 @@ --- abstract: My master's thesis, including an overview of it in Danish. +lastupdated: 2017 --- # My Master's Thesis diff --git a/site/two-spaces.md b/site/two-spaces.md index 7eecfa8..1d615d6 100644 --- a/site/two-spaces.md +++ b/site/two-spaces.md @@ -1,9 +1,12 @@ --- abstract: Not one. +lastupdated: 2015 --- # Two spaces +*2015.* + When I end a sentence and intend on writing a new, I type two spaces instead of one. diff --git a/site/ugs/index.md b/site/ugs/index.md index 5eff51c..80bbd81 100644 --- a/site/ugs/index.md +++ b/site/ugs/index.md @@ -1,5 +1,6 @@ --- abstract: Wrote it because it was fun, stopped when it was not fun anymore. +lastupdated: 2012 --- ![Front page](frontpage.png) @@ -8,6 +9,8 @@ abstract: Wrote it because it was fun, stopped when it was not fun anymore. # Unnamed Good Story +*2012.* + 1. Good (it's in the title) 2. 9 word-packed chapters full of words 3. Good, simple language diff --git a/site/unhappy/index.md b/site/unhappy/index.md index fea83b5..16d61f7 100644 --- a/site/unhappy/index.md +++ b/site/unhappy/index.md @@ -1,5 +1,6 @@ --- abstract: Rant about Haskell's parser "Happy". +lastupdated: 2014 --- ![](UNHAPPY.PNG) @@ -7,6 +8,8 @@ abstract: Rant about Haskell's parser "Happy". # Unhappy About Happy: A Reflection or Something Like That +*2014.* + For the purposes of my quiet rage, this document will be written in all caps. I also will not use proper language. I won't even give suggestions on how to improve Happy; I'll just complain.