File tree Expand file tree Collapse file tree 6 files changed +31
-1
lines changed Expand file tree Collapse file tree 6 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ t/05-vars.t
15
15
t/data1/in/index.html.md
16
16
t/data1/in/static.txt
17
17
t/data1/layouts/page
18
+ t/data1/site.yml
18
19
t/data2/in/index.html.md
19
20
t/data2/in/static.txt
20
21
t/data2/in/test.html.md
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ WriteMakefile(
21
21
' Text::FrontMatter::YAML' => 0,
22
22
' Path::Tiny' => 0,
23
23
' YAML::XS' => 0,
24
+ ' Sys::Hostname' => 0,
25
+ URI => 0,
24
26
},
25
27
26
28
META_MERGE => {
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ use Getopt::Long;
34
34
use Carp;
35
35
use Clone ' clone' ;
36
36
use YAML::XS ' LoadFile' ;
37
+ use Sys::Hostname;
38
+ use URI;
37
39
38
40
use App::Aphra::File;
39
41
@@ -163,6 +165,27 @@ sub _build_template {
163
165
);
164
166
}
165
167
168
+ has uri => (
169
+ isa => ' URI' ,
170
+ is => ' ro' ,
171
+ lazy_build => 1,
172
+ );
173
+
174
+ sub _build_uri {
175
+ my $self = shift ;
176
+
177
+ return URI-> new($self -> site_vars-> {uri }) if $self -> site_vars-> {uri };
178
+
179
+ my $host = $self -> site_vars-> {host } || hostname;
180
+ my $protocol = $self -> site_vars-> {protocol } || ' https' ;
181
+
182
+ my $uri = " $protocol ://$host " ;
183
+ $uri .= ' :' . $self -> site_vars-> {port } if $self -> site_vars-> {port };
184
+ $uri .= ' /' ;
185
+
186
+ return URI-> new($uri );
187
+ }
188
+
166
189
sub run {
167
190
my $self = shift ;
168
191
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ sub process {
113
113
114
114
$self -> app-> template-> process($template , {
115
115
page => ($front_matter -> frontmatter_hashref // {}),
116
+ file => $self ,
116
117
}, $out )
117
118
or croak $self -> app-> template-> error;
118
119
} else {
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ for ($outfile, $outfile2) {
22
22
unlink $_ if -r $_ ;
23
23
}
24
24
25
- App::Aphra-> new-> run;
25
+ my $app = App::Aphra-> new;
26
+ is($app -> uri, ' https://example.com/' , ' Correct URI' );
27
+ $app -> run;
26
28
27
29
ok(-e $outfile , ' Got an output file' );
28
30
ok(-f $outfile , " ... and it's a real file" );
Original file line number Diff line number Diff line change
1
+ uri : https://example.com/
You can’t perform that action at this time.
0 commit comments