Day 6 – Creating a presentation hosted on a Gemini capsule

The fiddly process of making presentations

Many of us have been in a situation where we need to whip up a quick presentation. We might enjoy doing a talk on the subject material, but the thought of having to make presentation slides can take some joy out of it.

One of my requirements was to make a presentation that can be written in plain text, and publicly shared over the internet (not the web, we’ll get to that part later).

When I saw people using Gemini for all sorts of things, I started wondering if it would work for presentations as well.

What is Gemini?

Gemini is an “internet communication protocol for accessing remote documents”. Think of it as a lightweight ‘web’ where instead of HTML documents served over HTTP, we have Gemtext documents served over the Gemini protocol.

We can see the Gemtext spec is extremely lightweight, and deliberately does not have lot of features.

However, this has not stopped people from using it. There is a an entire world of Gemini and Gopher to be explored. There are a lot of Gemini capsules and Gopher holes out there that are worth checking out!

Writing our presentation

Let’s start creating a presentation on say, functional programming. Let’s make a slide.

We’ll need some way of navigating forwards and backwards, so this can be done with links.

Our first slide may look something like this.

## Map

> "I have a bunch of things, I want to transform them all to some other bunch of things."

=> gemini://test.samebchase.com/presentations/fp-intro/map.png Map


=> gemini://test.samebchase.com/presentations/fp-intro/7.gmi next
=> gemini://test.samebchase.com/presentations/fp-intro/5.gmi prev

Hmm, this part of adding forward and backward links can get annoying and error prone to type out manually. If only there were some fun programming language with which all this drudgery could be automated… ๐Ÿ˜‰

Adding more slides

Now, we need to decide upon a way to add more slides. Let’s use a totally arbitrary separator like === to denote the boundary between slides. We can split the file on this separator, and generate the individual gemtext files.

Raku to the rescue

#!/usr/bin/env raku

# Example structure of presentation.gmi
# All the gemtext you want on a slide separated by ===
#`{
===
## Title for slide 1

* Point 1
* Point 2
===
## Title for slide 2

* Point 1
* and so on...
===
}

sub MAIN() {
    my $presentation-name = 'fp-intro';
    my $output-dir = "generated";
    my $url-prefix = "gemini://test.samebchase.com/presentations/$presentation-name";

    my $presentation-cont = slurp "presentation.gmi";
    my @slides = $presentation-cont.split('===');

    for @slides.kv -> $idx, $slide {

        my $slide-cont = $slide ~ "\n";
        my $filename;

        # We add an index.gmi as the first slide so that when the dir
        # is opened this file gets served the same way as index.html
        if $idx == 0 {
            $filename = "index.gmi";
            $slide-cont ~= "=> $url-prefix/{$idx.succ}.gmi start\n";
        }
        else {
            $filename = "$idx.gmi";
            # Show the next slide link for all but the last one
            if $idx < @slides.end {
                $slide-cont ~= "=> $url-prefix/{$idx.succ}.gmi next\n";
            }
            # For the second slide, the previous slide link is the
            # index.gmi
            if $idx == 1 {
                $slide-cont ~= "=> $url-prefix/index.gmi prev\n";
            }
            else {
                $slide-cont ~= "=> $url-prefix/{$idx.pred}.gmi prev\n";
            }
        }

        my $file-path = "$output-dir/$filename";
        spurt $file-path, $slide-cont;
        say "generated: $file-path";
    }
}

That’s all the code we need to generate the individual gemtext files for each slide in the presentation.

Uploading the files to the node

We need to copy these generated .gmi files to a directory that your Gemini server is serving as part of your Gemini capsule (a Gemini ‘website’, so to speak). I used good old rsync to copy all those files to the node where the Gemini server is configured and running.

The presentation is ready! I placed it in a folder called presentations/fp-intro, so we can open that using any Gemini client.

Viewing the presentation

I like using Lagrange, so let’s launch that and point it here!

Viewing the presentation served over Gemini using the Lagrange Gemini client.

This is what it looks like. You can also use any of the other available Gemini clients as well. There are graphical clients, command line clients, clients that run in Emacs and clients that run on mobile phones. Use whatever you like.

Why (not) use Raku for this?

This is all rather straightforward and can be done in any programming language.

You may wonder: “Why can’t I just use $MAINSTREAM-PRODUCTIVITY-LANG?” for this task. I contend, that for situations where massively popular and well regarded libraries are not required, why not make it fun for yourself by trying out something new? You may end up having a good time, and learn a few new neat tricks in the process.

As we have seen, with a bit of Raku to automate things, we can turn the process of making presentations from a chore to something (-O)fun.

Enjoy the holidays!

(Thanks to Elizabeth Mattijsen for helping with proofreading this article.)

Exercise for the reader: Setting up a Gemini Capsule

We did not cover which is to setup a Gemini capsule, which is out of scope for this article. This is analogous to setting up a web server (like NGINX), certificates required for enabling TLS on a publicly accessible node.

Once this required setup is done, we need to upload the gemtext files to a directory that the Gemini server is configured to serve.

There are plenty of Gemini server implementations in a wide array of languages including this one written in Raku.

2 thoughts on “Day 6 – Creating a presentation hosted on a Gemini capsule

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.