Midnight Pub

Post from your terminal

~m15o

The sky is blue in the city today, a change from the usually cloudy atmosphere. Brewed and I are having a coffee since it's still the afternoon. This evening will get busy on my end, and so will most of this week's evenings actually. It's all work-related though. I should be excited, but am I?

Before the Midnight opened, I didn't know much besides the Web. Since then, I discovered other protocols like Gemini or Gopher. Just the other day, while reading inquiry, I learned about usenet as well. It's humbling to see how forward thinking some software was more than 20 years ago. These are also incredibly exciting venues to learn and explore. And that's what I've been doing!

One thing that's been bugging me for a while now is that to write posts or replies on Midnight, we need to access it through the web. And while I do like the web, I'm slowly burning out from it. Maybe it's because it reminds me of what I don't like about technology, or maybe it's because I associate it too much with work. Whatever the deep reason, too much of anything isn't good. So when I'm enjoying my evening's Old Fashioned (thank you bartender!) I'd rather stay away from it. Heck, I'd like to do it from the comfort of my terminal (or emacs, in this case.)

I've been wondering about what a good way to write on the midnight without the web could look like. While exploring the small net, I've fallen in love with pubnixes and it just *feels* right. People access a remote terminal and are free to use any mean they'd like to interact and write content. Do you want to write a post in vim? Go for it. Do it locally and use rsync to make your content available. Prefer to build an emacs command? Say no more!

I'm fairly new to linux, so it might not be the right time to open an ssh access midnight.pub just yet. I have a lot of learning to go through first. But as I learn, how about a simple shell script for those of us who'd rather not open firefox? (By the way, I love you firefox!)

midnight.sh

This script is merely a convenient way to access Midnight's https endpoints without opening a browser. It's very basic, but hopefully it will be useful for some of us.

man midnight.sh

Here's how to use it:

1. Download the script, make it executable (`chmod +x midnight`). Optionally, move it to `/usr/local/bin`

2. Create `~/.config/.midnight` and put your session token in there. To get it, copy the value of the "midn" session cookie on the web, when you are logged, into that file.

3. It's now ready to use!

Writing an post

To write a post, first create a file. The name of the file isn't important:

myfile.gmi:

This is the title

This is the content

Then pipe that file to midnight:

cat myfile.gmi | midnight

The script will take the first like and add it as a title. The second line needs to be an empty line. Anything after is the content.

If you are actually seing this message, it means that I successfuly ran the following command:

cat post-from-your-terminal.gmi | midnight

Wish me luck!


maya

Oh, how lovely! Thank you so much for making this possible.

reply

tidux

On Terminals

You can also use w3m to browse the web directly in your terminal. It will spawn whatever editor you want, or you can use the Emacs frontend to w3m and it will open a new buffer for large text input forms like midnight.pub. I posted my first post to the pub that way.

reply

5th-position

Thanks for the w3m tip -- I should have thought of that myself.

So now I'm writing this from w3m. Thanks again!

reply

5th-position

I would like to try to post from a terminal, but I am anything but a hacker. So perhaps someone can assist me: where do I find the session token (or the "midn" session cookie on the web)? In case this is needed for your assistance: I use Firefox on Linux.

Thanks in advance!

reply

abacushex

Oooooh! This is glorious!

While I am stuck in Windows land for now (don't hate me), I have managed to streamline and CLI the hell out of it and script as much as I can. Challenge to self; implement in powershell or perhaps python...

reply

gerwitz

I’ve been thinking about this, because I want to visit the Pub without leaving Gemini. I’m also a big fan of the Indieweb movement.

So, naturally I think it’d be nice if Gemini browsers supported Micropub for posting and replying.

There are some issues I haven’t worked through: how do “sync” authentication between these two protocols? How might a Gemini page signal the correct endpoint for posting?

Maybe Micropub should be extended to support SSH keys for auth, and then you’ve basically already done the server part!

reply

m15o

I was unaware of micropub, and after a quick glance it looks like a really interesting approach. I'll definitely read up more on it -- I'm sure there are some good learnings!

reply

uirapuru

Hooray!! I've been waiting for this. Keep up the good work. And I have just replied using your script :)

reply

m15o

I appreciate that! Good to hear you are using the script. :)

reply