From 56ff7ecf1a3a12d0580739ded51d4d4e28082148 Mon Sep 17 00:00:00 2001 From: Brian Duggan Date: Sun, 14 Nov 2010 23:04:33 -0500 Subject: [PATCH] initial version --- Quikpic | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 Quikpic diff --git a/Quikpic b/Quikpic new file mode 100755 index 0000000..84cf6b0 --- /dev/null +++ b/Quikpic @@ -0,0 +1,47 @@ +#!/usr/bin/env perl + +use Mojolicious::Lite; +use Mojo::ByteStream qw/b/; +use IO::Dir; + +my $dir = q[/usr/local/share/pictures/2010-10-30]; + +get '/' => sub { + my $c = shift; + tie my %dir, 'IO::Dir', $dir; + $c->stash(dir => { %dir }); +} => 'index'; + +get '/download/(.file)' => sub { + my $c = shift; + my $file = $c->stash("file"); + $c->app->log->debug("serving $file"); + $c->app->static->root($dir); + $c->app->static->serve($c,$c->stash("file")); + $c->rendered; +} => 'download'; + +get '/thumbnail/(.file)' => sub { + my $c = shift; + my $file = $c->stash("file"); + + +} => 'thumb'; + +app->start; +__DATA__ + +@@ index.html.ep +% layout 'default'; +% for my $k (sort keys %$dir) { +% next if $k =~ /^\./; +%= link_to 'download' => {file => $k} => begin +<%= $k =%> +%= end +% } + +@@ layouts/default.html.ep + +<%= content =%> + +