Olive Press Archives Plugin

Our new church website uses WordPress to provide content for Web, Slideshow and Print. For print, we generate “The Olive Press” newsletter/bulletin for people to pick up on Sunday mornings. I wanted to provide an archive of previous print versions for archival purposes, so I wrote a script that uses Google Chrome’s –print-to-pdf command line option and uploads the PDF to a mo-media/op directory on the web site. In order to access these more easily, I created this new WordPress Plugin to show links to all the PDF files in reverse chronological order. As of this writing, you can download the plugin from here:

http://rinaldo.net/mount-olive-op-archives.zip

Installation

  1. Download serviceu-events-calendar.zip from the “download” link on the web page where you’re viewing this or from http://rinaldo.net/mount-olive-op-archives.zip (direct download link)
  2. Decompress the file contents.
  3. Upload the mount-olive-op-archives folder to your WordPress plugins directory (/wp-content/plugins/).
  4. Activate the Mount Olive OP Archives plugin from the WordPress Dashboard.
  5. You may now use the [op_archive] shortcode in a Page or Post.

Screenshots

See it in action http://mt-olive.org/the-olive-press-archives

Custom Script for Archiving PDFs

The shell script below is run weekly via a cron job on a CentOS 7.2 host with Google Chrome installed locally (with nss3/nspr4 libraries among others) at 5am Sunday mornings to archive a PDF copy to the web site.

#!/bin/sh
# The Olive Press Archiver - print to pdf and save eternally
adir=/local/website/mt-olive/mo-media/op
url="http://mt-olive.org/the-olive-press---print-edition"
mkdir /tmp/top.$$
cd /tmp/top.$$
/usr/local/bin/chrome --headless --disable-gpu --print-to-pdf "$url"
ts=`date +%Y-%m-%d`
ym=`date +%Y/%m`
mkdir -p $adir/$ym
cp output.pdf $adir/$ym/OP-$ts.pdf
/usr/local/bin/ncftpput -m -F -R -f ~/mologindetails /site/path/mo-media/op/$ym $adir/$ym/OP-$ts.pdf
echo Saved $url to http://mt-olive.org/mo-media/op/$ym/OP-$ts.pdf
cd /
rm -rf /tmp/top.$$
exit 0

The cron entry looks like this:

# Mn Hr Da Mo Wd Command
  00 05  *  *  0 /home/user/bin/top_archiver > /tmp/top_archiver.out 2>&1

The plugin will find the uploaded PDF files and display links to them automatically.