« Back to home

How to read a local archive of the Linux Journal on Ubuntu Touch

Like many Linux and FOSS enthusiasts, I am sad that the venerable Linux Journal is going out of business. As a last gift to subscribers, the Journal have released a complete up-to-date archive of all issues, from 1994 to 2017 - so at the very least we will be able to maintain access to the trove of knowledge they have built over the years. If you’re not a subscriber, you can purchase the archive for a very reasonable price right here, and I strongly recommend doing so while you can.

The archive is meant to be viewed on a desktop OS, but I usually prefer reading on mobile devices. I’ve also been getting into UBports Ubuntu Touch recently and wanted to be able to read the archive on my Ubuntu phone.

The archive is a collection of HTML files with associated assets, a search index and a web server. Usually, you’d run it by cding into the extracted directory and executing a script that will start the local server and open your default browser. Unfortunately, the server is compiled for Intel chips, so this won’t work on Ubuntu Touch (or Android) phones.

phablet@ubuntu-phablet:~/LJArchive/Server/Linux$ file FlyingAntLinux
FlyingAntLinux: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped                          

On Android, we can browse the archiv by opening <ARCHIVE_ROOT>/LJ/tocindex.hmtl in a browser. Sadly, the Ubuntu Touch web browser is not entitled to open local files, so the same won’t work for us.

Fortunately, there is a simple workaround, with the added bonus that you’ll get a nice app icon right in your Apps Scope (pinnable to your launcher). What we need to do is create a webapp-container. The following steps are based on chapter 34 of this GitBook by Matthias Apitz (website/GitHub)1.

I assume you own the archive, and have extracted it to your user’s home directory on the phone (the download is a .zip archive - Ubuntu Touch ships with unzip, which is handy).

First, we use an editor in the Terminal app on your phone to create a .desktop file to define a webapp-container for our Linux Journal archive, like so:

[Desktop Entry]
Name=Linux Journal Archive
Exec=webapp-container --enable-addressbar --enable-back-forward --webappUrlPatterns=/home/phablet/LJArchive* /home/phablet/LJArchive/LJ/tocindex.html

The nano and vi editors come preinstalled on Ubuntu Touch, so you can use either of those to create the file (hint: the Terminal lets you copy/paste text by long-pressing on the screen). This file can be named whatever you want, as long as it has a .desktop file extension (I called mine LinuxJournalArchive.desktop).

The file structure is largely self-explanatory. Name can be any string - notably, it can include spaces without the need to quote or escape anything (if you do quote the string, your app name will include the quotes, which is probably not what you want ;-)). The --webappUrlPatterns define the local file URLs your webapp-container can access. Make this the root directory of your extracted archive, followed by a * wildcard character. The last argument to the Exec=webapp-container line is the app’s entry point - the table of contents in our case: <ARCHIVE ROOT>/LJ/tocindex.html. Icon can be whatever image you fancy - you don’t even need one, but I recommend something nice and Linux-related to make the app easy to find in your Apps Scope.

Once you’re done, cp the file to ~/.local/share/applications/. Make sure the owner of the file is set to your user, which should be phablet.

We’re almost done, but to optimize the text for reading on a smartphone screen, I also made a few changes to ~/LJArchive/css/archive.css. The commented lines are my changes:

001 body {                                                                    
002     font-size: 2.5vw; /* 1vw is 1% of viewport width, but experiment to see whatever size and unit is best for you :-)*/   
003     padding: 0px 25px 30px 25px;                                          
004 } 
015 pre{ 
016     overflow-x: scroll; /*Optional: Prevent code samples from overflowing their box. More for aesthetics than readability*/
017     font-size: 1em !important;    
018     font-family: Courier New, Courier Std,  Monospace, Andale Mono !importan;t
019     background-color: #F9F9F9; 
020     padding: 3px 0px 3px 20px !important;
021     margin: 5px 0px  16px 0px !important;
022 }
113 .programlisting {
114     font-family: courier;
116     font-size: 1em !important;  /*Unlike all other text, this was specified in px and thus not addressed by the body rule*/
117     color: #000;
118 }                              

Now, when you open the Apps Scope, you should find your new Linux Journal web app, and the articles should be well readable on a phone screen. Happy reading :-)2 Linux Journal on Ubuntu Touch, with a good cup of coffee

  1. The entire book is an amazing resource if you are using Ubuntu Touch and want to understand the system better. My favourite part are the instructions on setting up a chroot environment to give you full terminal-based productivity without disturbing your root partition.
  2. One thing to point out is that the archive won’t be searchable with this approach - search functionality is provided by a CGI script that needs a web server to run. I am considering a pure Javascript solution that should work in a local web app, but for now at least we can browse and read articles. That’s also why we point our app directly at tocindex.html, which bypasses the search screen that the desktop version launches.