App-MaMGal
view release on metacpan or search on metacpan
lib/App/MaMGal/Entry.pm view on Meta::CPAN
}
# TODO: element should not have a need to know its index, container should be able to tell it simply given the object
sub element_index { $_[0]->{element_index} }
sub set_element_index { $_[0]->{element_index} = $_[1] }
sub name { $_[0]->{base_name} }
sub description { '' }
sub set_container { $_[0]->{container} = $_[1] }
sub container
{
my $self = shift;
unless (defined $self->{container}) {
# TODO this will lead to creation of a strange split tree if it
# is traversed again from container to this child
$self->set_container($self->tools->{entry_factory}->create_entry_for($self->{dir_name}));
}
return $self->{container};
}
sub containers
{
my $self = shift;
return ($self->container->containers, $self->container);
}
sub neighbours
{
my $self = shift;
# TODO this should in theory use container method rather than the hash
# element, but because this method needs element_index to be available
# (which is only set in the entity if it is instantiated by its
# container), then this will break in mysterious ways if the container
# method has to instantiate the container object
return (undef, undef) unless $self->{container};
return $self->{container}->neighbours_of_index($self->element_index);
}
# Returns the best available approximation of creation time of this entry
sub creation_time
{
my $self = shift;
my $stat = $self->{stat};
# We might not be able to get stat information (broken symlink, no permissions, ...)
return undef unless $stat;
# We need to use st_mtime, for lack of anything better
return $stat->mtime;
}
sub content_modification_time
{
my $self = shift;
return $self->App::MaMGal::Entry::creation_time(@_);
}
sub fresher_than_me
{
my $self = shift;
my $path = shift;
my %opts = @_;
my $stat = stat($path) or return 0;
return 1 if $stat->mtime >= $self->content_modification_time(%opts);
return 0;
}
# Whether this entry should be shown in a directory contents montage
sub is_interesting { }
# Some constants
our $slides_dir = '.mamgal-slides';
sub slides_dir { $slides_dir }
sub thumbnails_dir { '.mamgal-thumbnails' }
sub medium_dir { '.mamgal-medium' }
#######################################################################################################################
# Abstract methods
# these two need to return the text of the link ...
sub page_path { croak(sprintf("INTERNAL ERROR: Class [%s] does not define page_path.", ref(shift))) }
sub thumbnail_path { croak(sprintf("INTERNAL ERROR: Class [%s] does not define thumbnail_path.", ref(shift))) }
1;
( run in 1.883 second using v1.01-cache-2.11-cpan-97f6503c9c8 )