X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/odin-cgi/blobdiff_plain/be24e9afafe0d740652d962fd5531de901a9cd09..128543b0487425f62e66ddf8aa5bff893a2d816f:/bin/shorturl.userv diff --git a/bin/shorturl.userv b/bin/shorturl.userv index 489168d..a15a527 100755 --- a/bin/shorturl.userv +++ b/bin/shorturl.userv @@ -1,10 +1,32 @@ #! /usr/bin/perl +### +### URL shortening userv interface for Odin +### +### (c) 2015 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the `odin.gg' service, `odin-cgi'. +### +### `odin-cgi' is free software; you can redistribute it and/or modify +### it under the terms of the GNU Affero General Public License as +### published by the Free Software Foundation; either version 3 of the +### License, or (at your option) any later version. +### +### `odin-cgi' is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU Affero General Public License for more details. +### +### You should have received a copy of the GNU Affero General Public +### License along with `odin-cgi'; if not, see +### . use lib "lib"; use Odin; use DBI; -use POSIX; Odin::cmdline_who; @@ -23,12 +45,11 @@ EOF @ARGV == 0 or Odin::fail "usage: list"; my $db = Odin::open_db; for my $r (@{$db->selectall_arrayref - ("SELECT " . Odin::sql_timestamp($db, "stamp") . ", tag, url + ("SELECT tag, stamp, url FROM odin_shorturl WHERE owner = ? ORDER BY stamp", undef, $Odin::WHO)}) { - my ($stamp, $tag, $url) = @$r; - my $t = strftime "%Y-%m-%d %H:%M:%S %z", localtime $stamp; - printf "%-25s %-12s %s\n", $t, $tag, $url; + my ($tag, $stamp, $url) = @$r; + Odin::print_columns Odin::fmt_time $stamp => 25, $tag => 12, $url =>0; } } elsif ($op eq "new") { @ARGV == 1 or Odin::fail "usage: new URL";