|
From: <ix...@us...> - 2002-01-04 01:12:54
|
ixjonez 02/01/03 17:12:53
Modified: lib/LiveFrame Tag: Ð `¶@Ü Ü °Ã ¸½ x¶@x¶@À À
¶@¶@¶@¶@¶@¶@ ¶@ ¶@¨¶@¨¶@°¶@°¶@¸¶@¸¶@
/tmp/cvs-serv20703/lib/LiveFrame/Site.pm No tag
Site.pm
Log:
refactor config file writing. write files when a gallery is added.
Revision Changes Path
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
No revision
1.4 +64 -32 commons/lib/LiveFrame/Site.pm
Index: /tmp/cvs-serv20703/lib/LiveFrame/Site.pm
===================================================================
RCS file: /cvsroot/liveframe/commons/lib/LiveFrame/Site.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /tmp/cvs-serv20703/lib/LiveFrame/Site.pm 2002/01/04 00:27:03 1.3
+++ /tmp/cvs-serv20703/lib/LiveFrame/Site.pm 2002/01/04 01:12:53 1.4
@@ -94,6 +94,9 @@
$self->{galleries} = $new;
}
+ $self->write_hidden_file() if $gallery->hidden();
+ $self->write_order_file();
+
return 1;
}
@@ -107,48 +110,19 @@
$perms ||= 0755;
if ($self->exists()) {
- die "can't create: site previously exists\n";
+ die "can't create site ", $self->path(), ": site previously exists\n";
}
my $old_umask = umask;
umask 0000;
my $path = $self->path();
- warn "mkpath $path\n";
File::Path::mkpath($path, undef, $perms) or
die "can't mkdir $path: $!\n";
-
- my $order_file = $self->order_file();
- sysopen ORDER, $order_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
- die "can't write $order_file: $!\n";
- binmode ORDER;
- print ORDER <<EOT;
-#
-# to specify the order of LiveFrame galleries manually, set the manual
-# gallery ordering variable in your liveframe script to "yes" and enter
-# the name of each gallery directory, each on it's own line, below.
-#
-EOT
- close ORDER;
+ $self->write_order_file();
+ $self->write_hidden_file();
- my $hidden_file = $self->hidden_file();
- sysopen HIDDEN, $hidden_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
- die "can't write $hidden_file: $!\n";
- binmode HIDDEN;
- print HIDDEN <<EOT;
-#
-# to prevent LiveFrame galleries from being displayed in the gallery
-# index or in the previous/next gallery interface on the start page,
-# enter their names, each on it's own line, below.
-#
-# e.g.; to hide the gallery "sample" from the index, uncomment the
-# following line:
-#
-
-EOT
- close HIDDEN;
-
umask $old_umask;
$self->{exists} = 1;
@@ -235,6 +209,64 @@
sub order_file {
my ($self) = @_;
return File::Spec->catfile($self->path(), ORDER_FILE);
+}
+
+sub write_hidden_file {
+ my $self = shift;
+
+ my $hidden_file = $self->hidden_file();
+ sysopen HIDDEN, $hidden_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
+ die "can't write $hidden_file: $!\n";
+ binmode HIDDEN;
+
+ print HIDDEN <<EOT;
+#
+# to prevent LiveFrame galleries from being displayed in the gallery
+# index or in the previous/next gallery interface on the start page,
+# enter their names, each on it's own line, below.
+#
+# e.g.; to hide the gallery "sample" from the index, uncomment the
+# following line:
+#
+
+EOT
+
+ $self->galleries();
+ for my $gallery ($self->{galleries}->Values()) {
+ next unless $gallery->hidden();
+ print HIDDEN $gallery->basename(), "\n";
+ }
+
+ close HIDDEN;
+
+ return 1;
+}
+
+sub write_order_file {
+ my $self = shift;
+
+ my $order_file = $self->order_file();
+ sysopen ORDER, $order_file, Fcntl::O_WRONLY|Fcntl::O_CREAT|Fcntl::O_TRUNC, 0644 or
+ die "can't write $order_file: $!\n";
+ binmode ORDER;
+
+ print ORDER <<EOT;
+#
+# to specify the order of LiveFrame galleries manually, set the manual
+# gallery ordering variable in your liveframe script to "yes" and enter
+# the name of each gallery directory, each on it's own line, below.
+#
+
+EOT
+
+ $self->galleries();
+ for my $gallery ($self->{galleries}->Values()) {
+ print ORDER $gallery->basename(), "\n";
+ }
+
+ close ORDER;
+
+ return 1;
}
1;
No revision
No revision
1.4 +64 -32 commons/lib/LiveFrame/Site.pm
Index: Site.pm
===================================================================
RCS file: /cvsroot/liveframe/commons/lib/LiveFrame/Site.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Site.pm 2002/01/04 00:27:03 1.3
+++ Site.pm 2002/01/04 01:12:53 1.4
@@ -94,6 +94,9 @@
$self->{galleries} = $new;
}
+ $self->write_hidden_file() if $gallery->hidden();
+ $self->write_order_file();
+
return 1;
}
@@ -107,48 +110,19 @@
$perms ||= 0755;
if ($self->exists()) {
- die "can't create: site previously exists\n";
+ die "can't create site ", $self->path(), ": site previously exists\n";
}
my $old_umask = umask;
umask 0000;
my $path = $self->path();
- warn "mkpath $path\n";
File::Path::mkpath($path, undef, $perms) or
die "can't mkdir $path: $!\n";
-
- my $order_file = $self->order_file();
- sysopen ORDER, $order_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
- die "can't write $order_file: $!\n";
- binmode ORDER;
- print ORDER <<EOT;
-#
-# to specify the order of LiveFrame galleries manually, set the manual
-# gallery ordering variable in your liveframe script to "yes" and enter
-# the name of each gallery directory, each on it's own line, below.
-#
-EOT
- close ORDER;
+ $self->write_order_file();
+ $self->write_hidden_file();
- my $hidden_file = $self->hidden_file();
- sysopen HIDDEN, $hidden_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
- die "can't write $hidden_file: $!\n";
- binmode HIDDEN;
- print HIDDEN <<EOT;
-#
-# to prevent LiveFrame galleries from being displayed in the gallery
-# index or in the previous/next gallery interface on the start page,
-# enter their names, each on it's own line, below.
-#
-# e.g.; to hide the gallery "sample" from the index, uncomment the
-# following line:
-#
-
-EOT
- close HIDDEN;
-
umask $old_umask;
$self->{exists} = 1;
@@ -235,6 +209,64 @@
sub order_file {
my ($self) = @_;
return File::Spec->catfile($self->path(), ORDER_FILE);
+}
+
+sub write_hidden_file {
+ my $self = shift;
+
+ my $hidden_file = $self->hidden_file();
+ sysopen HIDDEN, $hidden_file, Fcntl::O_WRONLY|Fcntl::O_CREAT, 0644 or
+ die "can't write $hidden_file: $!\n";
+ binmode HIDDEN;
+
+ print HIDDEN <<EOT;
+#
+# to prevent LiveFrame galleries from being displayed in the gallery
+# index or in the previous/next gallery interface on the start page,
+# enter their names, each on it's own line, below.
+#
+# e.g.; to hide the gallery "sample" from the index, uncomment the
+# following line:
+#
+
+EOT
+
+ $self->galleries();
+ for my $gallery ($self->{galleries}->Values()) {
+ next unless $gallery->hidden();
+ print HIDDEN $gallery->basename(), "\n";
+ }
+
+ close HIDDEN;
+
+ return 1;
+}
+
+sub write_order_file {
+ my $self = shift;
+
+ my $order_file = $self->order_file();
+ sysopen ORDER, $order_file, Fcntl::O_WRONLY|Fcntl::O_CREAT|Fcntl::O_TRUNC, 0644 or
+ die "can't write $order_file: $!\n";
+ binmode ORDER;
+
+ print ORDER <<EOT;
+#
+# to specify the order of LiveFrame galleries manually, set the manual
+# gallery ordering variable in your liveframe script to "yes" and enter
+# the name of each gallery directory, each on it's own line, below.
+#
+
+EOT
+
+ $self->galleries();
+ for my $gallery ($self->{galleries}->Values()) {
+ print ORDER $gallery->basename(), "\n";
+ }
+
+ close ORDER;
+
+ return 1;
}
1;
|