store timefmt and restore on reload
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 27 Jun 2023 13:48:08 +0000 (15:48 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 27 Jun 2023 13:48:08 +0000 (15:48 +0200)
lib/MojoFacets/Data.pm

index e1dc8ac..eceafb7 100644 (file)
@@ -69,6 +69,9 @@ sub index {
 
        find( sub {
                my $file = $File::Find::name;
+
+               next if $file =~ m/.timefmt$/;
+
                if ( -f $file && $file =~ m/([^\/]+)\.changes\/(\d+[\.,]\d+.+)/ ) {
                        push @{ $changes->{$1} }, $2
                } elsif ( import_module( $file ) ) {
@@ -261,6 +264,11 @@ sub _load_path {
        $loaded->{ $path } = $info;
        $self->_save( $path ) unless $info->{generated};
 
+       my $timefmt_path = $self->_permanent_path( 'timefmt' );
+       if ( -e $timefmt_path ) {
+               $self->session( 'timefmt', read_file $timefmt_path );
+       }
+
 }
 
 
@@ -734,6 +742,14 @@ sub items {
 
        $self->_switch_dataset;
 
+       if ( my $timefmt = $self->param('timefmt') ) {
+               $self->session('timefmt', $timefmt);
+               warn "session store timefmt $timefmt\n";
+               my $timefmt_path = $self->_permanent_path( 'timefmt' );
+               write_file $timefmt_path, $timefmt;
+               warn "## $timefmt_path $timefmt"
+       }
+
        if ( my $show = $self->param('id') ) {
                $self->param('show', $show);
                warn "show $show\n";