diff --git a/Changes.md b/Changes.md
index 375e88a..b3148f4 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,6 +1,18 @@
# Change Log
-## [0.1.2] - 2024-06-16
+## [0.1.4] - 2024-07-01
+
+### Added
+
+- Support for redirection pages
+
+## [0.1.3] - 2024-06-14
+
+### Fixed
+
+- Bug in App::Aphra::File::uri
+
+## [0.1.2] - 2024-06-14
### Added
diff --git a/bin/aphra b/bin/aphra
index db3de53..0bcdf68 100755
--- a/bin/aphra
+++ b/bin/aphra
@@ -213,6 +213,44 @@ And you could access that text inside your templates with markup like this:
<% site.name %>
+=head2 Special variables in site.yml
+
+There are a few special variables that you can define in your `site.yml` file
+which will be used by the program.
+
+=over 4
+
+=item uri, protocol, host, port
+
+These are used to construct the base URL for the site. If you don't define
+these, then the program will try to guess them. It will use the value of the
+`uri` variable if it is defined. If not, it will use the values of the
+`protocol`, `host` and `port` variables. If any of these aren't defined, it
+will use the values "https", the result of calling `hostname` and no port
+(which is, effectively, port 80) respectively.
+
+=item redirects
+
+This is a list of URLs that should be redirected to other URLs. Each entry in
+the list should be a hash containing the keys `from` and `to`. For example:
+
+ redirects:
+ - from: /old/page
+ to: /new/page
+
+The value of "from" should be the path part of the URL that you want to
+redirect and the value of "to" can be either a full URL or a path part of a
+URL. If it is a path part, then the base URL of the site will be prepended to
+it.
+
+Aphra implements these redirects by creating stub HTML files in the output
+directory which contain a meta refresh tag that redirects the browser to the
+new URL. Redirects are created before other files are processed, so any files
+that have the same URL as a redirect will overwrite the redirect stub HTML
+file.
+
+=back
+
=head1 FRONT MATTER IN INDIVIDUAL PAGES
At the start of the template for a page, you can add a data section which
@@ -245,7 +283,7 @@ Dave Cross
=head1 COPYRIGHT AND LICENCE
-Copyright (c) 2017-2023, Magnum Solutions Ltd. All Rights Reserved.
+Copyright (c) 2017-2024, Magnum Solutions Ltd. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
diff --git a/lib/App/Aphra.pm b/lib/App/Aphra.pm
index b39388c..9145ce1 100644
--- a/lib/App/Aphra.pm
+++ b/lib/App/Aphra.pm
@@ -39,7 +39,7 @@ use URI;
use App::Aphra::File;
-our $VERSION = '0.1.2';
+our $VERSION = '0.2.0';
has commands => (
isa => 'HashRef',
@@ -210,6 +210,10 @@ sub build {
-e $src or die "Cannot find $src\n";
-d $src or die "$src is not a directory\n";
+ if ($self->site_vars->{redirects}) {
+ $self->make_redirects;
+ }
+
find({ wanted => $self->_make_do_this, no_chdir => 1 },
$self->config->{source});
}
@@ -228,6 +232,40 @@ sub _make_do_this {
};
}
+sub make_redirects {
+ my $self = shift;
+ my $redirects = $self->site_vars->{redirects};
+
+ return if !$redirects;
+ return if !@$redirects;
+
+ my $target = $self->config->{target};
+
+ for (@$redirects) {
+ my $from = $_->{from};
+ $from .= 'index.html' if $from =~ m|/$|;
+
+ my $to = $_->{to};
+
+ my $outdir = dirname "$target$from";
+ mkdir $outdir;
+
+ open my $out_fh, '>', "$target$from"
+ or die "Cannot open '$target$from' for writing: $!\n";
+
+ print $out_fh <
+
+
+
+
+
+EOF
+
+ close $out_fh;
+ }
+}
+
sub serve {
my $self = shift;
@@ -266,7 +304,7 @@ Dave Cross
=head1 COPYRIGHT AND LICENCE
-Copyright (c) 2017-2023, Magnum Solutions Ltd. All Rights Reserved.
+Copyright (c) 2017-2024, Magnum Solutions Ltd. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.