};
my $title = html_esc($txt =~ /\A([^\n]+)/);
$title =~ s/^\s+|\s+$//g;
-if ($opt_lang eq 'fa') {
- $title .= ' — Ø¨ÙØ¯Ø¹ÙÛ' if $title !~ /Ø¨ÙØ¯Ø¹ÙÛ/;
-} else {
- $title .= ' — bandali' if $title !~ /bandali/;
-}
+$title .= " — $author" if $title !~ /$author/;
my ($upd, $pub, $url) = $txt =~ /(.*)\r?\n(.*)\r?\n(.*)\r?\n?\z/;
($upd) = $upd =~ /(?:updated|ÙÛØ±Ø§ÛØ´): (.*)/ if $upd;
($pub) = $pub =~ /(?:published|Ø§ÙØªØ´Ø§Ø±): (.*)/ if $pub;
+$upd = $pub if (!$upd);
($url) = $url =~ /(?:plain text|Ù
ت٠سادÙ): (.*)/ if $url;
$url = 'https://bndl.org/bandali-cv.txt'
if (!$url and $title =~ /curriculum vitae/);
@@ -116,32 +208,86 @@ $url = html_esc($url) if $url;
$txt = linkify(html_esc($txt));
-print("",
- qq(",
- qq(
+
+my $upd_iso8601 = `date -Iseconds -ud '$upd' | tr -d \\\\n` if $upd;
+my $pub_iso8601 = `date -Iseconds -ud '$pub' | tr -d \\\\n` if $pub;
+my $pub_rfc5322 = `date -uRd '$pub' | tr -d \\\\n` if $pub;
+my $url_html = $url =~ s/(?:[.]$lang)?[.]txt$/.html/r if $url;
+$url_html =~ s|/bandali-(.*)|/$1| if $url_html;
+my $slug = $url_html =~ s|.*/(.*)[.]html$|$1|r if $url_html;
+my $note_id = "$feed_id:$slug" if $url_html;
+
+# note header
+if ($format eq 'html') {
+ $out .=
+ ''
+ . qq(')
+ . qq(
\n),
- "$title\n",
- qq(\n),
- $url ? qq(\n) : '',
- ($opt_index and $opt_lang eq 'en')
- ? qq(\n)
+ . "$title\n"
+ . qq(\n)
+ . ($url
+ ? qq(\n)
+ : '')
+ . (($index and $lang eq 'en')
+ ? qq(\n)
- : ($opt_index and $opt_lang eq 'fa')
- ? qq(\n)
- : '',
- qq(\n",
- "$txt
\n");
+ : '')
+ . "\n"
+ . '';
+} elsif ($format eq 'atom' or $format eq 'rss') {
+ my $atom_updated =
+ ($format eq 'atom') ? 'updated'
+ : ($format eq 'rss') ? 'atom:updated'
+ : '';
+ my $updated =
+ "<$atom_updated>$upd_iso8601$atom_updated>\n" if $upd;
+ $out .= ($format eq 'atom') ? qq(
+
+$author
+$note_id
+$pub_iso8601\n)
+. ($updated ? $updated : '') .
+qq(
+
+$title
+)
+ : ($format eq 'rss') ? qq(
+-
+$title
+$url_html
+$note_id
+$pub_rfc5322\n)
+. (($updated and $pub ne $upd) ? $updated : '') .
+qq()
+ : '';
+}
+# note body
+$out .= $txt;
+# note footer
+if ($format eq 'html') {
+ $out .= '
';
+} elsif ($format eq 'atom') {
+ $out .= "]]>";
+} elsif ($format eq 'rss') {
+ $out .= "]]>";
+}
+
+ PRINT:
+print("$out\n");
STDOUT->flush;