Wordpress CPT x AFC: Post to PDF via SVG template fun

Description

Assume that the starting point is a wordpress site with a Custom Page Type (CPT) for video (custom-type-video.php). This custom type uses Advanced Custom Fields (AFC) to store meta-data, and a uses a template file (single-video.php) to display the page on the website.

For example, this page: Craig Wilkins.

Given this display of information for the web, how is this translated into an archival print form?

Here is an example of an archival print form in PDF for the same page. This is a three-page PDF file, created by concatenating 3 individual pages into the final file.

The first page of this PDF file is generated via an input SVG file. This SVG file, as created by Inkscape or Illustrator, is a long and messy text file.

Simplified, it looks much more straightforward:

svg open


text open
afc_video_title
text close

text open
afc_video_youtube_link
text cclose

svg close

The goal is to extract the information residing in the AFC fields of the wordpress site, and strip it in to the SVG template. So, for the AFC field video_title, query the wordpress database, get a result, and strip it in to the SVG text file where afc_video_title currently resides.

Do this for all the AFC fields.Then, once done, a SVG file for this specific post will be produced.

Then, take this SVG file and transform it to a PDF file via cairosvg or inkscape.

Assume linux as the underlying OS, and utilities like ghostsript, ffmpeg, etc.

Questions

Is there a way to serialize wordpress posts that use ACF? Right now I am seeing support for Local Json, aka afc-json, which is cool and all but only describes the field group being used, not the values for a particular page.

The afc-json for data file for the above page looks like: this.

POD Linux Workflow

Follow these steps with letter or A4 sized layouts. Assuming the input is generated via composition and abuse of pdfunite, and will be called base.pdf

This becomes necessary when the design parameters for the input PDF include a lot of custom typography, complex vector art, and other challenging graphic elements. All of these vector elements are rendered to raster formats at high resolution, and then those rasterized versions are used to print the file.

In order:

    1.  Adobe Acrobat Pro as a re-writer, and save off base-opt.pdf as input for the next step. (optional)
    2. Vector transform: 50% shrink quad-A4 to A4, and then 90-degree rotate from landscape to portrait A4-sized sheet. For USA, substitute letter size for A4. (aka ghostscript-scale-to-a4p-rotate-90-file.sh)
    3. Raster Vector to TIFF: 300 dpi raster versions of complex layouts mandatory for generated forms. (aka ghostscript-drop-each-page-to-pdf.sh)
    4. Convert TIFF to PDF (aka ghostscript-tiff-to-pdf.sh)
    5. Transform individual pages into single file. (aka pdfunite)
    6. Postscript smoothing and flattening. (aka ghostscript-flatten.sh)

The final output is a file transformed-flat.pdf that is used as input to the publisher or physical press.

 

ARP Etherpad Notes

Software configuration for commodity x86/86_64 linux art research platform.

Prerequisites

Assume Fedora 27. See base document for full software stack.

Etherpad Setup

Etherpad is a collaborating system for writing. Some required packages: Node.js

dnf install -y nodejs

Next, create a system-level user to checkout the etherpad sources and run the etherpad application. For this, use parseepad. After this is done, clone the repository.

cd /var/www;
git clone https://github.com/ether/etherpad-lite.git;

This will checkout sources in the following directory, which doubles as the installation location for this package: /var/www/etherpad-lite

To start up the etherpads, run

/var/www/etherpad-lite/bin/run.sh

And then open the following in a browser, to bring up the etherpad main page:

http://localhost:9100

Close the terminal or otherwise exit the etherpad process to continue installation.

Next, conversion to mysql database. Configure the etherpad database, called parse_pad_db.

mysqladmin create parse_pad_db -u root -p

Make a system database user parsepad, give it access to the etherpads’s database.

sudo mysql -D mysql -u root -p;

GRANT ALL PRIVILEGES ON parse_pad_db.* TO 'parsepad'@'localhost' IDENTIFIED BY 'yer-password-here';

