#!/usr/bin/perl # This is a hack to upload a locally generated gallery to MJ's web. use common::sense; print "## Updating Git\n"; system "git", "pull"; die if $?; print "## Ensuring that photos are generated\n"; system "gal", "gen"; die if $?; use Cwd; my $cwd = getcwd; my ($root, $album) = $cwd =~ m{(.*)/photos/(.*)} or die "Cannot identify album from current directory, giving up.\n"; my $static = "$root/static/gallery/photo/$album"; -d $static or die "Cannot find generated photos in $static, giving up.\n"; print "## Uploading album $album\n"; system "rs", "$static/", "jw:www/static/gallery/photo/$album/"; die if $?; print "## Calling editor on index files\n"; system 'vim', 'gallery.cf', "$root/photos/Makefile", "$root/photos/index.thtml"; die if $?; print "## Committing to repository\n"; system 'git', 'add', 'gallery.cf', 'gallery.list'; die if #?; system 'git', 'add', "$root/photos/Makefile", "$root/photos/index.thtml", "$root/photos/default.cf"; die if $?; system 'git', 'commit', '-m', "photos/$album"; die if $?; system 'git', 'push'; die if $?; print "## Pulling at the server\n"; system "ssh", "jw", "cd web && git pull && make"; die if $?; print "## Regenerating cache at the server\n"; system "ssh", "jw", "cd web/photos/$album && ~/web/gal/gal cache"; die if $?; print "Done.\n";