#!/usr/bin/perl use strict; use warnings; use IronMan::Schema; use IronMan::Feeds; use Term::Prompt; use Data::Dumper; # my $dsn = [ 'dbi:SQLite:/home/castaway/plagger/subscriptions.db' ]; my $dsn = [ 'dbi:SQLite:/var/www/ironman.enlightenedperl.org/plagger/subscriptions.db' ]; my ($title, $url, $email, $email_2); my $why = []; do { print $_ for(@$why); ## Ask for name, feed url, email (2x) ($title, $url, $email, $email_2) = collect_data($title, $url, $email, $email_2); } until($url && (IronMan::Feeds::verify_feed_data($title, $url, $email, $email_2, $why))); ## Add blog my ($res, $fdb) = add_new_blog($title, $url, $email, $dsn) ; if(!$res) { print "That blog already exists: ", Dumper({ $fdb->get_columns }); } else { print "Added new blog: ", Dumper({ $fdb->get_columns }); } ## prompt to send email yes/no ## send email to user with guid sub add_new_blog { my ($title, $url, $email, $dsn) = @_; my $schema = IronMan::Schema->connect(@$dsn); return $schema->resultset('Feed')->add_new_blog(title => $title, url => $url, email => $email ); } sub collect_data { my ($title_def, $url_def, $email_def) = @_; my $title = prompt('x', 'Display name: First Last (nick):', '', $title_def ||''); my $url = prompt('x', 'URL of the ATOM/RSS feed:', '', $url_def || ''); my $email = prompt('x', "Blogger's email:", '', $email_def || ''); my $email_2 = prompt('x', "Blogger's email (confirmation):", '', ''); return ($title, $url, $email, $email_2); }