FLUSH PRIVILEGES;

QUIT;

Next, edit /var/www/etherpad-lite/settings.json to tie in the database above:

  /* An Example of MySQL Configuration   */
   "dbType" : "mysql",
   "dbSettings" : {
                    "user"    : "parsepad",
                    "host"    : "localhost",
                    "password": "your-password-here",
                    "database": "parse_pad_db",
                    "charset" : "utf8mb4"
                  },

Next, go to the admin page and install some plugins:

http://0.0.0.0:9001/admin/plugins

Add the following

adminpads, bookmark, small_list, themes, font_color, font_family, font_size, print, copy_paste_images, sketchspace

Finally, restart the etherpad application and start making pads!

Main configuration file is: /var/www/etherpad-lite/settings.json

ARP Wiki Notes

Software configuration for commodity x86/86_64 linux art research platform.

Prerequisites

Assume Fedora 27. See base document for full software stack.

Wiki Setup

Use mediawiki packages.

dnf install -y mediawiki mediawiki-wikicalendar php-pecl-apcu php-pecl-apcu-bc

Notes for the platform are here, and the file /usr/share/doc/mediawiki/README.RPM.

Use /var/www/mediawiki/parse as the installation directory.

mkdir /var/www/mediawiki/parse
mw-createinstance /var/www/mediawiki/parse
chown -R apache:apache /var/www/mediawiki/parse
chcon -R system_u:object_r:httpd_sys_content_t:s0 /var/www/mediawiki/parse

and then edit the /etc/httpd/conf.d/mediawiki.conf file as

DocumentRoot /var/www/mediawiki/parse
Alias /skins /usr/share/mediawiki/skins

Next, configure the wiki database, called parse_wiki_db.

mysqladmin create parse_wiki_db -u root -p

Make a system database user parsewiki, give it access to the wiki’s database.

sudo mysql -D mysql -u root -p;

GRANT ALL PRIVILEGES ON parse_wiki_db.* TO 'parsewiki'@'localhost' IDENTIFIED BY 'yer-password-here';

FLUSH PRIVILEGES;

QUIT;

This should be enough setup to start the web-based wiki installation. Go to

http://localhost

And finish the setup. Some of the remaining configuration: wiki administrator user name and password, license terms for the wiki content, open or private wiki access, etc.

Skin and theme the wiki.

ARP Content Management System Notes

Software configuration for commodity x86/86_64 linux art research platform.

Prerequisites

Assume Fedora 27. See base document for full software stack.

CMS Setup

Use wordpress packages.

dnf install -y wordpress wordpress-plugin-bad-behavior wordpress-plugin-defaults python3-wordpress-xmlrpc

Configure as per these Fedora-specific notes. Also, read these Centos-7 notes.
Useful background material on WordPress is at the codex.

Recommended, but not essential packages:

dnf install -y php-pecl-imagick php-pecl-ssh2 php-opcache php-pecl-zendopcache php-pecl-apc

Configuration file for webserver-wordpress is: /etc/httpd/conf.d/wordpress.conf
Configuration file for wordpress is: /etc/wordpress/wp-config.php
Wordpress site files are:/usr/share/wordpress

Backup and Migration

To import a pre-existing site, there are a couple of options:

  • import/export via WordPress Admin Tools, may be the only option if not a hosted site
  • stage and backup with a plugin like Duplicator, JetPack, or BackUPup
  • dealing with the archive files that a hosting service provides

For sites that have export files over the default 2M, a bit of tweaking is necessary to import the export file (WXR) in its entirety. First, find out where the active php.ini file is:

php -i | grep "Loaded Configuration File"
Loaded Configuration File => /etc/php.ini

So, edit this file to change the value of upload_max_filesize to 64M and post_max_sizelike so:

 upload_max_filesize = 64M
 post_max_size = 128M

That out of the way, let the migration/backup process continue!

For option 1 above, the simplest import/export via builtin tools:
install the import plugin. See the importing content part of the wordpress codex.

