Add local domains
This commit is contained in:
parent
450b09554e
commit
b5779936da
15
cap2site.pl
15
cap2site.pl
|
@ -14,6 +14,7 @@ struct('Config', => {
|
||||||
web_schemes => '@',
|
web_schemes => '@',
|
||||||
standalone => '$',
|
standalone => '$',
|
||||||
head => '$',
|
head => '$',
|
||||||
|
local_domains => '@',
|
||||||
});
|
});
|
||||||
|
|
||||||
our $DEFAULT = Config->new(
|
our $DEFAULT = Config->new(
|
||||||
|
@ -29,6 +30,7 @@ our $DEFAULT = Config->new(
|
||||||
},
|
},
|
||||||
web_schemes => ["http", "https", "mailto", "gemini"],
|
web_schemes => ["http", "https", "mailto", "gemini"],
|
||||||
standalone => 0,
|
standalone => 0,
|
||||||
|
local_domains => [],
|
||||||
head => <<~'EOF',
|
head => <<~'EOF',
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<link rel="stylesheet" href="style.css"></link>
|
<link rel="stylesheet" href="style.css"></link>
|
||||||
|
@ -47,6 +49,12 @@ sub isA($$$) {
|
||||||
return grep $1, $self->extensions->{type};
|
return grep $1, $self->extensions->{type};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub isLocal($$) {
|
||||||
|
my ($self,$url) = @_;
|
||||||
|
$url =~ /gemini:\/\/([^\/]+).*/ or return 0;
|
||||||
|
return grep $1, $self->{local_domains};
|
||||||
|
}
|
||||||
|
|
||||||
package State;
|
package State;
|
||||||
|
|
||||||
sub new($$) {
|
sub new($$) {
|
||||||
|
@ -163,6 +171,12 @@ sub parse($$$) {
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($config->isUrl($uri)) {
|
elsif ($config->isUrl($uri)) {
|
||||||
|
if ($config->isLocal($uri)) {
|
||||||
|
# TODO: local http
|
||||||
|
$uri =~ s/gemini:/https:/;
|
||||||
|
$uri =~ s/\.gmi$/\.html/;
|
||||||
|
}
|
||||||
|
|
||||||
print '<div>', "\n";
|
print '<div>', "\n";
|
||||||
print '<span class="link-delim">=></span> ';
|
print '<span class="link-delim">=></span> ';
|
||||||
print '<a href="', escape($uri), '">', escape($content), '</a>', "\n";
|
print '<a href="', escape($uri), '">', escape($content), '</a>', "\n";
|
||||||
|
@ -207,6 +221,7 @@ GetOptions (
|
||||||
'inline-video!' => \$config->inline->{video},
|
'inline-video!' => \$config->inline->{video},
|
||||||
'inline-image!' => \$config->inline->{image},
|
'inline-image!' => \$config->inline->{image},
|
||||||
'standalone!' => \$config->{standalone},
|
'standalone!' => \$config->{standalone},
|
||||||
|
'local-domain=s' => \$config->{local_domains},
|
||||||
) or pod2usage(-exitval => 1, -verbose => 0);
|
) or pod2usage(-exitval => 1, -verbose => 0);
|
||||||
|
|
||||||
pod2usage(-verbose => $help) if $help;
|
pod2usage(-verbose => $help) if $help;
|
||||||
|
|
Loading…
Reference in New Issue