PirateBox

When I was looking into nifty Raspberry Pi projects, I stumbled across the PirateBox project. The website describes it well:

PirateBox is a DIY anonymous offline file-sharing and communications system built with free software and inexpensive off-the-shelf hardware.

In other words, it’s a bit of preconfigured software you can run on a Raspberry Pi that lets folks chat, share files, and peruse forums on an offline network created by the Pi. Oh, and it’s GPLv3! Open source software FTW!

I have always disliked sharing files via Airplay (Mac-only), Dropbox, or other methods. They work, but require some mental overhead and for everything to magically work. There’s also sharing via USB, but with USB C, that got slightly more annoying.

To me, PirateBox sounded perfect. I could quickly fire up a network from my backpack and share files with those around me. I could use it at meetups or WordPress events after loading it up with some WordPress stuff so folks don’t have to deal with sketchy internet to download software. All pretty pragmatic uses.

I also really like the idea of firing it up when I’m working at busy coffee shops and at conferences to see what folks do with it. Will they try to add malicious software? Will they add poetry and selfies? I guess I will find out!

Yesterday, I downloaded the PirateBox software and loaded it onto a Raspberry Pi Zero W. That’s the itty bitty Raspberry Pi. The folks who put the PirateBox together did an excellent job. It was super straightforward to set up and didn’t require a monitor, or any attached keyboard or mouse. I spotted the PirateBox network on my Mac, joined it, and connected via SSH.

For those of you unfamiliar with SSH, you can crack open Terminal (in Mac) or a console in Linux and talk to another computer. PirateBox walks through the process right on the site.

After I followed the short and sweet setup instructions, I opened a browser window and was greeted with the PirateBox interface.

Screen Shot 2017-11-12 at 5.13.30 PM

I tested out just about everything (except the forum) to make sure it worked. Then I decided it was time for me to do some design magic to the interface. It was not the easiest process to figure out as I had to locate the files and understand their build.

How to customize the interface

To customize the PirateBox web interface, you should be comfortable with HTML, CSS, and Javascript. If you’re not familiar, you should either take an online course or pick up a book. It’s super fun!

The important files are all over the place and were somewhat of a mystery to locate. This should help out folks in the future.

 

The home page

Most of the HTML, CSS, and Javascript files are in /mnt/sdshare/share/content and its subdirectories. They are fairly straightforward. There is some jQuery in use so make sure you keep an eye on which IDs are changed to avoid breaking jQuery functionality. I mostly rewrote the CSS keeping a few of the things from the original. I’ll be open sourcing these shortly (when I figure out the best format).

Localisation

Much to my surprise and delight, there is some basic, but functional localization of the web app. If you want to change text on the home page, you will likely need to change it in multiple places. You will need to change it in the HTML and in the corresponding file in /mnt/sdshare/share/content/locales/. Bonus points if you translate your new or modified strings!

The file browser HTML

I found the file browser HTML to be one of the quirkiest bits. It’s split into three parts. The two you likely will want to mess with are located in /mnt/sdshare/share/Shared/. This is also where your uploads end up by default.

The two files are the first half of the page and last half of the page. The first half is HEADER.txt. Why it is a txt file is beyond me. The second half is in README.txt. Again, why these are this way are a mystery. However, they are just basic HTML and are easy enough to modify.

The chat content

If you for some reason want to clear out the chat or remove a comment, you will need to modify at least one file. The important one is /opt/piratebox/www/cgi-bin/data.pso. If you remove content from this file. the next time someone uses the chatbox, it will regenerate the second file, /opt/piratebox/www/chat_content.html, which is used to render the chat and. This will remove the content. If you want it gone from the chat view immediately, you will need to remove the same content from both.

The results

PirateBox.gif

I wanted to add some breathing room, make it feel friendlier (for my non-pirate friends), and make it look good on high resolution screens so I did just that.

As you can see, it’s not perfect. The header’s a bit big, but hey I did this in an afternoon and I can fix that up as I iterate. I also need to style the upload a bit nicer.

It’s also mobile-friendly and should be fairly accessible. I think a few of the chat box’s form fields could use labels so maybe I’ll add those the next time I mess with it.

The hardware

For those curious, here’s what the final build looks like.

It’s just a Raspberry Pi Zero W with an SD card and power supply. I put it in a nifty case I found on Amazon, but that’s unnecessary. It might even be cool to strip off unused ports to lighten it and put it in a book, wallet, or maybe even a clever laptop case.

Thoughts?

What do you think of this idea? What cool things would you use it for? Leave a comment!

Raspberry machines

I’m writing this on a Raspberry Pi. It has a 2.5 inch screen  and my keyboard is some kind of cheap tiny wireless thing with a track pad that more closely resembles a game controller than a keyboard. Please forgive my brevity or typos. In addition to composing on a small screen, Chromium has a minimum width which makes seeing this editor a bit tricky. Here’s what the whole thing looks like on a 13″ Macbook for scale:

On Saturday Keya and I went for breakfast at a place that happened to be near Microcenter, an electronics retailer. We made the poor life decision to drop in since neither of us had been there in ages. We played with keyboards, security stuff, and IOT things, but what really grabbed their attention was the section with all the Raspberry Pi’s and Arduino projects. Keya got a nifty Raspberry Pi Zero W project and some capacitive thread (for wearable electronics). I walked out with a Pi 3 and a Pi Zero radio project as well as some accessories. We also stocked up on micro SD cards.

The Pirate Radio was the first project I put together. It’s not to difficult and ended up being a delightful airplay speaker when it was all said and done. It is the first “radio” Keya and I have attempted that actually worked (third time is the charm?). It uses a pHAT BEAT addon and a Raspberry Pi Zero W to make the magic happen. I also followed a super simple tutorial to get it done. The only hitch was due to localization settings. Once I switched to the proper keyboard layout and language, everything worked like a charm. Here’s the result:

Once I was feeling confident, I decided to go for putting together the tiny computer with the tiny screen I was imagining. It turned out to be a bit more difficult. The mouse I was trying to use turned out to not work at all. Updating the packages bricked the machine so I had to reflash the operating system a few times.

Learning how to navigate a small screen was an interesting challenge. Pro tip: Use alt + click anywhere on a window to drag it around. This is necessary for windows that have minimum heights and widths. They cannot be scrolled. Once I got the hang of window manipulation, further adjustments were straightforward. I ensmallen the font size and made the menu bar smaller via the appearance settings.

So far I’m loving this thing. What will I use it for? No idea, but it fits rather nicely in any bag and can be powered via my USB batteries. I think my next project might be to make it a local git server or a web server. I also saw something about a VPN or a network ad blocker. Maybe even a robot butler? The cloud is the limit! I ordered a few more thingies to attempt another project or two and if successful, I’ll post the results.

If you have made anything nifty like this or have project ideas, drop them in the comments! If you haven’t and want to, say so in the comments! If you hate these things and don’t understand why anyone bothers with them, let me know in the comments!