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.

Advertisements

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

IPFS Background

Background

Some info:
Stanford Seminar, IPFS and the Permanent Web, October 22, 2015.

Main problem points with current web: offline, distributed, permanence, security, speed, lack of richer communication protocols.

Merkle Web, Merkle Tree, Merkle Links: protocol to upgrade how the web works. Related to git’s merkledag. Instead of using a centralized address to locate, use a combination of data x hash function as the address, that way it can be shared.

A quick summary:

Taking a higher-level approach to network design, like Paul Baran and some of the earliest categorization of networks, as featured in 1964’s On Distributed Communications. See network designs for centralized, distributed, peer, isolated, etc.

There is also no ‘presence linking’ in the status quo, meaning that there isn’t a notion for a peer to announce itself in several transports, so that other peers can guarantee that it is always the same peer.

This is especially problematic when sharing media. Any file, any media: when shared on a centralized network, the total amount of data required to share is the size of the original media times multiplied by the number of shares (modulo caching, if be). Ten or 20x multiples are common.

The solution is a distributed web with content uniquely identified, so it can be properly served by multiple peers in a resilient manner. In addition, this works for disconnected, offline, and slow networks.

Instead, social platforms are throwing tons of capital to build walled gardens on centralized networks. Apps continue to dominate the mobile web.

Some hype:
TEDxSanFrancisco, The Next Internet Revolution, December, 2016.

There is documentation for the distributed web as a free gitbook, The Decentralized Web Primer.

Sources, Protocol Specifications

InterPlanetary File System wikipedia.

The IPFS Project, a hypermedia transport protocol project. Based on a network stack encoded in libp2p. See specs documentation here. The naming system is IPNS.

Online community is found here.

Part of Protocol Labs

Questions
what about other peer to peer networking libraries, namely libtorrent? libp2p design compare?

language bindings for libp2p are javascript, go, rust, python. What else is in development?

See Also

Dtube