|
From: <ix...@us...> - 2002-01-04 00:25:12
|
ixjonez 02/01/03 16:25:11
Modified: lib/LiveFrame Tag: Èå `¶@¨Ð ¨Ð Æ °µ @y Pt À· À·
¶@¶@¶@¶@¶@¶@ ¶@ ¶@èx èx
°¶@°¶@¸¶@¸¶@À¶@À¶@ȶ@ȶ@ж@ж@0· 0·
à¶@à¶@è¶@è¶@ð¶@ð¶@ø¶@ø¶@
/tmp/cvs-serv10850/lib/LiveFrame/Gallery.pm No tag
Gallery.pm
Log:
implement directory and file creation
Revision Changes Path
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
1.3 +79 -2 commons/lib/LiveFrame/Gallery.pm
Index: /tmp/cvs-serv10850/lib/LiveFrame/Gallery.pm
===================================================================
RCS file: /cvsroot/liveframe/commons/lib/LiveFrame/Gallery.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /tmp/cvs-serv10850/lib/LiveFrame/Gallery.pm 2001/12/19 05:26:51 1.2
+++ /tmp/cvs-serv10850/lib/LiveFrame/Gallery.pm 2002/01/04 00:25:11 1.3
@@ -8,6 +8,10 @@
@LiveFrame::Gallery::ISA = 'LiveFrame::PhotoDir';
+use constant CONFIG_FILE => 'config';
+use constant DISPLAY_DIR => 'display';
+use constant PREVIEW_DIR => 'preview';
+
sub new {
my ($type, $site, $dir) = @_;
my $class = ref($type) || $type;
@@ -46,11 +50,67 @@
## public methods
sub create {
- my ($self, $pos, $perms) = @_;
+ my ($self, $perms) = @_;
+ $perms ||= 0755;
+
+ if ($self->exists()) {
+ die "can't create: site previously exists\n";
+ }
+
+ my $old_umask = umask;
+ umask 0000;
$self->SUPER::create($perms);
- $self->{site}->add_gallery($pos);
+ undef $self->{exists};
+
+ my $display_dir = $self->display_dir();
+ File::Path::mkpath($display_dir, undef, $perms) or
+ die "can't mkdir $display_dir: $!\n";
+
+ my $preview_dir = $self->preview_dir();
+ File::Path::mkpath($preview_dir, undef, $perms) or
+ die "can't mkdir $preview_dir: $!\n";
+
+ my $config_file = $self->config_file();
+ sysopen CONFIG, $config_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
+ die "can't write $config_file: $!\n";
+ binmode CONFIG;
+
+ my $title = $self->title();
+ my $description = $self->description();
+
+ print CONFIG <<EOT;
+# LiveFrame configuration file
+#
+# the first uncommented line MUST contain the title of your series. you can
+# optionally specify a description for the series.
+#
+# format -
+# title} description
+#
+# (note that if you changed the seperator configuration option to something
+# other than "}" you should use that to seperate the title from the description # instead.)
+
+$title} $description
+
+# the rest of the file should contain the filename of each photo on a single
+# line. you optionally specify a caption for each photo.
+#
+# format -
+# title} caption
+#
+# (note that if you changed the seperator configuration option to something
+# other than "}" you should use that to seperate the title from the caption
+# instead.)
+
+EOT
+ close CONFIG;
+
+ umask $old_umask;
+
+ $self->{exists} = 1;
+
return 1;
}
@@ -74,6 +134,23 @@
sub shown {
my ($self) = @_;
return $self->{visibility} || undef;
+}
+
+# private methods
+
+sub config_file {
+ my ($self) = @_;
+ return File::Spec->catfile($self->path(), CONFIG_FILE);
+}
+
+sub display_dir {
+ my ($self) = @_;
+ return File::Spec->catdir($self->path(), DISPLAY_DIR);
+}
+
+sub preview_dir {
+ my ($self) = @_;
+ return File::Spec->catdir($self->path(), PREVIEW_DIR);
}
1;
No revision
No revision
1.3 +79 -2 commons/lib/LiveFrame/Gallery.pm
Index: Gallery.pm
===================================================================
RCS file: /cvsroot/liveframe/commons/lib/LiveFrame/Gallery.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Gallery.pm 2001/12/19 05:26:51 1.2
+++ Gallery.pm 2002/01/04 00:25:11 1.3
@@ -8,6 +8,10 @@
@LiveFrame::Gallery::ISA = 'LiveFrame::PhotoDir';
+use constant CONFIG_FILE => 'config';
+use constant DISPLAY_DIR => 'display';
+use constant PREVIEW_DIR => 'preview';
+
sub new {
my ($type, $site, $dir) = @_;
my $class = ref($type) || $type;
@@ -46,11 +50,67 @@
## public methods
sub create {
- my ($self, $pos, $perms) = @_;
+ my ($self, $perms) = @_;
+ $perms ||= 0755;
+
+ if ($self->exists()) {
+ die "can't create: site previously exists\n";
+ }
+
+ my $old_umask = umask;
+ umask 0000;
$self->SUPER::create($perms);
- $self->{site}->add_gallery($pos);
+ undef $self->{exists};
+
+ my $display_dir = $self->display_dir();
+ File::Path::mkpath($display_dir, undef, $perms) or
+ die "can't mkdir $display_dir: $!\n";
+
+ my $preview_dir = $self->preview_dir();
+ File::Path::mkpath($preview_dir, undef, $perms) or
+ die "can't mkdir $preview_dir: $!\n";
+
+ my $config_file = $self->config_file();
+ sysopen CONFIG, $config_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
+ die "can't write $config_file: $!\n";
+ binmode CONFIG;
+
+ my $title = $self->title();
+ my $description = $self->description();
+
+ print CONFIG <<EOT;
+# LiveFrame configuration file
+#
+# the first uncommented line MUST contain the title of your series. you can
+# optionally specify a description for the series.
+#
+# format -
+# title} description
+#
+# (note that if you changed the seperator configuration option to something
+# other than "}" you should use that to seperate the title from the description # instead.)
+
+$title} $description
+
+# the rest of the file should contain the filename of each photo on a single
+# line. you optionally specify a caption for each photo.
+#
+# format -
+# title} caption
+#
+# (note that if you changed the seperator configuration option to something
+# other than "}" you should use that to seperate the title from the caption
+# instead.)
+
+EOT
+ close CONFIG;
+
+ umask $old_umask;
+
+ $self->{exists} = 1;
+
return 1;
}
@@ -74,6 +134,23 @@
sub shown {
my ($self) = @_;
return $self->{visibility} || undef;
+}
+
+# private methods
+
+sub config_file {
+ my ($self) = @_;
+ return File::Spec->catfile($self->path(), CONFIG_FILE);
+}
+
+sub display_dir {
+ my ($self) = @_;
+ return File::Spec->catdir($self->path(), DISPLAY_DIR);
+}
+
+sub preview_dir {
+ my ($self) = @_;
+ return File::Spec->catdir($self->path(), PREVIEW_DIR);
}
1;
|