~duncan-bayne/halp

213baac8c96eb6bad58d39207b0c165db7caae31 — Duncan Bayne a month ago cf49e48
Lots of style cleanup

+ Consistent formatting.
+ Consistent quotes.
+ Editorconfig.
+ Removed some logging.
3 files changed, 32 insertions(+), 17 deletions(-)

A .editorconfig
M lib/Halp/Generator.pm
M t/Halp/generation_test.t
A .editorconfig => .editorconfig +16 -0
@@ 0,0 1,16 @@
root = true

[**]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = false
trim_trailing_whitespace = true

[Makefile]
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = false
trim_trailing_whitespace = true

M lib/Halp/Generator.pm => lib/Halp/Generator.pm +7 -8
@@ 2,12 2,12 @@ package Halp::Generator;

use strict;
use warnings;
use feature "switch";
use feature 'switch';

use Cwd;
use Data::Dump qw(dump);
use File::Basename;
use File::Copy::Recursive "dircopy";
use File::Copy::Recursive 'dircopy';
use File::Slurp;
use File::Spec;
use File::Spec qw(abs2rel rel2abs);


@@ 60,7 60,7 @@ sub wrap_page_template {
    my $menu = $self->generate_menu($self->{input_path});
    my $template_pathname = File::Spec->catfile($self->{template_path}, "page.$self->{template_type}.tpl");
    my $template = Text::Template->new(SOURCE => $template_pathname);
    my $atom_url = File::Spec->catfile(dirname(File::Spec->abs2rel($source_filename, $self->{input_path})), "feed.xml");
    my $atom_url = File::Spec->catfile(dirname(File::Spec->abs2rel($source_filename, $self->{input_path})), 'feed.xml');

    my $footer = '';
    my $footer_pathname = '';


@@ 79,13 79,13 @@ sub wrap_page_template {
	given ($template_type) {
	    when ('html') { $atom_feed = "<a href='$atom_url'><img class='feed-logo' src='/.static/images/atom.png' alt='Atom Feed'></a>"; }
	    when ('gmi')  { $atom_feed = "=> $atom_url Atom Feed\n"; }
	    default       { die "Unsupported template type"; }
	    default       { die 'Unsupported template type'; }
	}
    }

    my @stylesheets = [];
    if ($self->{include_stylesheets}) {
	my $custom_css_pathname = File::Spec->catfile($self->{input_path}, ".static/styles/custom.css");
	my $custom_css_pathname = File::Spec->catfile($self->{input_path}, '.static/styles/custom.css');
	if (-f $custom_css_pathname) {
	    @stylesheets = ['halp.css', 'custom.css'];
	} else {


@@ 129,7 129,7 @@ sub generate_directory {

    my $title = directory_title($source_path);

    my $directory_description = "";
    my $directory_description = '';
    my $description_pathname = File::Spec->catfile($source_path, ".description.$self->{template_type}");
    if (-f $description_pathname) {
	$directory_description = read_file($description_pathname);


@@ 138,7 138,6 @@ sub generate_directory {

    if ($relative_path !~ /^\..+$/) {
	my $template_pathname = File::Spec->catfile($self->{template_path}, "directory_listing.$self->{template_type}.tpl");
	print "$template_pathname\n";
	my $template = Text::Template->new(SOURCE => $template_pathname);
	my @items = directory_listing($self->{input_path}, $source_path, 0);
	my $result = $template->fill_in(HASH => {'path' => $source_path,


@@ 151,7 150,7 @@ sub generate_directory {
	print $file $result;
	close $file;

	my $atom_file = File::Spec->catfile($output_path, "feed.xml");
	my $atom_file = File::Spec->catfile($output_path, 'feed.xml');
	my $atom_feed = feed_for($self->{host}, $source_path, $self->{input_path}, $self->{domain}, $self->{author});
	open $file, '>', $atom_file or die "Can't open '$index_file'";
	print $file $atom_feed;

M t/Halp/generation_test.t => t/Halp/generation_test.t +9 -9
@@ 10,19 10,19 @@ use Test::More;

use Test::More tests => 4;

system("git clean -fdx ./tmp");
system('git clean -fdx ./tmp');

my $result = system("perl ./halp.pl --config-filename ./dev-config/halp-config.pl --web");
ok($result == 0, "halp --web executed");
my $result = system('perl ./halp.pl --config-filename ./dev-config/halp-config.pl --web');
ok($result == 0, 'halp --web executed');

$result = system("diff -r ./t/expected/www ./tmp/www");
ok($result == 0, "all files generated with expected content");
$result = system('diff -r ./t/expected/www ./tmp/www');
ok($result == 0, 'all files generated with expected content');

$result = system("perl ./halp.pl --config-filename ./dev-config/halp-config.pl --gemini");
ok($result == 0, "halp --gemini executed");
$result = system('perl ./halp.pl --config-filename ./dev-config/halp-config.pl --gemini');
ok($result == 0, 'halp --gemini executed');

$result = system("diff -r ./t/expected/gemini ./tmp/gemini");
ok($result == 0, "all files generated with expected content");
$result = system('diff -r ./t/expected/gemini ./tmp/gemini');
ok($result == 0, 'all files generated with expected content');

exit(0);