It's finally done! #ocular can now automatically post images to your mastodon account - huzzah!

https://nchrs.xyz/ocular.html

Host your own tiny static image feed, join the webring and share images #smallweb style!

Boosts appreciated. 

@rostiger this is really great. i have been looking for a way out of corporate image hosting and sharing. i read through the repo docu, it all seems doable. i have a webserver, just need to check how to access it without “their” online toolset.

one big question though: depending on where i am, i use different machines (linux laptop, osx macbook and win desktop)
Do you think this works with posting to the gallery, or are there local dependencies that need to be synced?

@tovabele Nice! Happy to hear you'd like to give it a shot.

I have only tested it on Ubuntu, where all of the dependencies are already pre-installed. Theoretically it should be possible to use on a Mac, since afaik MacOS also comes with commands such as mkdir, cp, rm, rsync and curl preinstalled. I have never tried it, but I'd be curious if it works for sure!

As for windows, I have no idea what would be needed to get it up an running, but I'm pretty confident that it won't run out of the box.

Anyway, if you do try it, let me know how it goes or if you run into any issues. :3

@rostiger good thing my computer science laptop is ubuntu - mint

@rostiger @tovabele I'm trying to get it going on macOS and have found a couple of stumbling blocks, things like using xdg-open in the script and an issue with the BSD version of realpath not supporting the -m option.

I'm currently working to get it usable and then I'll submit a PR for the changes if that is ok?

@drisc @tovabele Absolutely, that would be awesome! I'm wondering if there are also stumbling blocks in the Lua code - I'm running a bunch of os.execute commands that might cause issues as well.

@rostiger Right now I'm getting this when I try to add an image so I'll be digging into it to see what is going on.

I can potentially solve the realpath issue with grealpath which is installed via 'brew install coreutils', you can add the gnubin folder to the PATH to force your computer to use grealpath for realpath but that might break something if the user is relying on the macOS bundled version somewhere else.

@drisc I'm considering to do away with realpath altogether. I changed the code recently so original images are copied to src/img/ instead of storing the path in the database because it would cause issues if the original file was moved or renamed.

The Lua code currently takes care of copying images, right after adding everything to the database. I could copy the image earlier, in the bash script. The only downside is if the script were canceled prematurely, the image would still be copied to the src dir.

@drisc Ok, I found another solution that should be compatible with macOS. Instead of realpath, you can use

absPath=$(cd "$WD_PATH/$(dirname "$1")" && pwd)/$(basename "$1")

This changes the working directory to the directory of the image, prints the working directory path and concatenates the filename resulting in the absolute path of the file.

Can you test if this works on your machine?

@rostiger Yep that worked for me, I was able to add a title and other metadata, though I am getting this from the conversion process (it still works but all 3 emit the warning):

WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"

I assume the default for Ubuntu LTS is an earlier version.

@drisc Ah, yes, I'm on an older version of imagemagick. I will write a check for this. Besides the warnings, is ocular working for you now?

@rostiger It's working now, the changes I had to make were adding "local keyword =" before kw on line 533 of main.lua to resolve the const error that cropped in in my screenshot and adding a new function to the bash script to use the correct "open" command on each platform, I've included it below:

function openFile() {
case $(uname) in
Linux) xdg-open "$1" ;;
Darwin) open "$1" ;;
esac
}

Then replace xdg-open with openFile.

The only other thing I noticed is that the style and theme css, the favicon stuff and the profile/banner image are supposed to be in a folder called media but the build just puts them in straight into dst.

@drisc Are you referring to the buildKeywordIndex function? I've got a couple of local changes, so line 533 is something else for me, hah

The issue with the media stuff is that I think cp -r isn't supported on macs. I'll fix this with the next push.

@drisc Ok, I pushed all the most recent fixes, in the bash script as well as the Lua scrip. Could you pull them and check if things work?

@rostiger Yep that version is working for me though the media folder in the src folder doesn't appear to be getting copied properly. It's making the media directory but the contents are still ending up in the root of dst. Give me a few and I'll try and puzzle out what's going on.

The imagemagick error is also still there, likely because the command still works and returns a version instead of erroring out.