For option 2 above, use the Duplicator plugin. First, install it on the active site by copying the zip file into */public_html/content/plugins. Activate it on the admin page of WordPress, and make an archive by following the on-screen conditions.

The Duplicator plugin requires some server-side capabilities. Make sure that php.ini has the following extensions enabled:

extension=zip.so
extension=mysqli.so

Once everything is working, the Duplicator plugin produces an archive file and a installation.php file. Download these and transfer them to the test site.

ARP Webserver Notes

Software configuration for commodity x86/86_64 linux art research platform.

Prerequisites

Assume Fedora 27. See base document for full software stack.

Webserver Setup

Assume physical access to the server hardware, that there is a default install of the operating system, that the network is up, and that the static IP address of the server is 192.168.1.52. For any of the commands below, assume the root user or use of sudo.

Use the Apache httpd package. See the section of the Fedora System Administration Guide on Web Servers for background, and a quick install notes at Fedora magazine. After, read the getting started notes.

dnf install -y httpd mod_ssl

Then configure the webserver to start at boot via

systemctl enable httpd.service

And punch holes through the firewall to allow incoming traffic on port 80 and 443

 firewall-cmd --permanent --add-service=http --add-service=https 

Then, a bit of fun to enable the webserver for other computers, aka enabling access to web applications in Fedora-speak. The authorization file is /etc/httpd/conf.d/webapp.conf, so add a new config file that loads after this to broaden access. Say, /etc/httpd/conf.d/z-webapp-allow.conf with the following

    
        # Apache 2.4
        Require all granted
    
    
        # Apache 2.2
        Order Deny,Allow
        Allow from all
    

At this point, using either of the chrome or firefox browsers on the server’s desktop should show a default webserver welcome page when

http://localhost

is entered into the search bar. To check that the webserver is working for other computers, try to view it on another computer. For instance, try

http://192.168.1.52

on both computers. The generated page should look the same. If so, congratulations, the first of part of setup is completed.

Additional SELinux efforts:

setsebool -P httpd_graceful_shutdown 1;
setsebool -P httpd_can_network_connect 1;

Configure the webserver to allow mod_rewrite so that wordpress can make more legible permalinks.
Find the part of the main configuration file (as below) and change the directory block to have AllowOverride All.

To check the configuration of the webserver, post-hacking, use

apachectl configtest

Main configuration file is: /etc/httpd/conf/httpd.conf
Configuration file for the first page is: /etc/httpd/conf.d/welcome.conf
Apache site files are found: /var/www/html/
Apache log file: /var/log/httpd/error_log

ARP Database Notes

Software configuration for commodity x86/86_64 linux art research platform.

Prerequisites

Assume Fedora 27. See base document for full software stack.

Database Setup 1: server mysql

Both the wiki and wordpress require a database. So, pick the MySQL database, which is packaged as mariadb on Fedora. Project page for MariaDB.

dnf install -y mariadb mariadb-server php-mysqlnd phpMyAdmin

Secure it (and set the root password on the database) with

mysql_secure_installation

And enable and start it via

systemctl enable mariadb.service
systemctl start mariadb.service

To use the web-ui to administer, go to

http://localhost/phpmyadmin/

Configuration file is: /etc/my.cnf
Log file is:/var/log/mariadb/mariadb.log
The site files are in prefix:/var/lib/mysql

Database Setup 2: per-user postgressql

For non-platform use, aka for individual users, pick the glom front-end for the postgres database. Some platform notes are here.

dnf install -y postgresql postgresql-server postgresql-libs postgresql-contrib phpPgAdmin

Initialize the database

postgresql-setup --initdb --unit postgresql

Then enable and start

systemctl enable postgresql
systemctl start postgresql

To use the web-ui to administer, go to

http://localhost:8080/phppgadmin

There is a graphical database called glom that is similar to FileMakerPro on the mac and Access on windows.

dnf install -y glom