| 1 | # | ||
| 2 | # This file is part of Markdown::Publish. | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | # Full license text is available at: | ||
| 10 | # | ||
| 11 | # <http://dev.perl.org/licenses/> | ||
| 12 | # | ||
| 13 | package Markdown::Publish::Constant; | ||
| 14 | |||
| 15 | use strict qw(vars); | ||
| 16 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %Constant); | ||
| 17 | use warnings; | ||
| 18 | |||
| 19 | use Cwd qw(abs_path); | ||
| 20 | |||
| 21 | $VERSION='1.003'; | ||
| 22 | |||
| 23 | %Constant=( | ||
| 24 | MARKDOWN_PUBLISH_MODULE => 'Markdown::Publish::MkDocs', | ||
| 25 | MARKDOWN_PUBLISH_CONFIG_FN => 'doc/project.json', | ||
| 26 | MARKDOWN_PUBLISH_OUTPUT_DN => 'site', | ||
| 27 | MARKDOWN_PUBLISH_BRANCH => 'gh-pages', | ||
| 28 | MARKDOWN_PUBLISH_NPM_VERBOSE => 0, | ||
| 29 | MARKDOWN_PUBLISH_HOST => undef, | ||
| 30 | MARKDOWN_PUBLISH_PORT => undef | ||
| 31 | ); | ||
| 32 | |||
| 33 | # Local preferences sit beside the installed module. Environment variables | ||
| 34 | # with the same names take precedence over both the file and built-in values. | ||
| 35 | # | ||
| 36 | my $local_fn=abs_path(__FILE__).'.local'; | ||
| 37 | if (-f $local_fn) { | ||
| 38 | my $local_hr=do($local_fn); | ||
| 39 | die "unable to load local publication constants $local_fn: ".($@ || $! || 'expected a hash reference')."\n" | ||
| 40 | unless ref($local_hr) eq 'HASH'; | ||
| 41 | @Constant{keys(%{$local_hr})}=values(%{$local_hr}); | ||
| 42 | } | ||
| 43 | foreach my $name (keys(%Constant)) { | ||
| 44 | $Constant{$name}=$ENV{$name} if defined($ENV{$name}); | ||
| 45 | } | ||
| 46 | |||
| 47 | require Exporter; | ||
| 48 | @ISA=qw(Exporter); | ||
| 49 | { | ||
| 50 | no warnings qw(once); | ||
| 51 | foreach (keys(%Constant)) {${$_}=$Constant{$_}} | ||
| 52 | } | ||
| 53 | @EXPORT=map {'$'.$_} keys(%Constant); | ||
| 54 | @EXPORT_OK=@EXPORT; | ||
| 55 | %EXPORT_TAGS=(all => [@EXPORT_OK]); | ||
| 56 | |||
| 57 | 1; | ||
| 58 | __END__ |