Allow overriding of templates; document in usage()
This commit is contained in:
parent
59edf2cdfb
commit
58797c1b3a
59
fedi2html
59
fedi2html
|
@ -8,7 +8,8 @@
|
|||
# Date: 2024-03
|
||||
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
|
||||
POST_TEMPLATE='
|
||||
if test -z "$POST_TEMPLATE"; then
|
||||
POST_TEMPLATE='
|
||||
<article class="comment">
|
||||
<a class="user" href="$ACCOUNT_URL">
|
||||
<img class="avatar" src="$ACCOUNT_AVATAR">
|
||||
|
@ -29,17 +30,21 @@ POST_TEMPLATE='
|
|||
</div>
|
||||
</article>
|
||||
'
|
||||
fi
|
||||
|
||||
|
||||
ATTACH_TEMPLATE='
|
||||
if test -z "$ATTACH_TEMPLATE"; then
|
||||
ATTACH_TEMPLATE='
|
||||
<a href="$ATTACH_URL">
|
||||
<div class="attachment">
|
||||
<strong>$ATTACH_NAME</strong>
|
||||
$ATTACH_DESC
|
||||
</div>
|
||||
</a>'
|
||||
fi
|
||||
|
||||
ATTACH_IMAGE_TEMPLATE='
|
||||
|
||||
if test -z "$ATTACH_IMAGE_TEMPLATE"; then
|
||||
ATTACH_IMAGE_TEMPLATE='
|
||||
<figure>
|
||||
<a href="$ATTACH_URL">
|
||||
<img class="attachment" src="$ATTACH_URL" alt="$ATTACH_DESC" title="$ATTACH_DESC">
|
||||
|
@ -55,8 +60,12 @@ ATTACH_IMAGE_TEMPLATE='
|
|||
</figcaption>
|
||||
</figure>
|
||||
'
|
||||
fi
|
||||
|
||||
EMOJI_TEMPLATE='<img class="emoji" src="$EMOJI_URL" alt="$EMOJI_SHORTCODE" title="$EMOJI_SHORTCODE">'
|
||||
|
||||
if test -z "$EMOJI_TEMPLATE"; then
|
||||
EMOJI_TEMPLATE='<img class="emoji" src="$EMOJI_URL" alt="$EMOJI_SHORTCODE" title="$EMOJI_SHORTCODE">'
|
||||
fi
|
||||
|
||||
|
||||
# Given a note’s JSON, render it as HTML.
|
||||
|
@ -345,15 +354,8 @@ usage() {
|
|||
echo " $(basename "$0") [-h] [-IRc] [-bBt] USER_URL"
|
||||
echo
|
||||
echo "$(basename "$0") does exactly what it says on the tin: It formats"
|
||||
echo 'a fediverse post (and its replies) into simple-and-embeddable HTML.'
|
||||
echo
|
||||
echo 'It works with posts from any server that supports Mastodon’s API,'
|
||||
echo 'including Pleroma, Akkoma, Glitch, etc.'
|
||||
echo
|
||||
echo 'Notably, it supports post-atachments and custom-emoji. Keep in mind'
|
||||
echo 'that images are all fetched from remote sources. It is recommended,'
|
||||
echo 'if privacy or total archival, is a concern, to use wget(1)’s --mirror'
|
||||
echo '(or something like it) to fetch even these foreign files.'
|
||||
echo 'a fediverse post (and its replies) into text. By default, into'
|
||||
echo 'simple-and-embeddable HTML.'
|
||||
echo
|
||||
echo ' -c only print the responses (children) of a post'
|
||||
echo ' -h print this message and exit'
|
||||
|
@ -364,6 +366,35 @@ usage() {
|
|||
echo ' -b exclude reblogs/repeats from user feed'
|
||||
echo ' -B exclude top-level replies from user feed'
|
||||
echo ' -t filter posts from user feed by tag'
|
||||
echo
|
||||
echo 'It works with posts from any server that supports Mastodon’s API,'
|
||||
echo 'including Pleroma, Akkoma, Glitch, etc.'
|
||||
echo
|
||||
echo 'Notably, it supports post-atachments and custom-emoji. Keep in mind'
|
||||
echo 'that images are all fetched from remote sources. It is recommended,'
|
||||
echo 'if privacy or total archival, is a concern, to use wget(1)’s --mirror'
|
||||
echo '(or something like it) to fetch even these foreign files.'
|
||||
echo
|
||||
echo '“Template” environment variables are used to generate the text'
|
||||
echo 'output. A template is a string that contains shell-style variable'
|
||||
echo "names (\$NAME) that $(basename "$0") will replace."
|
||||
echo 'They are $POST_TEMPLATE, $ATTACH_TEMPLATE, and $EMOJI_TEMPLATE.'
|
||||
echo
|
||||
echo 'The variables that can be used in $POST_TEMPLATE are:'
|
||||
echo ' $ACCOUNT_ID, $ACCOUNT_URL, $ACCOUNT_NAME, $ACCOUNT_AVATAR,'
|
||||
echo ' $POST_URL, $POST_DATE, $POST_CONTENT, $POST_ATTACHMENTS,'
|
||||
echo ' and $POST_RESPONSES.'
|
||||
echo
|
||||
echo 'The variables that can be used in $ATTACH_TEMPLATE are:'
|
||||
echo ' $ATTACH_URL, $ATTACH_NAME, $ATTACH_TYPE, $ATTACH_DESC,'
|
||||
echo ' and $ATTACH_PREVIEW.'
|
||||
echo
|
||||
echo 'The variables that can be used in $EMOJI_TEMPLATE are:'
|
||||
echo ' $EMOJI_SHORTCODE and $EMOJI_URL.'
|
||||
echo
|
||||
echo 'See the first few lines of fedi2html for the default (example)'
|
||||
echo 'template values; see the README for a more detailed description'
|
||||
echo 'of these variables’ meanings.'
|
||||
}
|
||||
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue