M README.md => README.md +7 -2
@@ 31,12 31,17 @@ $ prove -rv t
halp is licensed under the GNU Affero General Public License 3.0.
-
## credits
* [Brad Taunt](https://bt.ht/) for an excellent [suggestion on how to approach site navigation without hamburger menus](https://btxx.org/posts/hamburgers).
* [Mateus V. Farias](https://github.com/fariasmateuss) for [favicon-generator](https://github.com/fariasmateuss/favicon-generator).
-* The Avatar image in the test data is ["Ang and Momo"](https://www.deviantart.com/art-of-li/art/Ang-and-Momo-1017030845) by [Art of Li](https://www.deviantart.com/art-of-li/), licensed under [CC BY-NC-ND 3.0](https://creativecommons.org/licenses/by-nc-nd/3.0/).
+
+### test images
+
+* ["Ang and Momo"](https://www.deviantart.com/art-of-li/art/Ang-and-Momo-1017030845) by [Art of Li](https://www.deviantart.com/art-of-li/), licensed under [CC BY-NC-ND 3.0](https://creativecommons.org/licenses/by-nc-nd/3.0/).
+* ["Flatlay Crafts"](https://stocksnap.io/photo/flatlay-crafts-OLQPVNTGXR) by [Kelly Ishmael](https://stocksnap.io/author/kellyishmael), licensed under [CC0](https://creativecommons.org/public-domain/cc0/).
+* ["IBM PC-5150"](https://commons.wikimedia.org/wiki/File:IBM_PC-5150.JPG) by [Jordiferrer](https://commons.wikimedia.org/wiki/User:Jordiferrer), licensed under [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/deed.en).
+* ["IMG_9976"](https://www.flickr.com/photos/54568729@N00/9636183501) by [Jason Scott](https://www.flickr.com/photos/textfiles/), licensed under [CC BY 2.0](https://creativecommons.org/licenses/by/2.0/).
## FAQ
M dev-config/halp-config.pl => dev-config/halp-config.pl +2 -2
@@ 7,13 7,13 @@
domain => 'example.com',
gemini => {
- host => '0.0.0.0',
+ host => 'http://0.0.0.0:8080',
input_path => './t/fixtures/gemini',
output_path => './tmp/gemini'
},
web => {
- host => '0.0.0.0',
+ host => 'http://0.0.0.0:8080',
input_path => './t/fixtures/www',
output_path => './tmp/www'
}
M html/templates/page.html.tpl => html/templates/page.html.tpl +6 -0
@@ 21,6 21,12 @@
<meta property="og:title" content="{ $title }">
<meta property="og:url" content="{ $url }">
<meta property="og:description" content="{ $description }">
+
+ {
+ if ($image_url ne "") {
+ $OUT .= "<meta property=\"og:image\" content=\"$image_url\">\n";
+ }
+ }
<script>
function showAdBlockerRecommendation() \{
document.getElementById("adblocker-recommendation").style.display = "block"
M lib/Halp/Generator.pm => lib/Halp/Generator.pm +35 -4
@@ 56,10 56,13 @@ sub generate_menu {
sub wrap_page_template {
my ($self, $title, $content, $show_atom_link, $source_filename, $url, $description) = @_;
+ my $source_dirname = dirname($source_filename);
+ my $source_basename = basename($source_filename);
my $menu = $self->generate_menu($self->{input_path});
+ my $url_dirname = dirname(File::Spec->abs2rel($source_filename, $self->{input_path}));
my $template_pathname = File::Spec->catfile($self->{template_path}, "page.$self->{template_type}.tpl");
my $template = Text::Template->new(SOURCE => $template_pathname);
- my $atom_url = File::Spec->catfile(dirname(File::Spec->abs2rel($source_filename, $self->{input_path})), 'feed.xml');
+ my $atom_url = File::Spec->catfile($url_dirname, 'feed.xml');
my $footer = '';
my $footer_pathname = '';
@@ 72,6 75,26 @@ sub wrap_page_template {
$footer = read_file($footer_pathname);
}
+ my $image_url = "";
+
+ if (-d $source_filename) {
+ if (-f File::Spec->catfile($source_filename, ".opengraph.jpg")) {
+ $image_url = "$url.opengraph.jpg";
+ }
+ } else {
+ if (-f File::Spec->catfile($source_dirname, ".$source_basename.opengraph.jpg")) {
+ $image_url = "$self->{host}/$url_dirname/.$source_basename.opengraph.jpg";
+ } elsif (-f File::Spec->catfile($source_dirname, ".opengraph.jpg")) {
+ $image_url = "$self->{host}/$url_dirname/.opengraph.jpg";
+ }
+ }
+
+ if ($image_url eq "") {
+ if (-f File::Spec->catfile($self->{input_path}, '.static/images/opengraph.jpg')) {
+ $image_url = "$self->{host}/.static/images/opengraph.jpg";
+ }
+ }
+
my $atom_feed = '';
if ($show_atom_link) {
my $template_type = $self->{template_type};
@@ 92,7 115,15 @@ sub wrap_page_template {
}
}
- my $result = $template->fill_in(HASH => {'title' => $title, 'url' => $url, 'content' => $content, 'description' => $description, 'menu' => $menu, 'atom_feed' => $atom_feed, 'stylesheets' => @stylesheets, 'footer' => $footer});
+ my $result = $template->fill_in(HASH => {'title' => $title,
+ 'url' => $url,
+ 'content' => $content,
+ 'description' => $description,
+ 'menu' => $menu,
+ 'atom_feed' => $atom_feed,
+ 'stylesheets' => @stylesheets,
+ 'footer' => $footer,
+ 'image_url' => $image_url});
return $result;
}
@@ 175,8 206,8 @@ sub generate_directory {
if ($relative_file =~ m/^\.+$/) {
# Ignore . and ..
- } elsif (-f $filename && $relative_file =~ m/^\./) {
- # Ignore dotfiles
+ } elsif (-f $filename && $relative_file =~ m/^\./ && !($relative_file =~ m/\.opengraph\.jpg$/)) {
+ # Ignore dotfiles except *.opengraph.jpg
} elsif (-d $filename) {
$self->generate_directory($filename);
} elsif (-f $filename) {
M t/expected/gemini/feed.xml => t/expected/gemini/feed.xml +2 -2
@@ 1,3 1,3 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>fixtures</title><link href="0.0.0.0/"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator></feed>>
\ No newline at end of file
+<feed xmlns="http://www.w3.org/2005/Atom"><title>fixtures</title><link href="http://0.0.0.0:8080/"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator></feed><
\ No newline at end of file
A t/expected/www/.static/images/opengraph.jpg => t/expected/www/.static/images/opengraph.jpg +0 -0
A t/expected/www/blog/.2023-05-07_first-article.html.opengraph.jpg => t/expected/www/blog/.2023-05-07_first-article.html.opengraph.jpg +0 -0
M t/expected/www/blog/2023-05-07_first-article.html => t/expected/www/blog/2023-05-07_first-article.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="My First Ever Article">
- <meta property="og:url" content="0.0.0.0/blog/2023-05-07_first-article.html">
+ <meta property="og:url" content="http://0.0.0.0:8080/blog/2023-05-07_first-article.html">
<meta property="og:description" content="This is a blog post, which should be templated.">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/blog/.2023-05-07_first-article.html.opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
M t/expected/www/blog/2023-05-07_second-article.html => t/expected/www/blog/2023-05-07_second-article.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="2023-05-07_second-article.html">
- <meta property="og:url" content="0.0.0.0/blog/2023-05-07_second-article.html">
+ <meta property="og:url" content="http://0.0.0.0:8080/blog/2023-05-07_second-article.html">
<meta property="og:description" content="html">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/.static/images/opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
M t/expected/www/blog/feed.xml => t/expected/www/blog/feed.xml +2 -2
@@ 1,6 1,6 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>My Site</title><link href="0.0.0.0/blog"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/blog</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>2023-05-07_second-article.html</title><link href="0.0.0.0/blog/2023-05-07_second-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/blog/2023-05-07_second-article.html</id><summary></summary></entry><entry><title>My First Ever Article</title><link href="0.0.0.0/blog/2023-05-07_first-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/blog/2023-05-07_first-article.html</id><summary type="html"><p>
+<feed xmlns="http://www.w3.org/2005/Atom"><title>My Site</title><link href="http://0.0.0.0:8080/blog"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/blog</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>2023-05-07_second-article.html</title><link href="http://0.0.0.0:8080/blog/2023-05-07_second-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/blog/2023-05-07_second-article.html</id><summary></summary></entry><entry><title>My First Ever Article</title><link href="http://0.0.0.0:8080/blog/2023-05-07_first-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/blog/2023-05-07_first-article.html</id><summary type="html"><p>
This is a blog post, which should be templated.
</p>
</summary></entry></feed>=
\ No newline at end of file
M t/expected/www/blog/index.html => t/expected/www/blog/index.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="My Blog">
- <meta property="og:url" content="0.0.0.0/blog/">
+ <meta property="og:url" content="http://0.0.0.0:8080/blog/">
<meta property="og:description" content="My blog posts.">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/.static/images/opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
M t/expected/www/feed.xml => t/expected/www/feed.xml +3 -3
@@ 1,9 1,9 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>fixtures</title><link href="0.0.0.0/"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>The Halp Project</title><link href="0.0.0.0/projects/halp/index.html"/><updated>2023-06-03T10:50:59+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/projects/halp/index.html</id><summary type="html"><p>
+<feed xmlns="http://www.w3.org/2005/Atom"><title>fixtures</title><link href="http://0.0.0.0:8080/"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>The Halp Project</title><link href="http://0.0.0.0:8080/projects/halp/index.html"/><updated>2023-06-03T10:50:59+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/projects/halp/index.html</id><summary type="html"><p>
This is the index file for the halp project.
</p>
-</summary></entry><entry><title>2023-05-07_second-article.html</title><link href="0.0.0.0/blog/2023-05-07_second-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/blog/2023-05-07_second-article.html</id><summary></summary></entry><entry><title>My First Ever Article</title><link href="0.0.0.0/blog/2023-05-07_first-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/blog/2023-05-07_first-article.html</id><summary type="html"><p>
+</summary></entry><entry><title>2023-05-07_second-article.html</title><link href="http://0.0.0.0:8080/blog/2023-05-07_second-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/blog/2023-05-07_second-article.html</id><summary></summary></entry><entry><title>My First Ever Article</title><link href="http://0.0.0.0:8080/blog/2023-05-07_first-article.html"/><updated>2023-05-07T15:39:15+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/blog/2023-05-07_first-article.html</id><summary type="html"><p>
This is a blog post, which should be templated.
</p>
</summary></entry></feed>=
\ No newline at end of file
M t/expected/www/index.html => t/expected/www/index.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="My Site">
- <meta property="og:url" content="0.0.0.0/">
+ <meta property="og:url" content="http://0.0.0.0:8080/">
<meta property="og:description" content="This is my site, served by Halp.">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/.static/images/opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
M t/expected/www/miscellaneous/feed.xml => t/expected/www/miscellaneous/feed.xml +2 -2
@@ 1,3 1,3 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>My Site</title><link href="0.0.0.0/miscellaneous"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/miscellaneous</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator></feed>>
\ No newline at end of file
+<feed xmlns="http://www.w3.org/2005/Atom"><title>My Site</title><link href="http://0.0.0.0:8080/miscellaneous"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/miscellaneous</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator></feed><
\ No newline at end of file
M t/expected/www/miscellaneous/index.html => t/expected/www/miscellaneous/index.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="miscellaneous">
- <meta property="og:url" content="0.0.0.0/miscellaneous/">
+ <meta property="og:url" content="http://0.0.0.0:8080/miscellaneous/">
<meta property="og:description" content="">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/.static/images/opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
A t/expected/www/projects/.opengraph.jpg => t/expected/www/projects/.opengraph.jpg +0 -0
M t/expected/www/projects/feed.xml => t/expected/www/projects/feed.xml +2 -2
@@ 1,6 1,6 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>My Site</title><link href="0.0.0.0/projects"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/projects</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>The Halp Project</title><link href="0.0.0.0/projects/halp/index.html"/><updated>2023-06-03T10:50:59+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/projects/halp/index.html</id><summary type="html"><p>
+<feed xmlns="http://www.w3.org/2005/Atom"><title>My Site</title><link href="http://0.0.0.0:8080/projects"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/projects</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>The Halp Project</title><link href="http://0.0.0.0:8080/projects/halp/index.html"/><updated>2023-06-03T10:50:59+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/projects/halp/index.html</id><summary type="html"><p>
This is the index file for the halp project.
</p>
</summary></entry></feed>=
\ No newline at end of file
M t/expected/www/projects/halp/feed.xml => t/expected/www/projects/halp/feed.xml +2 -2
@@ 1,6 1,6 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>Projects</title><link href="0.0.0.0/projects/halp"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/projects/halp</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>The Halp Project</title><link href="0.0.0.0/projects/halp/index.html"/><updated>2023-06-03T10:50:59+10:00</updated><author><name></name><email></email></author><id>0.0.0.0/projects/halp/index.html</id><summary type="html"><p>
+<feed xmlns="http://www.w3.org/2005/Atom"><title>Projects</title><link href="http://0.0.0.0:8080/projects/halp"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/projects/halp</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator><entry><title>The Halp Project</title><link href="http://0.0.0.0:8080/projects/halp/index.html"/><updated>2023-06-03T10:50:59+10:00</updated><author><name></name><email></email></author><id>http://0.0.0.0:8080/projects/halp/index.html</id><summary type="html"><p>
This is the index file for the halp project.
</p>
</summary></entry></feed>=
\ No newline at end of file
M t/expected/www/projects/halp/index.html => t/expected/www/projects/halp/index.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="The Halp Project">
- <meta property="og:url" content="0.0.0.0/projects/halp/index.html">
+ <meta property="og:url" content="http://0.0.0.0:8080/projects/halp/index.html">
<meta property="og:description" content="This is the index file for the halp project.">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/.static/images/opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
M t/expected/www/projects/index.html => t/expected/www/projects/index.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="Projects">
- <meta property="og:url" content="0.0.0.0/projects/">
+ <meta property="og:url" content="http://0.0.0.0:8080/projects/">
<meta property="og:description" content="My projects.">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/projects/.opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
M t/expected/www/projects/unicomp-overhaul/feed.xml => t/expected/www/projects/unicomp-overhaul/feed.xml +2 -2
@@ 1,3 1,3 @@
<?xml version="1.0" encoding="us-ascii"?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title>Projects</title><link href="0.0.0.0/projects/unicomp-overhaul"/><updated>2023-04-16T00:48:08+10:00
-</updated><id>0.0.0.0/projects/unicomp-overhaul</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator></feed>>
\ No newline at end of file
+<feed xmlns="http://www.w3.org/2005/Atom"><title>Projects</title><link href="http://0.0.0.0:8080/projects/unicomp-overhaul"/><updated>2023-04-16T00:48:08+10:00
+</updated><id>http://0.0.0.0:8080/projects/unicomp-overhaul</id><generator uri="https://metacpan.org/pod/XML::Atom::SimpleFeed" version="0.905">XML::Atom::SimpleFeed</generator></feed><
\ No newline at end of file
M t/expected/www/projects/unicomp-overhaul/index.html => t/expected/www/projects/unicomp-overhaul/index.html +4 -1
@@ 16,8 16,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta property="og:title" content="unicomp-overhaul">
- <meta property="og:url" content="0.0.0.0/projects/unicomp-overhaul/">
+ <meta property="og:url" content="http://0.0.0.0:8080/projects/unicomp-overhaul/">
<meta property="og:description" content="">
+
+ <meta property="og:image" content="http://0.0.0.0:8080/.static/images/opengraph.jpg">
+
<script>
function showAdBlockerRecommendation() {
document.getElementById("adblocker-recommendation").style.display = "block"
A t/fixtures/www/.static/images/opengraph.jpg => t/fixtures/www/.static/images/opengraph.jpg +0 -0
A t/fixtures/www/blog/.2023-05-07_first-article.html.opengraph.jpg => t/fixtures/www/blog/.2023-05-07_first-article.html.opengraph.jpg +0 -0
A t/fixtures/www/projects/.opengraph.jpg => t/fixtures/www/projects/.opengraph.jpg +0 -0