Back to desktops

β€œIn it's highest and purest form, good feng shui signifies perfect alignment between inner and outer worlds.”

― Lada Ray

Why do we rice?

I. Aesthetics

We want to add style to generic, default desktops and create something pleasant to work in.

II. Efficiency

We want to improve how we work with our desktops so we can achive higher productivity.

III. Comfort

We want to work in an environment that is comfortable and relaxing.

IV. Fun

We rice our interfaces because we can and because it's fun!

How do we rice?

Welcome, young grasshopper.

Unfortunately, this is not the time nor place to give you a lecture on how to rice. But keep in mind that only you can develop a taste suited for you. However, it doesn't hurt to find inspiration and some help.

Here are some excellent resources to help you on your journey:

Colophon

Using free tools and technologies this site is able to stay afloat. It will never ask for donations, but feel free to donate to the projects below - it's a way of supporting us indirectly.

A Vision

A static image gallery with no database and no server side logic, hosted with free web services, and completely administrated and controlled by a terminal.

For these requirements, I chose Neocities as it offers a free plan with 50 MB of storage. The site will be relatively low-scaling but given that there is no server-side or client-side logics, service static files is quite fast.

As for the gallery, my needs are simple. I needed an index page that gave a view of all desktops, single pages for individual desktops, a tagging system and something that would generate these for me easily. Pelican was my choice, as it is Python-based, used Jinja2 for templates, and I have previous experience with it.

Adminning the site would be entirely done within a terminal, such as adding new content, uploading images, generating thumbnails, generating the entire site and uploading it to our host.

The Workflow

Follow along with this Gist page to see the relevant code.

  1. Find a desktop screenshot I like
  2. Generate thumbnails
  3. Upload images to Pomf
  4. Add new article entry with appropriate data
  5. Regenerate the site
  6. Upload the site to neocities

Steps 2-4 are handled by a shell script, add_desktop.sh. Adding/Updating desktops is as easy as evoking the command:

$ add_desktop.sh Pictures/screenshot.jpg

Step 5 is simply done by evoking pelican on the same directory as the pelicanconf.py to build the site in an output folder. However I wanted to work on the root directory on a day-to-day basis, so I wrote a convinience script:

$ generate_content.sh

Step 6 utilizies curl and the neocities API to deploy entire site in the output folder.

$ update_neocities.sh

The Work Done

The majority of the work is done by Pelican by editing it's pelicanconf.py. I had to create a separate theme, desktops-theme, for the site. I will not go into detail on making Pelican themes here.

I like writing my CSS in SASS since its easier and it ensures my CSS output is valid.

The site uses Google Fonts for convinience.

Once I find a desktop screenshot I want to display in my gallery, I run the script aptly named add_desktop.sh. The script has two main functions:

Along the way I was met with a problem of thumbnails. As it is impractical to load full size images and display them on the front-page (well, nothing wrong with it inherently, just that humans have short attention spans), I had to generate a thumbnail of the screenshot. I used ImageMagick's convert to convert and crop the images to lessen the file size. If the script detects that the desired screenshot has a safe file extension (jpg, png, gif) it creates a thumbnail of the image and upload's the original file to Pomf.

A special case for animated gifs, I wanted to preseve animations so I wrote a separate convert just for gifs:

$ convert ${file} -coalesce -strip -quality 75 -thumbnail 531x350^ -gravity Center -extent 531x350 +repage thumb.gif

add.desktop.sh also lets me edit the post data such as tags, who shot the screenshot, source link etc.

After adding a new desktop in the gallery, we must now build our new site. Simply run pelican in the generator folder.

$ pushd generator ; pelican ; popd

And once that is done we can now upload the site!

Limitations and Future Changes

Uploading to Neocities is quite slow since it only allows one file per payload. The script solves that problem but the API doesn't allow directory creation. For this reason, I had to make the site in one level.

The limitation to update_neocities.sh is that it cannot create directories and it can't upload subdirectories. Still investigating a way to fix this, since I have to upload the theme folder by hand every time I update the theme.

add_desktops.sh is limited to three formats, I'd like to support webm in the future.