#! /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
+### <http://www.gnu.org/licenses/>.
use lib "lib";
use Odin;
use DBI;
-use POSIX;
Odin::cmdline_who;
@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";