Midnight Pub

My midnight.sh

~coldwave

I changed midnight.sh to post the contents of a file which is given as first argument, instead of from stdin. Run like "bash ./midnight.sh post.txt ". The file should contain: title, one blank line, body.

--form-string instead of -F to read the text as literal; I had some problems with semicolons read as field seperators in the posting form

Haven't gotten to the reply and thread options yet.

#!/bin/bash

 host=https://midnight.pub

 if [ $# -eq 1 ]
 then
	file=$1
	echo "$(sed -n '1p' $file)"
	echo "$(tail -n +2 $file)"
  curl --form-string title="$(sed -n '1p' $file)"\
	    --form-string content="$(tail -n +2 $file)"\
	 -b midn="$(cat ~/.config/.midnight)"\
	 $host/posts/save
fi

zampano

If I'm reading this right, it's also loading your login credentials from a local file?

reply

coldwave

Yes but that comes from m15o's original midnight.sh, you can find it down at 'read manual'. I had to copy the data from a cookie as directed, and sadly it might expire in a month.

reply

zampano

Gotcha. I wonder if there's a way to handle manually logging in first? Curl should be able to send your credentials and then store a reply from the server....

reply