Categories
WebOps

How to visualize blog schedule using terminal

Visualize the blog schedule using a terminal.

I have tried to use calendar and gcal, but these applications weren’t suitable for this task. There is also a khal, which is excellent, but only pal allow keeping things simple in this specific use case.

Install pal calendar with events.

$ sudo apt install pal

In this example, the repository that contains blog posts is stored in /srv/golb_oper/_posts/ directory.

$ ls -1 /srv/golb_oper/_posts/
[...]
/srv/golb_oper/_posts/2020-01-01-how-to-protect-system-against-accidental-shutdown.html
/srv/golb_oper/_posts/2020-01-06-how-to-supress-message-of-the-day.html
/srv/golb_oper/_posts/2020-01-09-how-to-display-lwn-news-using-message-of-the-day-framework.html
/srv/golb_oper/_posts/2020-01-13-how-to-stop-requests-with-empty-or-incorrect-host-header.html
/srv/golb_oper/_posts/2020-01-15-how-to-use-yum-without-downloading-or-updating-metadata.html
/srv/golb_oper/_posts/2020-01-17-how-to-serve-single-file-using-nginx.html
/srv/golb_oper/_posts/2020-01-20-how-to-manage-and-display-system-news.html
/srv/golb_oper/_posts/2020-01-22-how-to-mark-which-backend-server-is-used.html
/srv/golb_oper/_posts/2020-01-27-how-to-access-onedrive-on-debian.htm
[...]

Create a dedicated pal directory.

$ mkdir pal

Change the working directory.

$ cd pal

Create blog-pal.conf configuration file. I have removed settings that don’t have any impact on this use case.

##--------------------------------------------------------------------
## pal.conf file
##   Type "man pal" for more information about this file.
##
## Comments begin with #
##
## The latest copy of a 'template' pal.conf file can be found in
## /etc/pal.conf.  It describes every setting that can be changed in
## pal.conf.
##
##--------------------------------------------------------------------

file dynamic-blog.pal (red)

##--------------------------------------------------------------------
## Make weeks begin on monday

week_start_monday

##--------------------------------------------------------------------
## Display week numbers in output

show_weeknum

##--------------------------------------------------------------------
## Don't use columns when displaying the calendar

#no_columns

##--------------------------------------------------------------------
## Show lists of events in a more compact form (no spaces between
## days)

compact_list

##--------------------------------------------------------------------
## Date format used when compact_list is used
## Default: %m/%d/%Y
##
## The default writes the date in the American format.  Users in other
## countries might prefer using %d/%m/%Y

compact_date_fmt %d/%m/%Y

##--------------------------------------------------------------------
## If you get tired of always using -r, you can set the default value
## for -r here.  Note: Remember that this will affect what is
## displayed when -d and -s are used too.
## Default: 0
##
## Use the same thing thing after default_range that you use with -r.
## For example, if you always want to use '-r 1-2', use 'default_range
## 1-2'.  This value can be overridden by using -r at run-time.

default_range 1-30

(Re)Generate a calendar.

