Vimã§é¸æããããã¹ãã Google Notebook ã«ä¿åãã
ã¨ãããã WWW::Google::Notebook ã£ã¦ããã®ãä½ã£ãã
WWW-Google-Notebook-0.01 - Perl interface for Google Notebook - metacpan.org
http://d.hatena.ne.jp/bonar/20061002/1159745024 ã§ç´¹ä»ããã¦ãã Python ã® Google Notebook ã®ã©ã¤ãã©ãªãè¦ã¦ãFirebug ã§è§£æããªããä½ã£ãã Firebug ãµã¤ã³ã¦ã
ã§ãã¤ã³ã¹ãã¼ã«ãã¦ããããªã¹ã¯ãªãããã©ã£ãã«ããã¦ããã
#!/usr/local/bin/perl use strict; use warnings; use Encode; use Encode::Guess qw(utf8 euc-jp shiftjis 7bit-jis); use WWW::Google::Notebook; my $username = '[email protected]'; my $password = 'password'; my $title = 'vim'; my $google = WWW::Google::Notebook->new( username => $username, password => $password, ); $google->login; my $notebooks = $google->notebooks; my ($notebook) = grep { $_->title eq $title } @$notebooks; $notebook = $google->add_notebook($title) unless $notebook; my $content = do { local $/; <STDIN> }; $content = encode('utf8', decode('Guess', $content)); $notebook->add_note($content); print $content;
追è¨
æåã³ã¼ãå¤æã追å ã
ãã¨ã¯Vim㧠v ãªã V ã§é¸æãã¦
:'<,'>!/path/to/scriptname.pl
ã¨ãããã¨ä¿åãããã
.vimrcã«
vnoremap <leader>gn :'<,'>!/path/to/scriptname.pl<CR>
ã¨ããã£ã¨ã㨠\gnã§ãµã¯ã£ã¨ä¿ååºæ¥ãã
対話åã®ã¹ã¯ãªããã¯ãããªæãã§ã
#!/usr/local/bin/perl use strict; use warnings; use Term::ReadLine; use Term::ReadPassword; use WWW::Google::Notebook; my $term = Term::ReadLine->new; my $username = $term->readline('username: '); my $password = read_password('password: '); my $google = WWW::Google::Notebook->new( username => $username, password => $password, ); $google->login; my $notebooks = $google->notebooks; my $index = 0; for my $notebook (@$notebooks) { printf '[%d] %s'."\n", $index++, $notebook->name; } my $selected = $term->readline('notebook: '); die 'invalid notebook' if $selected !~ /^\d+$/ or $selected >= @$notebooks; my $notebook = $notebooks->[$selected] or die 'invalid notebook'; my $content = join '', <STDIN>; $notebook->add_note($content); print "added your note!\n";