Skip to content
Snippets Groups Projects
Commit 66295887 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

TOC generation improved

parent 663aa6a5
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,9 @@ use strict;
use Tomboy::Note::Simple;
my @TB_note_attrs= qw(title create-date last-change-date last-metadata-change-date);
my @TB_meta_attrs= qw(uid mtime size notebook is_template);
# attributes read from the note itself or from the filesystem
my @TB_note_attrs= qw(title create-date last-change-date last-metadata-change-date notebook is_template fnm);
my @TB_meta_attrs= qw(uuid mtime size);
sub TB_attrs { return (@TB_meta_attrs, @TB_note_attrs) }
sub new
......@@ -46,6 +47,7 @@ sub scan_dir
my $obj= shift;
my $dir= shift;
$dir=~ s#/+$##;
unless (opendir (DIR, $dir))
{
print "ATTN: can't read directory [$dir]\n";
......@@ -57,7 +59,7 @@ sub scan_dir
{
next NOTE if ($e eq '.' || $e eq '..');
next NOTE unless ($e =~ /(.+)\.note$/);
my $uid= $1;
my $fnm_uuid= $1;
my $fp= join ('/', $dir, $e);
# print "reading note [$fp]\n"; # TODO: if verbose...
......@@ -75,18 +77,25 @@ sub scan_dir
print "ATTN: parsing [$fp] returned undefined note!\n";
next NOTE;
}
# print "n: ", main::Dumper ($n);
my %rec= map { $_ => $n->{$_} } @TB_note_attrs;
$rec{'uid'}= $uid;
$rec{'uuid'}= $fnm_uuid;
$rec{'mtime'}= $st[9];
$rec{'size'}= $st[7];
=begin comment
... this is now part of Tomboy::Note::Simple
foreach my $tag (@{$n->{'tags'}})
{
if ($tag =~ m#system:notebook:(.+)#) { $rec{'notebook'}= $1 }
elsif ($tag eq 'system:template') { $rec{'is_template'}= 1; }
elsif ($tag eq 'system:template') { $rec{'is_template'}= 1 }
}
=end comment
=cut
push (@res, \%rec);
}
......
#!/usr/bin/perl
=head1 NAME
s2.pl
=head1 DESCRIPTION
Script to play with Tomboy::Directory for testing.
Generates a CSV file as TOC (table of contents) which might be useful.
=cut
use strict;
use lib 'lib';
......@@ -16,6 +28,7 @@ my $toc_file= 'Tomboy-TOC.csv';
die "no note dir specified" unless ($note_dir);
$note_dir=~ s#/+$##;
my $tb_d= new Tomboy::Directory ('dir' => $note_dir);
print "tb_d: ", Dumper ($tb_d);
......@@ -26,7 +39,7 @@ my $toc_data= $tb_d->scan_dir ($note_dir);
my $toc= new Util::Simple_CSV ('UTF8' => 1, 'no_hash' => 1);
$toc->define_columns (Tomboy::Directory::TB_attrs());
$toc->{'data'}= $toc_data;
$toc->save_csv_file ('filename' => $toc_file);
$toc->save_csv_file ('filename' => $toc_file, 'separator' => "\t", 'UTF8' => 1);
exit (0);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment