Skip to content

Commit

Permalink
Move howto to Locale and script to format HTML
Browse files Browse the repository at this point in the history
Rather than manually regenerate it and store it in %Lexicon, ship it as
an `.html` file in the appropriate locale directory. Pilfer the
`from_file` Locale method from PGXN::Site, but remove the
Locale::Maketext processing step to avoid the need to escape characters
it looks for. There should be no Locale::Maketext processing anyway:
just the translated document. Fixes #76.

Add `bin/format_l10n_docs`, a simple script that uses `multimarkdown` to
regenerate the `.html` version of Markdown files in `lib`. This will
allow other localize-able documents to be added in the future.
  • Loading branch information
theory committed Feb 17, 2024
1 parent 7ea4abc commit 4816746
Show file tree
Hide file tree
Showing 7 changed files with 467 additions and 393 deletions.
8 changes: 6 additions & 2 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ my $class = $build_pkg->subclass(
},
);

$class->new(
my $build = $class->new(
module_name => 'PGXN::Manager',
license => 'postgresql',
script_files => 'bin',
Expand Down Expand Up @@ -159,4 +159,8 @@ $class->new(
repository => 'https://github.com/pgxn/pgxn-manager/',
}
},
)->create_build_script;
);

# Add html files in lib.
$build->add_build_element('html');
$build->create_build_script;
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Revision history for Perl extension PGXN::Manager
ceases running and doesn't remove its PID file, so never restarts.
- Replaced use of the deprecated `given`/`when` syntax with plain old
`if`/`elsif`/`else`.
- Moved `doc/howto.md` to `lib/PGXN/Manager/Locale/en`, added
`bin/format_l10n_docs` to convert it to HTML, and added `from_file`
to PGXN::Manager::Locale to find and returns its contents. This
allows it to be removed from the Locale `%Lexicon`, which was a
ridiculous waste of memory, and also prevents it from being processed
by Locale::Maketext, which requires tildes to escape brackets and
trailing backslashes (#76).

0.31.1 2023-10-07T21:40:53Z
- Restored the writing of the pgxn_consumer PID file, accidentally
Expand Down
24 changes: 24 additions & 0 deletions bin/format_l10n_docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env perl -w

# Find all .md files in lib, run them through multimarkdown, and write
# to .html.
#
# brew install multimarkdown

use 5.10.0;
use strict;
use warnings;
use utf8;
use File::Find;
use File::Basename qw(basename);

find({
no_chdir => 1,
wanted => sub {
return unless /\.md$/;
my $src = $File::Find::name;
my $dst = $src =~ s/\.md$/.html/r;
my @cmd = ('multimarkdown', $src, '-o', $dst);
system(@cmd) == 0 or die "system @cmd failed: $?\n"
},
}, 'lib');
432 changes: 42 additions & 390 deletions lib/PGXN/Manager/Locale.pm

Large diffs are not rendered by default.

387 changes: 387 additions & 0 deletions lib/PGXN/Manager/Locale/en/howto.html

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 1 addition & 1 deletion lib/PGXN/Manager/Templates.pm
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ template howto => sub {
my ($self, $req, $args) = @_;
wrapper {
h1 { T 'PGXN How To' };
outs_raw T 'howto_body';
outs_raw $l->from_file('howto.html');
} $req, { page_title => 'howto_page_title', $args ? %{ $args } : () };
};

Expand Down

0 comments on commit 4816746

Please sign in to comment.