]> www.average.org Git - mkgallery.git/blob - mkgalrss.pl
make it work, more or less...
[mkgallery.git] / mkgalrss.pl
1 #!/usr/bin/perl
2
3 # $Id: mkgallery.pl 38 2006-12-17 09:39:01Z crosser $
4
5 # Build initial (empty) RSS file for mkgallery.pl
6
7 # Copyright (c) 2007 Eugene G. Crosser
8
9 #  This software is provided 'as-is', without any express or implied
10 #  warranty.  In no event will the authors be held liable for any damages
11 #  arising from the use of this software.
12 #
13 #  Permission is granted to anyone to use this software for any purpose,
14 #  including commercial applications, and to alter it and redistribute it
15 #  freely, subject to the following restrictions:
16 #
17 #  1. The origin of this software must not be misrepresented; you must not
18 #     claim that you wrote the original software. If you use this software
19 #     in a product, an acknowledgment in the product documentation would be
20 #     appreciated but is not required.
21 #  2. Altered source versions must be plainly marked as such, and must not be
22 #     misrepresented as being the original software.
23 #  3. This notice may not be removed or altered from any source distribution.
24
25 use strict;
26 use Carp;
27 use Term::ReadLine;
28 use XML::RSS;
29 use Getopt::Long;
30 use Encode;
31 use encoding 'utf-8';
32 binmode(STDOUT, ":utf8");
33
34 ######################################################################
35
36 my $debug = 0;
37 my $rssfile = "";
38
39 unless (GetOptions(
40                 'help'=>\&help,
41                 'rssfile=s'=>\$rssfile,
42                 'debug'=>\$debug)) {
43         &help;
44 }
45
46 sub help {
47
48         print STDERR <<__END__;
49 usage: $0 [options]
50  --help:        print help message and exit
51  --incpath:     do not try to find .include diretory upstream, use
52                 specified path (absolute or relavive).  Use with causion.
53  --debug:       print a lot of debugging info to stdout as you run
54  --asktitle:    ask to edit album titles even if there are ".title" files
55  --noasktitle:  don't ask to enter album titles even where ".title"
56                 files are absent.  Use partial directory names as titles.
57  --rssfile=...: build RSS feed for newly added "albums", give name of rss file
58 __END__
59
60         exit 1;
61 }
62
63 unless ($rssfile) {
64         print STDERR "you must specify --rssfile\n";
65         exit 1;
66 }
67
68 my $term = new Term::ReadLine "Edit RSS Attribute";
69
70 my $rssobj = new XML::RSS (version=>'2.0');
71 die "could not build new RSS object" unless ($rssobj);
72
73 my $OUT = $term->OUT || \*STDOUT;
74 print $OUT "Enter attributes for this gallery RSS feed\n";
75 my $title = $term->readline('Feed title >','');
76 $term->addhistory($title) if ($title);
77 my $link = $term->readline('Gallery root URL >','');
78 $term->addhistory($link) if ($link);
79 my $desc = $term->readline('Gallery description >','');
80 $term->addhistory($desc) if ($desc);
81
82 $rssobj->channel(
83                 title=>$title,
84                 link=>$link,
85                 description=>$desc,
86                 #language=>$language,
87                 #rating=>$rating,
88                 #copyright=>$copyright,
89                 #pubDate=>$pubDate,
90                 #lastBuildDate=>$lastBuild,
91                 #docs=>$docs,
92                 #managingEditor=>$editor,
93                 #webMaster=>$webMaster
94                 );
95 $rssobj->save($rssfile);