]> mj.ucw.cz Git - gallery.git/blob - gal/Gallery.pm
Gallery2: Missing bits
[gallery.git] / gal / Gallery.pm
1 # Simple Photo Gallery
2 # (c) 2003--2005 Martin Mares <mj@ucw.cz>
3
4 package Gallery;
5
6 use strict;
7 use warnings;
8
9 BEGIN {
10         # Standard Perl module stuff
11         use Exporter();
12         our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
13         $VERSION = 1.00;
14         @ISA = qw(Exporter);
15         @EXPORT = qw(&SetOptions &Start &img &Finish &RawHTML);
16         %EXPORT_TAGS = ();
17         @EXPORT_OK = qw(%CF);
18 }
19
20 our %CF;
21 our $th;
22
23 BEGIN {
24         $CF{"Title"} = "An Unnamed Gallery",
25         $CF{"HeadExtras"} = "",
26         $CF{"TopExtras"} = "",
27         $CF{"BotExtras"} = "",
28         $CF{"ParentURL"} = "../",
29         $CF{"BackURL"} = "",
30         $CF{"FwdURL"} = "",
31         $CF{"ImageSubpages"} = 1,
32         $CF{"AllowArchives"} = 1,
33         $CF{"PhotoUrlPrefix"} = "",
34         $CF{"ThumbUrlPrefix"} = "",
35         $CF{"MetaDataDir"} = ".",
36         $CF{"PhotoDir"} = ".",
37         $CF{"ThumbDir"} = ".",
38 }
39
40 sub SetOptions(@) {
41         while (my $o = shift @_) {
42                 my $v = shift @_;
43                 $CF{$o} = $v;
44                 if ($o eq "Theme") {
45                         require $CF{"GalDir"} . "/$v/theme.pm";
46                         Gallery::Theme::Init($CF{"GalURL"} . "/$v");
47                 }
48         }
49 }
50
51 sub Start() {
52         if (defined $ENV{"GATEWAY_INTERFACE"}) {
53                 require Gallery::Web;
54                 $th = new Gallery::Web;
55         } else {
56                 if (@ARGV && $ARGV[0] eq "--generate") {
57                         require Gallery::Generator;
58                         $th = new Gallery::Generator;
59                 } else {
60                         print STDERR "Usage: $0 [--generate]\n";
61                         exit 1;
62                 }
63         }
64         $th->Start();
65 }
66
67 sub img($$) {
68         $th->img(@_);
69 }
70
71 sub Finish() {
72         $th->Finish();
73 }
74
75 sub RawHTML($) {
76         $th->RawHTML($_[0]);
77 }
78
79 1;