GO BACK

AUTOMATING ART UPLOADS

Edit (13/08/2023): made the bash script actually readable

Making things that are not really part of the process as easy as possible is key to minimize any obstacles to your expression. Anyways. I used to use a hacky C script (didn't know bash) to do it for me, but I realized I probably lost it. Whatever, let's create a new one!

I still don't know bash. So I just tried learning it right now, plus the power of search engine no jutsu.


#!/bin/bash

# CONFIG

SITE_DIRECTORY=img/art/ # you need to leave a trailing slash
LOCAL_DIRECTORY=$HOME/Art/drawings
EXTENSION=png

# SCRIPT

read -p "Filename?: " NAME
read -p "Comment?: " COMMENT

echo "<img tabindex=1 src=\"$SITE_DIRECTORY$NAME.$EXTENSION\" alt=\"$NAME\"/><span class=\"f\"><img src=\"$SITE_DIRECTORY$NAME.$EXTENSION\" alt=\"$NAME\"/></span>"

printf -v DATE '%(%d/%m/%Y)T' -1

echo "<p>($DATE) $COMMENT</p>"

neocities upload -d $SITE_DIRECTORY $LOCAL_DIRECTORY/$NAME.$EXTENSION
  

This time instead of having stuff hard coded to my inner system (its still hardcoded to my website, edit that as you wish) everything you can set in the CONFIG section, so I can share it to others and offer some more flexibility to myself. I even added the EXTENSION variable for the freaks who use jpg or something.

HOW TO USE

PREREQUISITES

USAGE

Just create a file called whatever you want, for example uploadart.sh, and copy paste the script above inside it.

Change values in the CONFIG section to whatever appropriate, SITE_DIRECTORY is where you want the file to end up in your site and LOCAL_DIRECTORY is where you store your images in your computer.


$ chmod +x uploadart.sh
$ ./uploadart.sh
Filename?: fart
Comment?: hello this is my incredible comment
<img tabindex=1 src="img/art/fart.png alt="fart"/><span class="f"><img src="img/art/fart.png" alt="fart"/></span>
<p>(25/07/2023) hello this is my incredible comment</p>
Uploading /home/gabba/Art/drawings/fart.png to /img/art/fart.png ...
SUCCESS: your file(s) have been successfully uploaded
  

After you are done changing what you need in the file, make it executable with chmod as shown above.

Then you will be able to run it as also shown above. It will spit out HTML to copy paste to your website and upload the image for you. The only effort needed from your part is giving the filename, your comment and then copy pasting it. Have fun.