Skip to content

Commit

Permalink
Merge pull request #5 from MaxPerl/master
Browse files Browse the repository at this point in the history
Bugfix and UTF 8 output for the Textile Convertor
  • Loading branch information
alanhaggai committed Oct 16, 2016
2 parents fe2bb0a + 868b1f9 commit 3e9081d
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 7 deletions.
58 changes: 52 additions & 6 deletions lib/StaticVolt.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# ABSTRACT: Static website generator

package StaticVolt;
{
$StaticVolt::VERSION = '1.00';
}

use strict;
use warnings;
Expand All @@ -21,7 +24,7 @@ use StaticVolt::Convertor::Textile;

sub new {
my ( $class, %config ) = @_;

my %config_defaults = (
'includes' => '_includes',
'layouts' => '_layouts',
Expand Down Expand Up @@ -59,7 +62,7 @@ sub _gather_files {
my $self = shift;

my $source = $self->{'source'};
find sub { _traverse_files $self }, $source;
find sub { _traverse_files($self) }, $source;

return;
}
Expand All @@ -76,8 +79,8 @@ sub _extract_file_config {
}
push @yaml_lines, $line;
}

return Load join '', @yaml_lines;
my $yaml_lines = join '', @yaml_lines;
return Load $yaml_lines;
}
}

Expand Down Expand Up @@ -123,9 +126,28 @@ sub compile {
my $file_layout = $file_config->{'layout'};
my $includes = $self->{'includes'};
my $layouts = $self->{'layouts'};
my $abs_include_path = File::Spec->catfile( getcwd, $includes );
my $abs_layout_path =

# BUGFIX 1
# If you create the StaticVolt with different absolute layout, includes etc. directories
# and therefore start $stratovolt->compile from a different cwd than the directory
# which contains _includes, _layouts etc, don't use getcwd
my $abs_include_path;
my $abs_layout_path;

if (File::Spec->file_name_is_absolute( $includes ) ) {
$abs_include_path = File::Spec->catfile( $includes );
}
else {
$abs_include_path = File::Spec->catfile( getcwd, $includes );
}
if (File::Spec->file_name_is_absolute( $layouts ) ) {
$abs_layout_path =
File::Spec->catfile( $layouts, $file_layout );
}
else {
$abs_layout_path =
File::Spec->catfile( getcwd, $layouts, $file_layout );
}
my $template = Template->new(
'INCLUDE_PATH' => $abs_include_path,
'WRAPPER' => $abs_layout_path,
Expand Down Expand Up @@ -180,6 +202,16 @@ sub _relative_path {

__END__
=pod
=head1 NAME
StaticVolt - Static website generator
=head1 VERSION
version 1.00
=head1 SYNOPSIS
use StaticVolt;
Expand Down Expand Up @@ -435,3 +467,17 @@ L<Shlomi Fish|http://www.shlomifish.org/> for suggesting change of licence.
=head1 See Also
L<Template Toolkit|Template>
=head1 AUTHOR
Alan Haggai Alavi <haggai@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Alan Haggai Alavi.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
=cut
32 changes: 31 additions & 1 deletion lib/StaticVolt/Convertor/Textile.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# ABSTRACT: StaticVolt convertor for textile

package StaticVolt::Convertor::Textile;
{
$StaticVolt::Convertor::Textile::VERSION = '1.00';
}

use strict;
use warnings;
Expand All @@ -11,7 +14,10 @@ use Text::Textile qw( textile );

sub convert {
my $content = shift;
return textile $content;
my $textile=Text::Textile->new();
$textile->charset('utf-8');
my $html_content = $textile->process($content);
return $html_content;
}

__PACKAGE__->register(qw/ textile /);
Expand All @@ -20,10 +26,34 @@ __PACKAGE__->register(qw/ textile /);

__END__
=pod
=head1 NAME
StaticVolt::Convertor::Textile - StaticVolt convertor for textile
=head1 VERSION
version 1.00
=head1 Registered Extensions
=over 4
=item * C<textile>
=back
=head1 AUTHOR
Alan Haggai Alavi <haggai@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Alan Haggai Alavi.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
=cut

1 comment on commit 3e9081d

@alanhaggai
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.