Browse files

add tags support

  • Loading branch information...
1 parent 73fed1b commit a355966c54f217a577b0cf640847289c0f6e10e0 zag committed Jan 14, 2013
Showing with 36 additions and 14 deletions.
  1. +2 −2 Build.PL
  2. +4 −1 Changes
  3. +1 −1 lib/WriteAt.pm
  4. +23 −1 lib/WriteAt/To/Atom.pm
  5. +1 −1 scripts/atom2file
  6. +5 −8 t/01.bookinfo.t
View
4 Build.PL
@@ -4,9 +4,9 @@ Module::Build->new
( module_name => 'WriteAt',
license => 'perl',
prereq => {
- 'Regexp::Grammars'=>1.015,
+ 'Regexp::Grammars'=>1.021,
'Perl6::Pod::Lib'=>0.11,
- 'Perl6::Pod'=>0.55,
+ 'Perl6::Pod'=>0.57,
'DateTime::Format::W3CDTF'=>0
},
script_files=>[qw!
View
5 Changes
@@ -1,6 +1,9 @@
Revision history for Perl extension WriteAt.
-
+0.03
+ + convert books to atom feed
+ + add latex support
+ + util atom2file
+ track path for =Include
0.02
+ rename to WriteAt,
View
2 lib/WriteAt.pm
@@ -71,7 +71,7 @@ Point your web brouser to C<index.html> file in C<work> directory.
use strict;
use warnings;
use v5.10;
-our $VERSION = '0.02';
+our $VERSION = '0.03';
use WriteAt::CHANGES;
use WriteAt::AUTHOR;
use WriteAt::To::DocBook;
View
24 lib/WriteAt/To/Atom.pm
@@ -127,6 +127,18 @@ sub start_write {
<uri>$base_url</uri>
</author>
TXT
+ # add category if tag exists
+ if ( my $desc_node = $tags{DESCRIPTION}->[0] ) {
+ if ( my $tags = $desc_node->get_attr()->{tag} ) {
+ # save TAGS as ref to array
+ $self->{TAGS} = ref($tags) ? $tags : [$tags];
+ #fill categoty tags
+ foreach my $tag ( @{$self->{TAGS}} ) {
+ $w->raw("<category>$tag</category>\n")
+
+ }
+ }
+ }
}
sub write {
@@ -191,8 +203,17 @@ sub write {
<link rel="alternate" href="$url" title="$title" type="text/html"/>
<published>$published</published>
<updated>$updated</updated>
- <content type="html">%
+ %
);
+ if ( my $tags = $entry->{node}->get_attr->{tag} ) {
+ # save TAGS as ref to array
+ my $local_tags = ref($tags) ? $tags : [$tags];
+ #union tags fill categoty tags
+ foreach my $tag ( @{$local_tags}, @{ $self->{TAGS}|| [] } ) {
+ $w->raw("<category>$tag</category>\n")
+ }
+ }
+
my $out = '';
open( my $fd, ">", \$out );
my $renderer = new Perl6::Pod::To::XHTML::
@@ -211,6 +232,7 @@ sub write {
}
close $fd;
my $safe_text = &Perl6::Pod::Writer::_html_escape($out);
+ $w->raw('<content type="html">');
$w->raw($safe_text);
$w->raw(
'</content>
View
2 scripts/atom2file
@@ -180,7 +180,7 @@ Zahatski Aliaksandr, E<lt>zahatski@gmail.comE<gt>
=head1 COPYRIGHT AND LICENSE
-Copyright 2012 by Zahatski Aliaksandr
+Copyright 2013 by Zahatski Aliaksandr
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
View
13 t/01.bookinfo.t
@@ -9,7 +9,7 @@ package main;
use strict;
use warnings;
use v5.10;
-use Test::More tests => 1; # last test to print
+use Test::More tests => 13; # last test to print
use Perl6::Pod::Utl;
use Data::Dumper;
use WriteAt;
@@ -32,7 +32,7 @@ Jan 08th 2011(v0.5)[zag] Подпрограммы и сигнатуры
=end CHANGES
=AUTHOR Александр Загацкий
-=for CHAPTER :published<'2012-11-27T09:39:19Z'>
+=for CHAPTER :published<'2012-11-27T09:39:19Z'> :tag<intro>
Test chapter
Ok
@@ -78,7 +78,6 @@ my %res2 = ();
my $tree2 = Perl6::Pod::Utl::parse_pod( $t, default_pod => 1 )
|| die "Can't parse ";
$tree2 = &WriteAt::get_book_info_blocks( $tree2, \%res2 );
-
use_ok "WriteAt::To::Atom";
my $out = '';
@@ -109,9 +108,7 @@ $atom->write($tree2);
$atom->end_write();
close $fd;
is scalar( @{ [ $out =~ /(<\/entry>)/gs ] } ), 1, 'default_published';
-
-#$atom
-#print Dumper \%res; exit;
-#print Dumper $tree;
-#warn $str;
+#test DESCRIPTION :tag
+ok $out =~ m%<category>pod6</category>%, '=for DESCRITION :tag<pod6>';
+ok $out =~ m%<category>intro</category>%, '=for CHAPTER :tag<intro>';

0 comments on commit a355966

Please sign in to comment.