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
55c097ad
Commit
55c097ad
authored
11 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
copied Tomboy module from CVS repository
parent
55b758f5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+3
-2
3 additions, 2 deletions
README.md
perl/Gnome-Tomboy/lib/Tomboy/Note/Simple.pm
+173
-0
173 additions, 0 deletions
perl/Gnome-Tomboy/lib/Tomboy/Note/Simple.pm
perl/Gnome-Tomboy/s1.pl
+25
-0
25 additions, 0 deletions
perl/Gnome-Tomboy/s1.pl
with
201 additions
and
2 deletions
README.md
+
3
−
2
View file @
55c097ad
...
@@ -4,6 +4,7 @@ formats.
...
@@ -4,6 +4,7 @@ formats.
repository structure
repository structure
====================
====================
*
perl/wiki-confluence/ process Atlassian/Confluence Wiki XML dumps.
*
perl/Wiki-Confluence/ process Atlassian/Confluence Wiki XML dumps.
*
perl/ebook-calibre/ (coming soon)
*
perl/ebook-calibre/ (coming soon)
*
perl/Gnome-Tomboy/ simple module for Tomboy note files
This diff is collapsed.
Click to expand it.
perl/Gnome-Tomboy/lib/Tomboy/Note/Simple.pm
0 → 100755
+
173
−
0
View file @
55c097ad
#!/usr/bin/perl
package
Tomboy::Note::
Simple
;
=head1 NAME
Tomboy::Note::Simple;
=head1 SYNOPSIS
# version 1
my $n1= parse Tomboy::Note::Simple ($note_fnm);
# version 2
my $n2= new Tomboy::Note::Simple; $n->parse ($note_fnm);
=head1 DESCRIPTION
Simple abstraction for notes written with Gnome's Tomboy.
The script uses XML::Parser in Tree style and uses it's parse
tree as the note's content datastructure.
=cut
use
strict
;
use
XML::
Parser
;
use
JSON
;
use
Data::
Dumper
;
$
Data::Dumper::
Indent
=
1
;
my
%fields
=
(
'
title
'
=>
{},
'
last-change-date
'
=>
{},
'
last-metadata-change-date
'
=>
{},
'
create-date
'
=>
{},
'
cursor-position
'
=>
{},
'
selection-bound-position
'
=>
{},
'
width
'
=>
{},
'
height
'
=>
{},
'
x
'
=>
{},
'
y
'
=>
{},
'
open-on-startup
'
=>
{},
);
sub
new
{
my
$class
=
shift
;
my
%par
=
@_
;
my
$note
=
{};
bless
$note
,
$class
;
foreach
my
$par
(
keys
%par
)
{
$note
->
{
$par
}
=
$par
{
$par
};
}
$note
;
}
sub
empty_text
{
my
$note
=
shift
;
$note
->
{'
text
'}
=
[
{
'
xml:space
'
=>
'
preserve
'
},
'
note-content
',
[
{
'
version
'
=>
'
0.1
'
},
0
,
'
empty text
'
]
];
1
;
}
sub
parse
{
my
$c
=
shift
;
my
$fnm
=
shift
;
my
$note
;
if
(
ref
(
$c
)
eq
'
Tomboy::Note::Simple
')
{
$note
=
$c
;
}
elsif
(
ref
(
$c
)
eq
'')
{
print
"
create new c=[
$c
]
\n
";
$note
=
new
Tomboy::Note::
Simple
;
}
else
{
print
"
unknown c=[
$c
] r=[
",
ref
(
$c
),
"
]
\n
";
}
# print "note=[$note]\n";
$note
->
{'
fnm
'}
=
$fnm
;
my
$p
=
new
XML::
Parser
(
Style
=>
'
Tree
');
# print "p: ", Dumper ($p);
my
$l1
=
$p
->
parsefile
(
$fnm
,
ErrorContext
=>
3
);
# print "l1: ", Dumper ($l1);
my
(
$tag
,
$nc
,
@rest
)
=
@$l1
;
# print "res: ", Dumper ($res);
if
(
$tag
ne
'
note
'
||
(
my
$r
=
ref
(
$nc
))
ne
'
ARRAY
')
{
print
"
unknown format fnm=[
$fnm
] tag=[
$tag
] r=[
$r
]
\n
";
return
undef
;
}
# || @rest)
my
$attr
=
shift
(
@$nc
);
# print "attr: ", main::Dumper ($attr);
$note
->
{'
attr
'}
=
$attr
;
while
(
@$nc
)
{
my
$k
=
shift
(
@$nc
);
my
$v
=
shift
(
@$nc
);
next
if
(
$k
eq
'
0
');
if
(
$k
eq
'
text
')
{
# print "text: ", main::Dumper ($v);
$note
->
{'
text
'}
=
$v
;
}
elsif
(
$k
eq
'
tags
')
{
# print "tags: ", main::Dumper ($v);
shift
(
@$v
);
# attributes of "tags"
while
(
@$v
)
{
my
$t1
=
shift
(
@$v
);
my
$t2
=
shift
(
@$v
);
# print "t1=[$t1] t2=[$t2]\n";
if
(
$t1
eq
'
0
')
{}
# skip text
elsif
(
$t1
eq
'
tag
')
{
# print "t2: [$t2]\n";
push
(
@
{
$note
->
{'
tags
'}},
$t2
->
[
2
]);
# ZZZ
}
}
}
elsif
(
exists
(
$fields
{
$k
}))
{
$note
->
{
$k
}
=
$v
->
[
2
];
}
else
{
print
"
unknown field k: [
$k
]
",
main::
Dumper
(
$v
);
}
}
$note
;
}
1
;
__END__
=head1 AUTHOR
Gerhard Gonter <ggonter@gmail.com>
=cut
This diff is collapsed.
Click to expand it.
perl/Gnome-Tomboy/s1.pl
0 → 100755
+
25
−
0
View file @
55c097ad
#!/usr/bin/perl
use
strict
;
use
lib
'
lib
';
use
Tomboy::Note::
Simple
;
use
Data::
Dumper
;
$
Data::Dumper::
Indent
=
1
;
my
$note_fnm
=
shift
(
@ARGV
);
die
"
no note filename specified
"
unless
(
$note_fnm
);
# V1:
# my $n= parse Tomboy::Note::Simple ($note_fnm);
# V2:
my
$n
=
new
Tomboy::Note::
Simple
;
$n
->
parse
(
$note_fnm
);
print
"
n:
",
Dumper
(
$n
);
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