Skip to content

Instantly share code, notes, and snippets.

@samebchase
Created February 20, 2024 09:57
Show Gist options
  • Save samebchase/f2a8cd9c6bca2b1506070d5a5ffa862d to your computer and use it in GitHub Desktop.
Save samebchase/f2a8cd9c6bca2b1506070d5a5ffa862d to your computer and use it in GitHub Desktop.
Raku program to generate gemini presentation slides from a single file
#!/usr/bin/env raku
# Example structure of presentation.gmi\
# All the gemtext you want on a 'slide' separated by ===
#`{
# Lightweight Web+Gemini hosting
===
## This is too easy, my $OLD-MUGGLE-RELATIVE could do it
* It was challenging to get it working for me.
* Deploy the simplest thing on the public internet is an achievement.
* Managed to learn some lightweight Ops skillz.
===
## Hosting Webpages in 2021, er, I mean 2022
* HTTPS is everywhere, so we need to figure that out.
* SSL (i.e. TLS) termination can be done by a load balancer
* HTTP Server can serve up the static webpages
* A Gemini server for the Gemini pages
===
}
use v6.d;
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('===');
my $idx = 0;
for @slides -> $slide {
my $slide-cont = $slide ~ "\n";
my $filename;
if $idx == 0 {
$filename = "index.gmi";
$slide-cont ~= "=> $url-prefix/{$idx.succ}.gmi start\n";
}
else {
$filename = "$idx.gmi";
if $idx < @slides.elems - 1 {
$slide-cont ~= "=> $url-prefix/{$idx.succ}.gmi next\n";
}
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";
$idx++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment