App-sitelenmute
view release on metacpan or search on metacpan
script/sitelen-mute view on Meta::CPAN
dircopy $viewdir, $vdir;
}
}
# craft the index.html contents from the actual data.json file
my $html = qq{\n <div id="photos" } .
qq{itemscope itemtype="http://schema.org/ImageGallery">\n};
$html .= qq{\t<h1 itemprop="name">$galleryTitle</h1>\n}
if $galleryTitle;
$html .= qq{\t<p itemprop="description">$galleryDescription</p>\n}
if $galleryDescription;
$html .= qq{\t<div id="wrapper">};
# enumerate the images for noscript
my $id = -1;
$adata = read_json($json_file);
for (@{$adata->{data}}) {
my $c = (splitpath($_->{img}[0]))[2];
$c = $_->{caption}[0] if exists $_->{caption};
my $f = $_->{img}[0];
my $t = $_->{thumb}[0];
$id++;
$html .= qq{\n\t <a id="$id" href="$f" title="$c">}
. qq{<img src="$t" alt="$c"/></a>};
}
$html .= qq{\n\t</div>\n};
$html .= qq{ </div>\n};
$html .= qq{ };
# read the template for the index.html file
my $indexhtml = read_text(catfile($absOut, 'view', 'index.html'));
$indexhtml =~ s@<noscript>.*?</noscript>@<noscript>$html</noscript>@s;
# include the optional social media decoration
if ($galleryTitle && $galleryDescription && $galleryUrl) {
# default to the first image
my $galleryImage = $adata->{data}->[0]->{img}->[0];
$html = qq{
<!-- for Facebook -->
<meta property="og:title" content="$galleryTitle" />
<meta property="og:description" content="$galleryDescription" />
<meta property="og:type" content="article" />
<meta property="og:image" content="${galleryUrl}$galleryImage" />
<meta property="og:url" content="$galleryUrl" />
<!-- for Twitter -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="$galleryTitle" />
<meta name="twitter:description" content="$galleryDescription" />
<meta name="twitter:image" content="${galleryUrl}imgs/$galleryImage" />
};
$indexhtml =~ s@ <!-- for Facebook -->\n( .*\n)*@@;
$indexhtml =~ s@ </head>@$html </head>@;
}
# unlink any existing index and write out the new index.html file
my $index = catfile($absOut, 'index.html');
unlink($index);
my $fd;
write_text($index, $indexhtml);
say "Wrote new $index";
print sprintf "%s version %s %s gallery in %s\n",
$me, $VERSION, $updating ? 'updated' : 'created', $absOut;
exit 0;
( run in 0.798 second using v1.01-cache-2.11-cpan-5623c5533a1 )