]> mj.ucw.cz Git - gallery.git/blob - Gallery/Archive.pm
6fb34571e3e685b5f1a73f849dbccb65e1a39730
[gallery.git] / Gallery / Archive.pm
1 # Simple Photo Gallery: Web Archiver
2 # (c) 2005 Martin Mares <mj@ucw.cz>
3
4 package Gallery::Archive;
5 import Gallery qw(%CF);
6
7 use IO::Handle;
8
9 sub new($$) {
10         my ($cls, $type) = @_;
11         my $x = { 'type' => $type, 'files' => [] };
12         return bless $x;
13 }
14
15 sub Start($) {
16         my ($this) = @_;
17         my $type = $this->{'type'};
18         my $cts = { "tar" => "application/x-tar", "zip" => "application/zip" };
19         defined $cts->{$type} or die "Unknown archive type $type";
20         print "Content-Type: ", $cts->{$type}, "\n";
21         print "Content-Disposition: inline;filename=gallery.$type\n";
22         print "\n";
23 }
24
25 sub Finish($) {
26         my ($this) = @_;
27         my $type = $this->{'type'};
28         STDOUT->flush();
29         chdir($CF{"PhotoDir"}) or die;
30         if ($type eq "tar") {
31                 system("/home/mj/bin/tar", "cf", "-", @{$this->{'files'}});
32         } elsif ($type eq "zip") {
33                 system("zip", "-", @{$this->{'files'}});
34         } else { die; }
35 }
36
37 sub RawHTML($$) {
38 }
39
40 sub img($$$) {
41         my ($this, $orig, $annot) = @_;
42         push @{$this->{'files'}}, $orig;
43 }
44
45 1;