# without any warranty.
-gen = perl txt2html < $< > $@
-gen_fa = perl txt2html --lang='fa' < $< > $@
+gen-html = perl txt2html $(1) < $< > $@
port := $(if $(port),$(port),8000)
TXT := $(filter-out bandali-pubkey.txt bandali.txt,$(wildcard *.txt))
all: $(OUT) $(OUT_FA) index.html fa/index.html
-%.html: bandali-%.txt ; $(gen)
-%.html: %.txt ; $(gen)
-index.html: bandali.txt ; $(gen)
+%.html: bandali-%.txt; $(gen-html)
+%.html: %.txt; $(gen-html)
+index.html: bandali.txt; $(call gen-html,--index)
-fa/%.html: fa/bandali-%.fa.txt ; $(gen_fa)
-fa/%.html: fa/%.fa.txt ; $(gen_fa)
-fa/index.html: fa/bandali.fa.txt ; $(gen_fa)
+fa/%.html: fa/bandali-%.fa.txt; $(call gen-html,--lang='fa')
+fa/%.html: fa/%.fa.txt; $(call gen-html,--lang='fa')
+fa/index.html: fa/bandali.fa.txt; $(call gen-html,--lang='fa' --index)
clean:
use Getopt::Long;
my $opt_lang = 'en';
-GetOptions ('lang=s' => \$opt_lang)
+my $opt_index;
+GetOptions ('lang=s' => \$opt_lang,
+ 'index' => \$opt_index)
or die("bad command line arguments\n");
my $link_re =
} else {
$title .= ' — bandali' if $title !~ /bandali/;
}
+my ($url) = $txt =~ /(?:plain text|متن ساده): (.*)\r?\n?\z/;
+$url = 'https://bndl.org/bandali-cv.txt'
+ if (!$url and $title =~ /curriculum vitae/);
+$url = html_esc($url) if $url;
$txt = linkify(html_esc($txt));
-print('<!doctype html>',
+print("<!doctype html>",
qq(<html lang="$opt_lang"),
- $opt_lang eq 'fa' ? ' dir="rtl"' : '', '>',
- '<head><meta
-http-equiv="Content-Type"
-content="text/html; charset=utf-8"
-/>',
- "<title>$title</title>",
+ $opt_lang eq 'fa' ? ' dir="rtl"' : '',
+ ">",
+ qq(<head>
+<meta http-equiv="Content-Type"
+content="text/html; charset=utf-8" />\n),
+ "<title>$title</title>\n",
+ $url ? qq(<link rel="alternate" href="$url"
+title="plain text" type="text/plain" />\n) : '',
+ ($opt_index and $opt_lang eq 'en')
+ ? qq(<link rel="alternate" href="https://bndl.org/fa/"
+hreflang="fa" title="persian" />\n)
+ : ($opt_index and $opt_lang eq 'fa')
+ ? qq(<link rel="alternate" href="https://bndl.org/"
+hreflang="en" title="english" />\n)
+ : '',
$opt_lang eq 'fa'
- ? "\n<style>\@font-face{font-family:sahel;font-weight:normal;
+ ? qq(<style>\@font-face{font-family:sahel;font-weight:normal;
src:local('Sahel WOL'),local('Sahel'),
-url('sahel.woff2')format('woff2');}pre{font-family:sahel}</style>\n"
+url('sahel.woff2')format('woff2');}pre{font-family:sahel}</style>\n)
: '',
- '</head><body><pre>', $txt, '</pre></body></html>');
+ "</head><body><pre>$txt</pre></body></html>\n");
STDOUT->flush;