Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
docu-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
docu-tools
Commits
66295887
Commit
66295887
authored
11 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
TOC generation improved
parent
663aa6a5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
perl/Gnome-Tomboy/lib/Tomboy/Directory.pm
+15
-6
15 additions, 6 deletions
perl/Gnome-Tomboy/lib/Tomboy/Directory.pm
perl/Gnome-Tomboy/s2.pl
+14
-1
14 additions, 1 deletion
perl/Gnome-Tomboy/s2.pl
with
29 additions
and
7 deletions
perl/Gnome-Tomboy/lib/Tomboy/Directory.pm
+
15
−
6
View file @
66295887
...
@@ -20,8 +20,9 @@ use strict;
...
@@ -20,8 +20,9 @@ use strict;
use
Tomboy::Note::
Simple
;
use
Tomboy::Note::
Simple
;
my
@TB_note_attrs
=
qw(title create-date last-change-date last-metadata-change-date)
;
# attributes read from the note itself or from the filesystem
my
@TB_meta_attrs
=
qw(uid mtime size notebook is_template)
;
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
TB_attrs
{
return
(
@TB_meta_attrs
,
@TB_note_attrs
)
}
sub
new
sub
new
...
@@ -46,6 +47,7 @@ sub scan_dir
...
@@ -46,6 +47,7 @@ sub scan_dir
my
$obj
=
shift
;
my
$obj
=
shift
;
my
$dir
=
shift
;
my
$dir
=
shift
;
$dir
=~
s#/+$##
;
unless
(
opendir
(
DIR
,
$dir
))
unless
(
opendir
(
DIR
,
$dir
))
{
{
print
"
ATTN: can't read directory [
$dir
]
\n
";
print
"
ATTN: can't read directory [
$dir
]
\n
";
...
@@ -57,7 +59,7 @@ sub scan_dir
...
@@ -57,7 +59,7 @@ sub scan_dir
{
{
next
NOTE
if
(
$e
eq
'
.
'
||
$e
eq
'
..
');
next
NOTE
if
(
$e
eq
'
.
'
||
$e
eq
'
..
');
next
NOTE
unless
(
$e
=~
/(.+)\.note$/
);
next
NOTE
unless
(
$e
=~
/(.+)\.note$/
);
my
$uid
=
$
1
;
my
$
fnm_u
uid
=
$
1
;
my
$fp
=
join
('
/
',
$dir
,
$e
);
my
$fp
=
join
('
/
',
$dir
,
$e
);
# print "reading note [$fp]\n"; # TODO: if verbose...
# print "reading note [$fp]\n"; # TODO: if verbose...
...
@@ -75,18 +77,25 @@ sub scan_dir
...
@@ -75,18 +77,25 @@ sub scan_dir
print
"
ATTN: parsing [
$fp
] returned undefined note!
\n
";
print
"
ATTN: parsing [
$fp
] returned undefined note!
\n
";
next
NOTE
;
next
NOTE
;
}
}
# print "n: ", main::Dumper ($n);
my
%rec
=
map
{
$_
=>
$n
->
{
$_
}
}
@TB_note_attrs
;
my
%rec
=
map
{
$_
=>
$n
->
{
$_
}
}
@TB_note_attrs
;
$rec
{'
uid
'}
=
$uid
;
$rec
{'
u
uid
'}
=
$
fnm_u
uid
;
$rec
{'
mtime
'}
=
$st
[
9
];
$rec
{'
mtime
'}
=
$st
[
9
];
$rec
{'
size
'}
=
$st
[
7
];
$rec
{'
size
'}
=
$st
[
7
];
=begin comment
... this is now part of Tomboy::Note::Simple
foreach my $tag (@{$n->{'tags'}})
foreach my $tag (@{$n->{'tags'}})
{
{
if
(
$tag
=~
m#system:notebook:(.+)#
)
{
$rec
{'
notebook
'}
=
$
1
}
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
);
push
(
@res
,
\
%rec
);
}
}
...
...
This diff is collapsed.
Click to expand it.
perl/Gnome-Tomboy/s2.pl
+
14
−
1
View file @
66295887
#!/usr/bin/perl
#!/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
strict
;
use
lib
'
lib
';
use
lib
'
lib
';
...
@@ -16,6 +28,7 @@ my $toc_file= 'Tomboy-TOC.csv';
...
@@ -16,6 +28,7 @@ my $toc_file= 'Tomboy-TOC.csv';
die
"
no note dir specified
"
unless
(
$note_dir
);
die
"
no note dir specified
"
unless
(
$note_dir
);
$note_dir
=~
s#/+$##
;
my
$tb_d
=
new
Tomboy::
Directory
('
dir
'
=>
$note_dir
);
my
$tb_d
=
new
Tomboy::
Directory
('
dir
'
=>
$note_dir
);
print
"
tb_d:
",
Dumper
(
$tb_d
);
print
"
tb_d:
",
Dumper
(
$tb_d
);
...
@@ -26,7 +39,7 @@ my $toc_data= $tb_d->scan_dir ($note_dir);
...
@@ -26,7 +39,7 @@ my $toc_data= $tb_d->scan_dir ($note_dir);
my
$toc
=
new
Util::
Simple_CSV
('
UTF8
'
=>
1
,
'
no_hash
'
=>
1
);
my
$toc
=
new
Util::
Simple_CSV
('
UTF8
'
=>
1
,
'
no_hash
'
=>
1
);
$toc
->
define_columns
(
Tomboy::Directory::
TB_attrs
());
$toc
->
define_columns
(
Tomboy::Directory::
TB_attrs
());
$toc
->
{'
data
'}
=
$toc_data
;
$toc
->
{'
data
'}
=
$toc_data
;
$toc
->
save_csv_file
('
filename
'
=>
$toc_file
);
$toc
->
save_csv_file
('
filename
'
=>
$toc_file
,
'
separator
'
=>
"
\t
",
'
UTF8
'
=>
1
);
exit
(
0
);
exit
(
0
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment