#!/usr/bin/perl

use strict;
use lib '/var/home/slowtwitch/slowtwitch.com/cgi-bin/articles/admin';

use Links qw/$PLG $IN $DB/;
use Links::User::Page;

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/var/home/slowtwitch/slowtwitch.com/cgi-bin/articles/admin');

my $id = $IN->param('id');

print $IN->header;
if ($id) {
    my $tab = $DB->table('Widgets');
    my $widget = $tab->get($id);

    if ($widget) {
        if ($widget->{Image}) {
            my $fh = $tab->file_info('Image', $widget->{ID});
            $widget->{Image_URL} = '/images/widgets/' . $fh->File_RelativeURL;
        }
        print Links::SiteHTML::display('include_widgets', { widgets_loop => [$widget] });
    }
}