$ posts_dir=/srv/golb_oper/_posts; \
  echo "[] sleeplessbeastie.eu" > ~/pal/dynamic-blog.pal; \
  ls ${posts_dir}/*.html | \
    xargs -I {} basename {} | \
    awk -F- '{cmd="grep  ^title: '${posts_dir}'/"$0" | cut -d: -f2"; cmd | getline title; close(cmd);print $1 $2 $3 title}' >> ~/pal/dynamic-blog.pal

The calendar is just a plain text file, which is advantageous as it can be quickly modified or regenerated.

$ cat dynamic-blog.pal
[] sleeplessbeastie.eu
20101129 How to access CLI on Linksys SRW switch
20101129 How to use ImageMagick effects with Coppermine
20101201 Nginx and Gandi SSL certificate
20101201 Nginx proxy and real IP address
20101202 HTTPS Everywhere
20101203 Linux-like environment for Windows
20101203 Ruby and RMagick - Quote with Polaroid-like effect
20101203 Zen Photo and Nginx – rewrite rules
20101204 Hide posts from selected category on main WordPress page
[...]

Display calendar schedule and posts that will be published in the next 30 days.

$ pal -f ~/pal/blog-pal.conf -c 16
     Mo   Tu   We   Th   Fr   Sa   Su |     Mo   Tu   We   Th   Fr   Sa   Su
Dec [23]  24  [25]  26   27   28   29 |Apr [13]  14  [15]  16   17   18   19
Jan [30] @31@ [01]  02   03   04   05 | 16 [20]  21  [22]  23   24   25   26
  1 [06]  07   08  [09]  10   11   12 |May [27]  28  [29]  30   01   02   03
  2 [13]  14  [15]  16  [17]  18   19 | 18 [04]  05  [06]  07   08   09   10
  3 [20]  21  [22]  23   24   25   26 | 19 [11]  12  [13]  14  [15]  16   17
Feb [27]  28   29   30   31   01   02 | 20 [18]  19   20   21   22   23   24
  5 [03]  04  [05]  06   07   08   09 | 21 [25]  26   27   28   29   30   31
  6 [10]  11  [12]  13   14   15   16 |Jun [01]  02  [03]  04  [05]  06   07
  7 [17]  18   19   20   21   22   23 | 23 [08]  09   10   11   12   13   14
Mar [24]  25  [26]  27   28  [29]  01 | 24 [15]  16   17   18   19   20   21
  9 [02]  03  [04]  05  [06]  07   08 | 25 [22]  23   24   25   26   27   28
 10 [09]  10  [11]  12   13   14   15 |Jul  29   30   01   02   03   04   05
 11 [16]  17  [18]  19   20   21   22 | 27  06   07   08   09  [10]  11   12
 12  23   24   25   26   27   28   29 | 28  13   14   15   16  [17]  18   19
Apr [30]  31   01   02   03   04   05 | 29  20   21   22   23   24   25   26
 14 [06]  07  [08]  09   10   11   12 |Aug  27   28   29   30   31   01   02
* 30/12/2019 sleeplessbeastie.eu: How to display message after successful login
* 01/01/2020 sleeplessbeastie.eu: How to protect system against accidental shutdown
* 06/01/2020 sleeplessbeastie.eu: How to suppress message of the day
* 09/01/2020 sleeplessbeastie.eu: How to display LWN news using message of the day framework
* 13/01/2020 sleeplessbeastie.eu: How to stop requests with empty or incorrect host header
* 15/01/2020 sleeplessbeastie.eu: How to use yum without downloading or updating metadata
* 17/01/2020 sleeplessbeastie.eu: How to serve single file using nginx
* 20/01/2020 sleeplessbeastie.eu: How to manage and display system news
* 22/01/2020 sleeplessbeastie.eu: How to mark which backend server is used
* 27/01/2020 sleeplessbeastie.eu: How to access OneDrive on Debian

Display calendar schedule only.

$ pal -f ~/pal/blog-pal.conf -c 28 -r 0
     Mo   Tu   We   Th   Fr   Sa   Su |     Mo   Tu   We   Th   Fr   Sa   Su
Dec [23]  24  [25]  26   27   28   29 |Jul  06   07   08   09  [10]  11   12
Jan [30] @31@ [01]  02   03   04   05 | 28  13   14   15   16  [17]  18   19
  1 [06]  07   08  [09]  10   11   12 | 29  20   21   22   23   24   25   26
  2 [13]  14  [15]  16  [17]  18   19 |Aug  27   28   29   30   31   01   02
  3 [20]  21  [22]  23   24   25   26 | 31  03   04   05   06   07   08   09
Feb [27]  28   29   30   31   01   02 | 32  10   11   12   13   14   15   16
  5 [03]  04  [05]  06   07   08   09 | 33  17   18   19   20   21   22   23
  6 [10]  11  [12]  13   14   15   16 | 34  24   25   26   27   28   29   30
  7 [17]  18   19   20   21   22   23 |Sep  31   01   02   03   04   05   06
Mar [24]  25  [26]  27   28  [29]  01 | 36  07   08   09   10   11   12   13
  9 [02]  03  [04]  05  [06]  07   08 | 37  14   15   16   17   18   19   20
 10 [09]  10  [11]  12   13   14   15 | 38  21   22   23   24   25   26   27
 11 [16]  17  [18]  19   20   21   22 |Oct  28   29   30   01   02   03   04
 12  23   24   25   26   27   28   29 | 40  05   06   07   08   09   10   11
Apr [30]  31   01   02   03   04   05 | 41  12   13   14   15   16   17   18
 14 [06]  07  [08]  09   10   11   12 | 42  19   20   21   22   23   24   25
 15 [13]  14  [15]  16   17   18   19 |Nov  26   27   28   29   30   31   01
 16 [20]  21  [22]  23   24   25   26 | 44  02   03   04   05   06   07   08
May [27]  28  [29]  30   01   02   03 | 45  09   10   11   12   13   14   15
 18 [04]  05  [06]  07   08   09   10 | 46  16   17   18   19   20   21   22
 19 [11]  12  [13]  14  [15]  16   17 | 47  23   24   25   26   27   28   29
 20 [18]  19   20   21   22   23   24 |Dec  30   01   02   03   04   05   06
 21 [25]  26   27   28   29   30   31 | 49  07   08   09   10   11   12   13
Jun [01]  02  [03]  04  [05]  06   07 | 50  14   15   16   17   18   19  [20]
 23 [08]  09   10   11   12   13   14 | 51  21   22   23   24   25   26   27
 24 [15]  16   17   18   19   20   21 |Jan  28   29   30   31   01   02   03
 25 [22]  23   24   25   26   27   28 |  1  04   05   06   07   08   09   10
Jul  29   30   01   02   03   04   05 |  2  11   12   13   14   15   16   17

Display posts that will be published in a week after 20/May/2020.

$ pal -f ~/pal/blog-pal.conf -c 0 -d 20200520 -r 7
* 25/05/2020 sleeplessbeastie.eu: How to use High-Performance Erlang compiler with RabbitMQ

This allows me to keep an eye on a blog schedule and plan content ahead of time without leaving the terminal.