<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>shell scripts &#8211; ptworld.net</title>
	<atom:link href="https://ptworld.net/blog/tag/shell-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>https://ptworld.net</link>
	<description>e-consultancy, research and publishing</description>
	<lastBuildDate>Tue, 13 Dec 2022 12:28:54 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Introducing MakeStaticSite for website deployment</title>
		<link>https://ptworld.net/blog/introducing-makestaticsite-for-website-deployment/</link>
		
		<dc:creator><![CDATA[Paul]]></dc:creator>
		<pubDate>Wed, 21 Sep 2022 14:53:20 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[MakeStaticSite]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[shell scripts]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://ptworld.net/?p=1504</guid>

					<description><![CDATA[(from a technical perspective) Launch of MakeStaticSite.sh Website November 2022: A website dedicated to MakeStaticSite is now available at https://makestaticsite.sh/. It provides the latest version of the software, released under AGPL, along with various documentation to help getting started. Motivation <a class="more-link" href="https://ptworld.net/blog/introducing-makestaticsite-for-website-deployment/">Read More ...</a>]]></description>
										<content:encoded><![CDATA[
<p>(from a technical perspective)</p>



<h2 class="wp-block-heading">Launch of MakeStaticSite.sh Website</h2>



<p><strong>November 2022</strong>: A website dedicated to MakeStaticSite is now available at <a rel="noreferrer noopener" href="https://makestaticsite.sh/" target="_blank">https://makestaticsite.sh/</a>.  It provides the latest version of the software, released under AGPL, along with various documentation to help getting started.</p>



<h2 class="wp-block-heading">Motivation</h2>



<p>The process of developing this website has evolved considerably.  On setting it up a few years ago in the conventional manner using WordPress, I duly familiarised myself with routines for maintaining security and improving performance on a hosted platform.  However, there were several aspects that weren&#8217;t ideal: the live content was hosted remotely, albeit with backups; updating the site <em>in situ</em>, particularly for major redesigns, was inconvenient; and performance wasn&#8217;t always as good as expected.  Observing that most of the content was not dynamic in nature, I resolved to develop the site locally and then, as a separate process, deliver it as a largely static site. </p>



<p>The rationale for generating static sites has been around a long-time; I first tackled this more than 20 years ago, when I needed to generate a <a href="https://ptworld.net/portfolio/multimedia-languages#CD2Go">CD ROM from a CGI/Perl multimedia website</a>.  Nowadays, the field is mature; <a rel="noreferrer noopener" href="https://www.netlify.com/blog/2018/07/12/the-reign-of-static-site-generators/" target="_blank">a Netlify blog post</a> (Netlify is a cloud-based service where many static outputs end up) gives many valid reasons, rooted in the need for more responsive work processes.  Typically underpinned by a simple language called <a rel="noreferrer noopener" href="https://www.w3schools.io/file/markdown-introduction/" target="_blank">markdown</a>, there has been a surge in solutions; hence, <a rel="noreferrer noopener" href="https://jamstack.org/generators/" target="_blank">options for Jamstack</a> abound.  However, the processes tend to be heavily oriented to developers at the expense of content authors, issues I know first-hand from enabling web access to museum collections.</p>



<p>I wanted instead to support existing content management processes, i.e. to continue with creating and managing content in WordPress, and then &#8216;at the press of a button&#8217; generate and publish a static copy online.  There are already some solutions, including dedicated plugins such as <a rel="noreferrer noopener" href="https://wordpress.org/plugins/simply-static/" target="_blank">Simply Static</a>.  Tim Nash, having observed increasingly complexity with the Jamstack options, <a rel="noreferrer noopener" href="https://timnash.co.uk/blog-like-a-confused-hacker-2020/" target="_blank">has described</a> how he used <a rel="noreferrer noopener" href="https://github.com/WP2Static/wp2static" target="_blank">WP2Static</a> via <a rel="noreferrer noopener" href="https://wp-cli.org" target="_blank">WP-CLI</a>, the WordPress command-line interface, for a (relatively) simple and compact solution.  But I hesitate over the use of a WordPress plugin to generate the static site.  Apart from the ongoing issue of maintenance and compatibility with WP Core, plugins are not really necessary since a public-facing website should be <em>de facto</em> crawlable by a web spider and not require internal system information.  </p>



<p>And so I turned to general-purpose tools I could run from the command line.  Enter <a rel="noreferrer noopener" href="https://www.gnu.org/software/wget/" target="_blank">Wget</a>, a ubiquitous utility for retrieving and packaging any number of web pages for subsequent viewing.  I needed to configure it, add a few additional inputs, and then choose where to store the outputs.  This led naturally to delving into (<a rel="noreferrer noopener" href="https://tiswww.case.edu/php/chet/bash/bashtop.html" target="_blank">Bash</a>) shell scripting to bring it all together and I continued the process, adding deployment options and invoking more commands, particularly <a rel="noreferrer noopener" href="https://wp-cli.org" target="_blank">WP-CLI</a> to prep the WordPress output (and to include a version of the plugin, <a rel="noreferrer noopener" href="https://github.com/paultraf/wp-static-search" target="_blank">WP Static Search</a>, revised to work offline).  If you examine the source code of this page, you will see the result.</p>



<h2 class="wp-block-heading">Pipeline</h2>



<p>Shell scripting became a means to orchestrate the overall process, which is readily seen as a <em>pipeline</em> comprising a sequence of <em>phases</em>.  For example, one phases runs <tt>wget</tt> for the initial capture, whilst another re-runs <tt>wget</tt> to more completely capture a site.  In fact, many core web development processes can be incorporated, such as replacing certain internal-facing pages or sections with alternative content; and invoking command-line tools for validation and streamlining output.  As of version 0.21, there are ten phases altogether; and command-line options allow you to control the start phase and end phase.</p>



<p>The flowchart below illustrates an emerging pipeline (for the latest perspective, please refer to pages on <a rel="noreferrer noopener" href="https://makestaticsite.sh/in-depth/workflow/" target="_blank">workflow</a> and <a rel="noreferrer noopener" href="https://makestaticsite.sh/in-depth/workflow/phases/" target="_blank">phases</a>).</p>



<div class="wp-block-cp-timeline-content-timeline-block Cool-Content-Timeline"><div class="cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484"><style scoped="true">.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body .story-time p{color: #333;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .story-time p{color: #333;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body::before{background: linear-gradient(to bottom, rgba(230, 230, 230, 0) 0%, #D91B3E 10%, #D91B3E 90%, rgba(230, 230, 230, 0) 100%);}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .timeline-content::before{background: #D91B3E;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .timeline-content::after{background: #D91B3E;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body .timeline-content::before{background: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body.left .story-details::after{background: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body.right .story-time::after{background: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body .timeline-content .timeline-block-icon{background: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .timeline-content .timeline-block-icon{background: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body.both-sided .timeline-content .position-right .story-details::before{border-right-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body.both-sided .timeline-content .position-left  .story-details::before{border-left-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body.one-sided.left .timeline-content  .story-details::before{border-right-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body.one-sided.right .timeline-content  .story-details::before{border-left-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body .timeline-content  .story-details{border-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .timeline-content .ctl-row .ctl-6.timeline-block-detail::before{border-bottom-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .ctl-6.timeline-block-detail{border-top-color: #D91B3E !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-vertical-timeline-body .timeline-content  .timeline-block-icon{border-color: #D91B3EFF !important;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .swiper-button-next{color: #D91B3E;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .swiper-button-prev{color: #D91B3E;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .cool-horizontal-timeline-body .swiper-pagination-bullet-active{background: #D91B3E;}.cool-timeline-block-9f4fed9e-b053-4040-999f-b8d7bd2d2484 .icon-true .timeline-block-icon span.timeline-block-render-icon svg{fill: white;}</style><div class="cool-vertical-timeline-body both-sided left"><div class="cool-timeline-block-list">
<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Setup</p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-image"><img decoding="async" src="https://ptworld.net/wp-content/uploads/2022/09/sample.cfg-part.png" alt="Extract from a sample configuration (text file) for MakeStaticSite shows options, row by row"/></div><div class="story-content"><h3>Configuration dialogue</h3><p>The first step is to run the <tt>setup.sh</tt> script, which guides the user in an interactive dialogue to specify a series of options. </p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Initialisation</p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Configure </h3><p>The system reads and processes configuration options<br><ul><li>read runtime options</li><li>read configuration file options</li><li>prepare output layout</li> </ul></p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Prep the CMS</p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>CMS-specific streamlining</h3><p>Optionally use wp-cli to<br><ul><li>ensure nice permalinks</li><li>remove query strings</li><li>remote shortlinks</li><li>replace with static search</li></ul>(Currently WordPress-only, but modules could be developed for other CMS.) </p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Generate static site  </p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Generate wget mirror (first run) </h3><p>Run wget with the supplied configuration options<br><ul><li>optionally incorporate further input files</li><li>optionally set up a zip files</li><li>store the mirror in its own directory with timestamp</li> </ul></p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Augment static site  </p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Further processing with wget </h3><p>Run wget with the supplied configuration options to fill in gaps<br><ul><li>optionally crawl static files for further URLs</li><li>Filter the URLs to retrieve only assets (multimedia files, etc.)</li><li>Re-run wget on the additional URLs</li></ul></p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Optimise static site  </p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Further post-processing for deployment </h3><p>Further post-wget processing<br><ul><li>convert feeds to be XML files and modify references accordingly</li><li>Apply HTML Tidy to make more standards-compliant and use pretty-print (dependent on options)</li></ul>An accessibility validator could be added here.</p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Create an offline zip archive</p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Create a custom zip based on the mirror</h3><p>The mirror acts as the basis for a zip archive, ready for uploading with the site or other distribution channels.</p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-left"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Augment</p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Further additions</h3><p>Optionally augment the static mirror with <em>snippets</em>, substituting chunks of HTML in particular places according to the use of snippet tags.  These will augment the zip file also.<br>Additionally, allow the inclusion of further files that might not necessarily be static files.</p></div></div></div></div></div></div>



<div class="wp-block-cp-timeline-content-timeline-block-child swiper-slide"><div class="timeline-content icon-false "><div class=" timeline-block-timeline ctl-row  position-right"><div class="ctl-6 timeline-block-time"><div class="story-time"><p>Deploy</p></div></div><div class="timeline-block-icon"></div><div class="ctl-6 timeline-block-detail"><div class="story-details"><div class="story-content"><h3>Finalise and deploy locally or remote </h3><p>Optionally copy over additional <br><ul><li>Optionally copy over additional files, which might be scripts to provide missing interactivity</li><li>Finally deploy on local or remote server using rsync</li></ul></p></div></div></div></div></div></div>
</div></div></div></div>



<h2 class="wp-block-heading">Extending the usefulness</h2>



<p>MakeStaticSite is a prototype that was initially developed for individuals who are creating and maintaining websites on a personal computer.  However, the question soon arose: how might a team of content authors and editors be supported?  (The answer is: yes!)</p>



<p>For example, what if this site is to have multiple contributors?  In this case, the most straightforward approach is to set up or continue hosting with a third-party hosting provider, in the usual way.  This means those who are creating and managing content carry on as normal through the dashboard.  The main change is to separate the editing environment from the public site, which can be achieved by restricting access by some means of web authentication.  Then, run MakeStaticSite to deploy the static site to the public, whether on the server or remotely.  This approach ensures continuity; the only additional consideration is how to initiate MakeStaticSite once changes have been made — from within the CMS or external to it?</p>



<p>An initial test has shown that once set up, the process of maintenance and deployment can be carried out entirely from within WordPress.  This can be achieved by running the script under the terminal emulator <a rel="noreferrer noopener" href="https://wordpress.org/plugins/wpterm/" target="_blank">WPTerm</a> (MakeStaticSite has an option to run &#8216;unattended&#8217;, which makes default selections).  This depends on appropriate support for MakeStaticSite on the server; for shared hosting, the versions of required components, particularly Wget, may be somewhat old and, of course, for any serious use with a third party, access to WPTerm should be properly secured as instructed.  It&#8217;s preferable to keep the running of MakeStaticSite on a personal computer, an arrangement that has been used for <a href="https://fuengsin.org/" target="_blank" rel="noreferrer noopener">fuengsin.org</a>.</p>



<p>However, hosting with a third party means that the data is no longer immediately under our control; although a mixture of database replication and file synchronization can compensate, there&#8217;s some loss of independence.  Perhaps a better solution lies in p2p networks, but that&#8217;s an area I have yet to explore &#8230;</p>



<p>For now, this tool serves my needs well and I hope it is helpful to others.  Please refer to the <a href="https://makestaticsite.sh/" data-type="page" data-id="1499">MakeStaticSite project site</a> for further information.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Website (technical)</title>
		<link>https://ptworld.net/about/website-technical/</link>
		
		<dc:creator><![CDATA[Paul]]></dc:creator>
		<pubDate>Mon, 30 May 2022 18:25:07 +0000</pubDate>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[production]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[shell scripts]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://ptworld.net/?page_id=794</guid>

					<description><![CDATA[This website has been created in WordPress and continues to be maintained in this content management system. However, it is published as a set of static web pages using MakeStaticSite, a custom system comprising a set of Bash shell scripts, <a class="more-link" href="https://ptworld.net/about/website-technical/">Read More ...</a>]]></description>
										<content:encoded><![CDATA[
<p></p>



<p>This website has been created in WordPress and continues to be maintained in this content management system.  However, it is published as a set of static web pages using <a href="https://ptworld.net/projects/software/makestaticsite/" data-type="page" data-id="1499">MakeStaticSite</a>, a custom system comprising a set of Bash shell scripts, to be released as open source software.</p>



<h2 class="wp-block-heading">WordPress plugins</h2>



<p>The following plugins have been used for building the site.</p>



<ul class="wp-block-list"><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/jquery-collapse-o-matic/" target="_blank">Collapse-O-Matic</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/enable-media-replace/" target="_blank">Enable Media Replace</a><a rel="noreferrer noopener" href="https://wordpress.org/plugins/teachpress/" target="_blank">https://wordpress.org/plugins/teachpress/</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/flip-boxes/" target="_blank">Flip Boxes</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/hello-dolly/" target="_blank">Hello Dolly</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/kadence-blocks/" target="_blank">Kadence Blocks – Gutenberg Blocks for Page Builder Features</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/pages-with-category-and-tag/" target="_blank">Pages with category and tag</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/pdfjs-viewer-shortcode/" target="_blank">PDFjs Viewer &#8211; Embed PDFs</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/perform/" target="_blank">Perform &#8211; Optimize Performance</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/really-simple-ssl/" target="_blank">Really Simple SSL</a></li><li>Shortlink Removal</li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/simple-page-ordering/" target="_blank">Simple Page Ordering</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/teachpress/" target="_blank">teachPress</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/timeline-block/" target="_blank">Timeline Block</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/visual-portfolio/" target="_blank">Visual Portfolio, Posts &amp; Image Gallery</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/wp-last-modified-info/" target="_blank">WP Last Modified Info</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/wp-rollback/" target="_blank">WP Rollback</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/wp-show-more/" target="_blank">WP show more</a></li><li><a rel="noreferrer noopener" href="https://wordpress.org/plugins/wp-sitemap-page/" target="_blank">WP Sitemap Page</a></li><li><a href="https://github.com/paultraf/wp-static-search">WP Static Search (fork)</a></li><li><a href="https://wordpress.org/plugins/insert-headers-and-footers/">WPCode &#8211; Insert Headers, Footers, and Code Snippets</a><br></li></ul>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
