$class = ref($this);
my $parent = $this;
my $name = shift;
- my $fullpath = $parent->{-fullpath}.'/'.$name;
$self = {
-parent=>$parent,
-root=>$parent->{-root},
+ -toppath=>$parent->{-toppath},
+ -depth=>$parent->{-depth}+1,
-base=>$name,
- -fullpath=>$fullpath,
+ -fullpath=>$parent->{-fullpath}.'/'.$name,
+ -relpath=>$parent->{-relpath}.'/'.$name,
-inc=>'../'.$parent->{-inc},
- -rss=>'../'.$parent->{-rss},
};
} else {
$class = $this;
my $root=shift;
$self = {
+ -depth=>0,
-root=>$root,
-fullpath=>$root,
- -inc=>getinc($root),
- -rss=>getrss($root),
};
+ # fill in -inc, -rss, -relpath
+ initpaths($self); # we are not blessed yet, so cheat.
}
bless $self, $class;
if ($debug) {
return $self;
}
-sub getinc {
- my $fullpath=shift; # this is not a method
+sub initpaths {
+ my $self=shift; # this is not a method but we cheat
my $depth=20; # arbitrary max depth
+ my $fullpath=$self->{-fullpath};
+ my $inc;
+ my $rss;
+ my $relpath;
if ($incpath) {
- return $incpath."/.gallery2";
- }
-
- my $inc=".gallery2";
- while ( ! -d $fullpath."/".$inc ) {
- $inc = "../".$inc;
- last unless ($depth-- > 0);
+ $inc = $incpath."/.gallery2";
+ } else {
+ $inc=".gallery2";
+ while ( ! -d $fullpath."/".$inc ) {
+ $inc = "../".$inc;
+ last unless ($depth-- > 0);
+ }
}
if ($depth > 0) {
- return $inc.'/'; # prefix with trailing slash
+ $self->{-inc} = $inc.'/';
+ my $dp=0;
+ my $pos;
+ for ($pos=index($inc,'/');$pos>=0;
+ $pos=index($inc,'/',$pos+1)) {
+ $dp++;
+ }
+ for ($pos=length($fullpath);$dp-->0 && $pos>0;
+ $pos=rindex($fullpath,'/',$pos-1)) {;}
+ my $relpath = substr($fullpath,$pos);
+ $relpath =~ s%^/%%;
+ $self->{-relpath} = $relpath;
+ $self->{-toppath} = substr($fullpath,0,$pos);
+ initrss($self);
} else {
- return 'NO-.INCLUDE-IN-PATH/'; # won't work anyway
+ $self->{-inc} = 'NO-.INCLUDE-IN-PATH/'; # won't work anyway
+ $self->{-rss} = '';
+ $self->{-relpath} = '';
}
}
-sub getrss {
- my $fullpath=shift; # this is not a method
- my $depth=20; # arbitrary max depth
+sub initrss {
+ my $self=shift; # this is not a method but we cheat
+ my $fullpath=$self->{-fullpath};
+ my $depth=20;
+ return;
return "" unless $rssfile;
my $rss=$rssfile;
close($T);
}
if ($asktitle || (!$title && !$noasktitle)) {
- my $prompt = $self->{-base};
+ my $prompt = $self->{-relpath};
$prompt = '/' unless ($prompt);
my $OUT = $term->OUT || \*STDOUT;
print $OUT "Enter title for $fullpath\n";
}
}
unless ($title) {
- $title=substr($fullpath,length($self->{-root}));
+ $title=$self->{-relpath};
}
$self->{-title}=$title;
print "title in $fullpath is $title\n" if ($debug);
print $IND start_html(-title => $title,
-encoding=>"utf-8",
-head=>$rsslink,
- -style=>{-src=>$inc."gallery.css"},
+ -style=>[
+ {-src=>$inc."gallery.css"},
+ {-src=>$inc."custom.css"},
+ ],
-script=>[
{-src=>$inc."mootools.js"},
{-src=>$inc."overlay.js"},
comment("Created by ".$version),"\n",
start_div({-class => 'indexContainer',
-id => 'indexContainer'}),
- a({-href=>"../index.html"},"UP"),"\n",
- start_center,"\n",
- h1($title),"\n",
"\n";
+ my $EVL;
+ if (open($EVL,$inc.'header.pl')) {
+ my $prm;
+ while (<$EVL>) {
+ $prm .= $_;
+ }
+ close($EVL);
+ %_ = (
+ -version => $version,
+ -depth => $self->{-depth},
+ -title => $title,
+ -breadcrumbs => "breadcrumbs unimplemented",
+ );
+ print $IND eval $prm,"\n";
+ } else {
+ print $IND a({-href=>"../index.html"},"UP"),"\n",
+ h1({-class=>'title'},$title),"\n",
+ }
}
sub endindex {
my $self = shift;
my $IND = $self->{-IND};
- print $IND end_center,end_div,
- # "\n",'<script type="text/javascript">init_gallery();</script>',"\n",
- end_html,"\n";
+ print $IND end_div;
+ my $EVL;
+ if (open($EVL,$self->{-inc}.'footer.pl')) {
+ my $prm;
+ while (<$EVL>) {
+ $prm .= $_;
+ }
+ close($EVL);
+ %_ = (
+ -version => $version,
+ -depth => $self->{-depth},
+ -title => $self->{-title},
+ -breadcrumbs => "breadcrumbs unimplemented",
+ );
+ print $IND eval $prm,"\n";
+ }
+ print $IND end_html,"\n";
close($IND) if ($IND);
undef $self->{-IND};
my $self = shift;
my $IND = $self->{-IND};
- print $IND h2("Albums"),"\n",start_table,"\n";
+ print $IND h2({-class=>"atitle"},"Albums"),"\n",start_table,"\n";
}
sub sub_entry {
my $first = $self->{-firstimg}->{-base};
my $slideref = sprintf(".html/%s-slide.html",$first);
- print $IND h2("Images ",
+ print $IND h2({-class=>"ititle"},"Images ",
a({-href=>$slideref,-class=>'showStart',-rel=>'i'.$first},
'> slideshow')),"\n";
}
my $h=$self->{$sz}->{'dim'}->[1];
print $IND " ",a({-href=>$src,
-class=>"conceal",
+ -rel=>$w."x".$h,
-title=>"Reduced to ".$w."x".$h},
$w."x".$h)," \n";
}
print $IND " ",a({-href=>$name,
+ -rel=>$w."x".$h,
-title=>'Original'},$w."x".$h),
"\n",end_div,"\n",
end_td,end_Tr,end_table,"\n";