FIX generation from markdown (merge)
This commit is contained in:
commit
3ed87d6bc6
|
@ -1,11 +1,14 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Create the css file from scratch
|
# Create the css file from scratch
|
||||||
|
declare css_include
|
||||||
|
|
||||||
create_css() {
|
create_css() {
|
||||||
# To avoid overwriting manual changes. However it is recommended that
|
# To avoid overwriting manual changes. However it is recommended that
|
||||||
# this function is modified if the user changes the blog.css file
|
# this function is modified if the user changes the blog.css file
|
||||||
(( ${#css_include[@]} > 0 )) && return || css_include=('main.css' 'blog.css')
|
|
||||||
if [[ ! -f blog.css ]]; then
|
((${#css_include} > 0)) && return || css_include=('main.css' 'blog.css')
|
||||||
|
if [[ ! -f blog.css ]]; then
|
||||||
# blog.css directives will be loaded after main.css and thus will prevail
|
# blog.css directives will be loaded after main.css and thus will prevail
|
||||||
echo '#title{font-size: x-large;}
|
echo '#title{font-size: x-large;}
|
||||||
a.ablack{color:black !important;}
|
a.ablack{color:black !important;}
|
||||||
|
@ -19,14 +22,14 @@ create_css() {
|
||||||
h3{margin-top:42px;margin-bottom:8px;}
|
h3{margin-top:42px;margin-bottom:8px;}
|
||||||
h4{margin-left:24px;margin-right:24px;}
|
h4{margin-left:24px;margin-right:24px;}
|
||||||
img{max-width:100%;}
|
img{max-width:100%;}
|
||||||
#twitter{line-height:20px;vertical-align:top;text-align:right;font-style:italic;color:#333;margin-top:24px;font-size:14px;}' > blog.css
|
#twitter{line-height:20px;vertical-align:top;text-align:right;font-style:italic;color:#333;margin-top:24px;font-size:14px;}' >blog.css
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If there is a style.css from the parent page (i.e. some landing page)
|
# If there is a style.css from the parent page (i.e. some landing page)
|
||||||
# then use it. This directive is here for compatibility with my own
|
# then use it. This directive is here for compatibility with my own
|
||||||
# home page. Feel free to edit it out, though it doesn't hurt
|
# home page. Feel free to edit it out, though it doesn't hurt
|
||||||
if [[ -f ../style.css ]] && [[ ! -f main.css ]]; then
|
if [[ -f ../style.css ]] && [[ ! -f main.css ]]; then
|
||||||
ln -s "../style.css" "main.css"
|
ln -s "../style.css" "main.css"
|
||||||
elif [[ ! -f main.css ]]; then
|
elif [[ ! -f main.css ]]; then
|
||||||
echo 'body{font-family:Georgia,"Times New Roman",Times,serif;margin:0;padding:0;background-color:#F3F3F3;}
|
echo 'body{font-family:Georgia,"Times New Roman",Times,serif;margin:0;padding:0;background-color:#F3F3F3;}
|
||||||
#divbodyholder{padding:5px;background-color:#DDD;width:100%;max-width:874px;margin:24px auto;}
|
#divbodyholder{padding:5px;background-color:#DDD;width:100%;max-width:874px;margin:24px auto;}
|
||||||
|
@ -43,6 +46,6 @@ create_css() {
|
||||||
a:visited{text-decoration:none;color:#336699 !important;}
|
a:visited{text-decoration:none;color:#336699 !important;}
|
||||||
blockquote{background-color:#f9f9f9;border-left:solid 4px #e9e9e9;margin-left:12px;padding:12px 12px 12px 24px;}
|
blockquote{background-color:#f9f9f9;border-left:solid 4px #e9e9e9;margin-left:12px;padding:12px 12px 12px 24px;}
|
||||||
blockquote img{margin:12px 0px;}
|
blockquote img{margin:12px 0px;}
|
||||||
blockquote iframe{margin:12px 0px;}' > main.css
|
blockquote iframe{margin:12px 0px;}' >main.css
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,16 @@ do_main() {
|
||||||
# Load default configuration, then override settings with the config file
|
# Load default configuration, then override settings with the config file
|
||||||
global_variables
|
global_variables
|
||||||
# shellcheck disable=SC1090 # variable config file
|
# shellcheck disable=SC1090 # variable config file
|
||||||
[[ -f "$global_config" ]] && source "$global_config" &> /dev/null
|
[[ -f "$global_config" ]] && source "$global_config" &>/dev/null
|
||||||
global_variables_check
|
global_variables_check
|
||||||
|
|
||||||
# Check for $EDITOR
|
# Check for $EDITOR
|
||||||
[[ -z $EDITOR ]] &&
|
[[ -z $EDITOR ]] &&
|
||||||
echo "Please set your \$EDITOR environment variable. For example, to use nano, add the line 'export EDITOR=nano' to your \$HOME/.bashrc file" && exit
|
EDITOR=vim
|
||||||
|
|
||||||
# Check for validity of argument
|
# Check for validity of argument
|
||||||
[[ $1 != "reset" && $1 != "post" && $1 != "rebuild" && $1 != "list" && $1 != "edit" && $1 != "delete" && $1 != "tags" ]] &&
|
[[ $1 != "reset" && $1 != "post" && $1 != "rebuild" && $1 != "list" && $1 != "edit" && $1 != "delete" && $1 != "tags" ]] &&
|
||||||
usage && return
|
usage && return
|
||||||
|
|
||||||
[[ $1 == list ]] &&
|
[[ $1 == list ]] &&
|
||||||
list_posts && return
|
list_posts && return
|
||||||
|
@ -43,10 +43,10 @@ do_main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test for existing html files
|
# Test for existing html files
|
||||||
if ls ./*.md &> /dev/null; then
|
if ls ./*.md &>/dev/null; then
|
||||||
# We're going to back up just in case
|
# We're going to back up just in case
|
||||||
tar -c -z -f ".backup.tar.gz" -- *.html &&
|
tar -c -z -f ".backup.tar.gz" -- *.html &&
|
||||||
chmod 600 ".backup.tar.gz"
|
chmod 600 ".backup.tar.gz"
|
||||||
elif [[ $1 == rebuild ]]; then
|
elif [[ $1 == rebuild ]]; then
|
||||||
echo "Can't find any html files, nothing to rebuild"
|
echo "Can't find any html files, nothing to rebuild"
|
||||||
return
|
return
|
||||||
|
@ -54,7 +54,7 @@ do_main() {
|
||||||
|
|
||||||
# Keep first backup of this day containing yesterday's version of the blog
|
# Keep first backup of this day containing yesterday's version of the blog
|
||||||
[[ ! -f .yesterday.tar.gz || $(date -r .yesterday.tar.gz +'%d') != "$(date +'%d')" ]] &&
|
[[ ! -f .yesterday.tar.gz || $(date -r .yesterday.tar.gz +'%d') != "$(date +'%d')" ]] &&
|
||||||
cp .backup.tar.gz .yesterday.tar.gz &> /dev/null
|
cp .backup.tar.gz .yesterday.tar.gz &>/dev/null
|
||||||
|
|
||||||
[[ $1 == reset ]] &&
|
[[ $1 == reset ]] &&
|
||||||
reset && return
|
reset && return
|
||||||
|
@ -63,7 +63,7 @@ do_main() {
|
||||||
create_includes
|
create_includes
|
||||||
[[ $1 == post ]] && write_entry "$@"
|
[[ $1 == post ]] && write_entry "$@"
|
||||||
[[ $1 == rebuild ]] && rebuild_all_entries && rebuild_tags
|
[[ $1 == rebuild ]] && rebuild_all_entries && rebuild_tags
|
||||||
[[ $1 == delete ]] && rm "$2" &> /dev/null && rebuild_tags
|
[[ $1 == delete ]] && rm "$2" &>/dev/null && rebuild_tags
|
||||||
if [[ $1 == edit ]]; then
|
if [[ $1 == edit ]]; then
|
||||||
if [[ $2 == -n ]]; then
|
if [[ $2 == -n ]]; then
|
||||||
edit "$3"
|
edit "$3"
|
||||||
|
@ -83,4 +83,4 @@ do_main() {
|
||||||
make_gemini
|
make_gemini
|
||||||
echo 'deleting includes'
|
echo 'deleting includes'
|
||||||
delete_includes
|
delete_includes
|
||||||
}
|
}
|
||||||
|
|
12
lib/edit.sh
12
lib/edit.sh
|
@ -22,7 +22,7 @@ edit() {
|
||||||
printf "Can't edit post \"%s.html\", did you mean to use \"bb.sh post <draft_file>\"?\\n" "${1%%.*}" && exit 1
|
printf "Can't edit post \"%s.html\", did you mean to use \"bb.sh post <draft_file>\"?\\n" "${1%%.*}" && exit 1
|
||||||
|
|
||||||
# Original post timestamp
|
# Original post timestamp
|
||||||
edit_timestamp=$(LC_ALL=C date -r "${1%%.*}.html" +"$date_format_full" )
|
edit_timestamp=$(LC_ALL=C date -r "${1%%.*}.html" +"$date_format_full")
|
||||||
touch_timestamp=$(LC_ALL=C date -r "${1%%.*}.html" +"$date_format_timestamp")
|
touch_timestamp=$(LC_ALL=C date -r "${1%%.*}.html" +"$date_format_timestamp")
|
||||||
tags_before=$(tags_in_post "${1%%.*}.html")
|
tags_before=$(tags_in_post "${1%%.*}.html")
|
||||||
if [[ $2 == full ]]; then
|
if [[ $2 == full ]]; then
|
||||||
|
@ -30,21 +30,17 @@ edit() {
|
||||||
filename=$1
|
filename=$1
|
||||||
else
|
else
|
||||||
if [[ ${1##*.} == md ]]; then
|
if [[ ${1##*.} == md ]]; then
|
||||||
if test_markdown; then
|
|
||||||
echo "Markdown is not working, please edit HTML file directly."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
# editing markdown file
|
# editing markdown file
|
||||||
$EDITOR "$1"
|
$EDITOR "$1"
|
||||||
TMPFILE=$(mrkdwn "$1")
|
TMPFILE=$(make_html "$1")
|
||||||
filename=${1%%.*}.html
|
filename=${1%%.*}.html
|
||||||
else
|
else
|
||||||
# Create the content file
|
# Create the content file
|
||||||
TMPFILE=$(basename "$1").$RANDOM.html
|
TMPFILE=$(basename "$1").$RANDOM.html
|
||||||
# Title
|
# Title
|
||||||
get_post_title "$1" > "$TMPFILE"
|
get_post_title "$1" >"$TMPFILE"
|
||||||
# Post text with plaintext tags
|
# Post text with plaintext tags
|
||||||
get_html_file_content 'text' 'text' <"$1" | sed "/^<p>$template_tags_line_header/s|<a href='$prefix_tags\([^']*\).html'>\\1</a>|\\1|g" >> "$TMPFILE"
|
get_html_file_content 'text' 'text' <"$1" | sed "/^<p>$template_tags_line_header/s|<a href='$prefix_tags\([^']*\).html'>\\1</a>|\\1|g" >>"$TMPFILE"
|
||||||
$EDITOR "$TMPFILE"
|
$EDITOR "$TMPFILE"
|
||||||
filename=$1
|
filename=$1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -19,4 +19,4 @@ get_html_file_content() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
# $1 the html file
|
# $1 the html file
|
||||||
get_post_title() {
|
get_post_title() {
|
||||||
#awk '/<h3><a class="ablack" href=".+">/, /<\/a><\/h3>/{if (!/<h3><a class="ablack" href=".+">/ && !/<\/a><\/h3>/) print}' "$1"
|
#awk '/<h3><a class="ablack" href=".+">/, /<\/a><\/h3>/{if (!/<h3><a class="ablack" href=".+">/ && !/<\/a><\/h3>/) print}' "$1"
|
||||||
head -1 $1
|
head -1 "$1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,13 @@ global_config=".tildelog"
|
||||||
global_variables() {
|
global_variables() {
|
||||||
global_software_name="tildelog"
|
global_software_name="tildelog"
|
||||||
global_software_version="0.1"
|
global_software_version="0.1"
|
||||||
|
|
||||||
# Blog title
|
# Blog title
|
||||||
global_title="my tildelog"
|
global_title="my tildelog"
|
||||||
# The typical subtitle for each blog
|
# The typical subtitle for each blog
|
||||||
global_description="a blog about tildes"
|
global_description="a blog about tildes"
|
||||||
# The server base domain
|
# The server base domain
|
||||||
global_domain="tilde.team"
|
global_domain="tilde.team"
|
||||||
# The public base URL for this blog
|
# The public base URL for this blog
|
||||||
global_url="https://${global_domain}/~$USER/blog"
|
global_url="https://${global_domain}/~$USER/blog"
|
||||||
# Your name
|
# Your name
|
||||||
global_author="~$USER"
|
global_author="~$USER"
|
||||||
|
@ -32,8 +31,7 @@ global_variables() {
|
||||||
# CC by-nc-nd is a good starting point, you can change this to "©" for Copyright
|
# CC by-nc-nd is a good starting point, you can change this to "©" for Copyright
|
||||||
global_license="CC by-nc-nd"
|
global_license="CC by-nc-nd"
|
||||||
|
|
||||||
|
# Leave this empty (i.e. "") if you don't want to use feedburner,
|
||||||
# Leave this empty (i.e. "") if you don't want to use feedburner,
|
|
||||||
# or change it to your own URL
|
# or change it to your own URL
|
||||||
global_feedburner=""
|
global_feedburner=""
|
||||||
|
|
||||||
|
@ -73,8 +71,6 @@ global_variables() {
|
||||||
# Regexp matching the HTML line where to do the cut
|
# Regexp matching the HTML line where to do the cut
|
||||||
# note that slash is regexp separator so you need to prepend it with backslash
|
# note that slash is regexp separator so you need to prepend it with backslash
|
||||||
cut_line='<hr ?\/?>'
|
cut_line='<hr ?\/?>'
|
||||||
# save markdown file when posting with "bb post -m". Leave blank to discard it.
|
|
||||||
save_markdown="yes"
|
|
||||||
# prefix for tags/categories files
|
# prefix for tags/categories files
|
||||||
# please make sure that no other html file starts with this prefix
|
# please make sure that no other html file starts with this prefix
|
||||||
prefix_tags="tag_"
|
prefix_tags="tag_"
|
||||||
|
@ -110,7 +106,7 @@ global_variables() {
|
||||||
template_tags_title="all tags"
|
template_tags_title="all tags"
|
||||||
# "posts" (on "All tags" page, text at the end of each tag line, like "2. Music - 15 posts")
|
# "posts" (on "All tags" page, text at the end of each tag line, like "2. Music - 15 posts")
|
||||||
template_tags_posts="posts"
|
template_tags_posts="posts"
|
||||||
template_tags_posts_2_4="posts" # Some slavic languages use a different plural form for 2-4 items
|
template_tags_posts_2_4="posts" # Some slavic languages use a different plural form for 2-4 items
|
||||||
template_tags_posts_singular="post"
|
template_tags_posts_singular="post"
|
||||||
# "Posts tagged" (text on a title of a page with index of one tag, like "My Blog - Posts tagged "Music"")
|
# "Posts tagged" (text on a title of a page with index of one tag, like "My Blog - Posts tagged "Music"")
|
||||||
template_tag_title="posts tagged"
|
template_tag_title="posts tagged"
|
||||||
|
@ -149,17 +145,17 @@ global_variables() {
|
||||||
|
|
||||||
# Markdown location. Trying to autodetect by default.
|
# Markdown location. Trying to autodetect by default.
|
||||||
# The invocation must support the signature 'markdown_bin in.md > out.html'
|
# The invocation must support the signature 'markdown_bin in.md > out.html'
|
||||||
|
# shellcheck disable=SC2016
|
||||||
markdown_bin=$(which md2html.awk)
|
md2html_bin='awk "$md2html_awk"'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for the validity of some variables
|
# Check for the validity of some variables
|
||||||
# DO NOT EDIT THIS FUNCTION unless you know what you're doing
|
# DO NOT EDIT THIS FUNCTION unless you know what you're doing
|
||||||
global_variables_check() {
|
global_variables_check() {
|
||||||
[[ $header_file == .header.html ]] && \
|
[[ $header_file == .header.html ]] &&
|
||||||
echo "Please check your configuration. '.header.html' is not a valid value for the setting 'header_file'" && \
|
echo "Please check your configuration. '.header.html' is not a valid value for the setting 'header_file'" &&
|
||||||
exit
|
exit
|
||||||
[[ $footer_file == .footer.html ]] && \
|
[[ $footer_file == .footer.html ]] &&
|
||||||
echo "Please check your configuration. '.footer.html' is not a valid value for the setting 'footer_file'" && \
|
echo "Please check your configuration. '.footer.html' is not a valid value for the setting 'footer_file'" &&
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,14 @@ is_boilerplate_file() {
|
||||||
done
|
done
|
||||||
|
|
||||||
case $name in
|
case $name in
|
||||||
( "$index_file" | "$archive_index" | "$gophermap" | "$gemini_index" | "$tags_index" | "$footer_file" | "$header_file" | "$prefix_tags"* )
|
"$index_file" | "$archive_index" | "$gophermap" | "$gemini_index" | "$tags_index" | "$footer_file" | "$header_file" | "$prefix_tags"*)
|
||||||
return 0 ;;
|
return 0
|
||||||
( * ) # Check for excluded
|
;;
|
||||||
for excl in "${html_exclude[@]}"; do
|
*) # Check for excluded
|
||||||
[[ $name == "$excl" ]] && return 0
|
for excl in "${html_exclude[@]}"; do
|
||||||
done
|
[[ $name == "$excl" ]] && return 0
|
||||||
return 1 ;;
|
done
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ list_tags() {
|
||||||
lines+=$line\\n
|
lines+=$line\\n
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( do_sort == 1 )); then
|
if ((do_sort == 1)); then
|
||||||
echo -e "$lines" | column -t -s "#" | sort -nrk 2
|
echo -e "$lines" | column -t -s "#" | sort -nrk 2
|
||||||
else
|
else
|
||||||
echo -e "$lines" | column -t -s "#"
|
echo -e "$lines" | column -t -s "#"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ make_gemini() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${HOME}/public_gemini/blog/$gemini_index" ]; then
|
if [ ! -f "${HOME}/public_gemini/blog/$gemini_index" ]; then
|
||||||
cat <<- 'EOF' > "${HOME}/public_gemini/blog/${gemini_index}"
|
cat <<-'EOF' >"${HOME}/public_gemini/blog/${gemini_index}"
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
printf "20 text/gemini\r\n"
|
printf "20 text/gemini\r\n"
|
||||||
printf "my bashblog posts\r\n"
|
printf "my bashblog posts\r\n"
|
||||||
|
@ -24,4 +24,4 @@ make_gemini() {
|
||||||
EOF
|
EOF
|
||||||
chmod +x "${HOME}/public_gemini/blog/${gemini_index}"
|
chmod +x "${HOME}/public_gemini/blog/${gemini_index}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ make_gophermap() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${HOME}/public_gopher/blog/$gophermap" ]; then
|
if [ ! -f "${HOME}/public_gopher/blog/$gophermap" ]; then
|
||||||
cat <<- 'EOF' > "${HOME}/public_html/blog/${gophermap}"
|
cat <<-'EOF' >"${HOME}/public_html/blog/${gophermap}"
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
printf "my bashblog posts\n"
|
printf "my bashblog posts\n"
|
||||||
user=$(stat -c '%U' .)
|
user=$(stat -c '%U' .)
|
||||||
|
@ -23,4 +23,4 @@ EOF
|
||||||
chmod +x "${HOME}/public_html/blog/${gophermap}"
|
chmod +x "${HOME}/public_html/blog/${gophermap}"
|
||||||
fi
|
fi
|
||||||
chmod 644 ./*.md
|
chmod 644 ./*.md
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Parse a Markdown file into HTML and return the generated file
|
||||||
|
declare md2html_bin
|
||||||
|
make_html() {
|
||||||
|
out=${1%.md}.html
|
||||||
|
while [[ -f $out ]]; do
|
||||||
|
out=${out%.html}.$RANDOM.html
|
||||||
|
done
|
||||||
|
eval "$md2html_bin" "$1" >"$out"
|
||||||
|
echo "$out"
|
||||||
|
}
|
|
@ -18,8 +18,8 @@ make_rss() {
|
||||||
|
|
||||||
{
|
{
|
||||||
pubdate=$(LC_ALL=C date +"$date_format_full")
|
pubdate=$(LC_ALL=C date +"$date_format_full")
|
||||||
echo '<?xml version="1.0" encoding="UTF-8" ?>'
|
echo '<?xml version="1.0" encoding="UTF-8" ?>'
|
||||||
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">'
|
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">'
|
||||||
echo "<channel><title>$global_title</title><link>$global_url/$index_file</link>"
|
echo "<channel><title>$global_title</title><link>$global_url/$index_file</link>"
|
||||||
echo "<description>$global_description</description><language>en</language>"
|
echo "<description>$global_description</description><language>en</language>"
|
||||||
echo "<lastBuildDate>$pubdate</lastBuildDate>"
|
echo "<lastBuildDate>$pubdate</lastBuildDate>"
|
||||||
|
@ -31,16 +31,16 @@ make_rss() {
|
||||||
is_boilerplate_file "$i" && continue
|
is_boilerplate_file "$i" && continue
|
||||||
((n >= number_of_feed_articles)) && break # max 10 items
|
((n >= number_of_feed_articles)) && break # max 10 items
|
||||||
echo -n "." 1>&3
|
echo -n "." 1>&3
|
||||||
echo '<item><title>'
|
echo '<item><title>'
|
||||||
get_post_title "$i"
|
get_post_title "$i"
|
||||||
echo '</title><description><![CDATA['
|
echo '</title><description><![CDATA['
|
||||||
get_html_file_content 'text' 'entry' "$cut_do" <"$i"
|
get_html_file_content 'text' 'entry' "$cut_do" <"$i"
|
||||||
echo "]]></description><link>$global_url/${i#./}</link>"
|
echo "]]></description><link>$global_url/${i#./}</link>"
|
||||||
echo "<guid>$global_url/$i</guid>"
|
echo "<guid>$global_url/$i</guid>"
|
||||||
echo "<dc:creator>$(get_post_author "$i")</dc:creator>"
|
echo "<dc:creator>$(get_post_author "$i")</dc:creator>"
|
||||||
echo "<pubDate>$(LC_ALL=C date -r "$i" +"$date_format_full")</pubDate></item>"
|
echo "<pubDate>$(LC_ALL=C date -r "$i" +"$date_format_full")</pubDate></item>"
|
||||||
|
|
||||||
n=$(( n + 1 ))
|
n=$((n + 1))
|
||||||
done < <(ls -t ./*.html)
|
done < <(ls -t ./*.html)
|
||||||
|
|
||||||
echo '</channel></rss>'
|
echo '</channel></rss>'
|
||||||
|
@ -49,4 +49,4 @@ make_rss() {
|
||||||
|
|
||||||
mv "$rssfile" "$blog_feed"
|
mv "$rssfile" "$blog_feed"
|
||||||
chmod 644 "$blog_feed"
|
chmod 644 "$blog_feed"
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,40 +22,40 @@ function oprint(t){
|
||||||
}
|
}
|
||||||
|
|
||||||
# https://unix.stackexchange.com/a/94751
|
# https://unix.stackexchange.com/a/94751
|
||||||
function centralize(t,c){
|
function centralize(text, border , margin){
|
||||||
L = col - c - length(t);
|
L = col - border - margin - length(text);
|
||||||
#print("====" length(t) "=====" t "=====\n")
|
#print("====" length(t) "=====" t "=====\n")
|
||||||
for(i=1; i<=int(L/2); i++)
|
for(i=1; i<=(int(L/2) + margin) ; i++)
|
||||||
t = " "t;
|
text = " "text;
|
||||||
for(i=1; i<=int(L/2+.5); i++)
|
for(i=1; i<=int(L/2+.5) ; i++)
|
||||||
t = t " "
|
text = text " "
|
||||||
return t
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# function from https://unix.stackexchange.com/a/282338
|
# function from https://unix.stackexchange.com/a/282338
|
||||||
function justify(t,i,nbchar,nbspc,spaces,spcpf,r){
|
function justify(text, margin, j, nbchar, wreturn, spcpf, spaces, nbspc){
|
||||||
$0=t
|
$0=text
|
||||||
if (NF <= 1) { return t }
|
if (NF <= 1) { return text }
|
||||||
else {
|
else {
|
||||||
nbchar = 0
|
nbchar = 0
|
||||||
for (i = 1; i <= NF; i++) {
|
for (i = 1; i <= NF; i++) {
|
||||||
nbchar += length($i)
|
nbchar += length($i)
|
||||||
}
|
}
|
||||||
nbspc = col - nbchar
|
nbspc = (col - margin) - nbchar - 1
|
||||||
spcpf = int(nbspc / (NF - 1))
|
spcpf = int(nbspc / (NF - 1))
|
||||||
for (i = 1; i < NF; i++) {
|
for (i = 1; i < NF; i++) {
|
||||||
r = r $i
|
wreturn = wreturn $i
|
||||||
spaces = (NF == 2 || i == NF - 1) ? nbspc : spcpf
|
spaces = (NF == 2 || i == NF - 1) ? nbspc : spcpf
|
||||||
if (spaces < 1) spaces = 1
|
if (spaces < 1) spaces = 1
|
||||||
for (j = 0; j < spaces; j++) {
|
for (j = 0; j < spaces; j++) {
|
||||||
r = r " "
|
wreturn = wreturn " "
|
||||||
}
|
}
|
||||||
nbspc -= spaces
|
nbspc -= spaces
|
||||||
}
|
}
|
||||||
r = r $NF
|
wreturn = wreturn $NF
|
||||||
}
|
}
|
||||||
return r
|
return wreturn
|
||||||
}
|
}
|
||||||
|
|
||||||
function subref(id){
|
function subref(id){
|
||||||
|
@ -104,6 +104,7 @@ function nextil(t) {
|
||||||
}
|
}
|
||||||
ilcode = !ilcode;
|
ilcode = !ilcode;
|
||||||
return t1 tag nextil(t2);
|
return t1 tag nextil(t2);
|
||||||
|
return t1 tag nextil(t2);
|
||||||
}
|
}
|
||||||
if(tag == "<"){
|
if(tag == "<"){
|
||||||
# Autolinks
|
# Autolinks
|
||||||
|
@ -240,7 +241,8 @@ function nextil(t) {
|
||||||
else
|
else
|
||||||
stag[++ns] = ntag;
|
stag[++ns] = ntag;
|
||||||
tag = "<" tag ">";
|
tag = "<" tag ">";
|
||||||
return t1 tag nextil(t2);
|
#return t1 tag nextil(t2);
|
||||||
|
return t1 nextil(t2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,22 +255,29 @@ function inline(t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#https://unix.stackexchange.com/a/337656
|
#https://unix.stackexchange.com/a/337656
|
||||||
function wrap(t,align,q,y,z,final) {
|
function wrap(t,align) {
|
||||||
|
final=""
|
||||||
|
z=""
|
||||||
|
y=0
|
||||||
|
margin_spaces=""
|
||||||
|
localmargin = blockquote * 5
|
||||||
|
for(c = 0; c < localmargin; c++)
|
||||||
|
margin_spaces = " " margin_spaces
|
||||||
while (t)
|
while (t)
|
||||||
{
|
{
|
||||||
q = match(t, / |$/); y += q
|
q = match(t, / |$/); y += q
|
||||||
if (y > col) {
|
if (y > col - localmargin) {
|
||||||
|
#print "|"localmargin"|"blockquote"|"nnl"|"
|
||||||
if (align != 0)
|
if (align != 0)
|
||||||
{
|
{
|
||||||
if (align=="c")
|
if (align=="c")
|
||||||
#print "zzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
final = final margin_spaces centralize(z,localmargin) RS
|
||||||
final = final centralize(z) RS
|
|
||||||
if (align=="j")
|
if (align=="j")
|
||||||
final = final justify(z) RS
|
final = final margin_spaces justify(z,localmargin) RS
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final = final z RS
|
final = final z RS
|
||||||
}
|
}
|
||||||
y = q - 1
|
y = q - 1
|
||||||
z = ""
|
z = ""
|
||||||
|
@ -279,10 +288,10 @@ function wrap(t,align,q,y,z,final) {
|
||||||
}
|
}
|
||||||
if (align=="c")
|
if (align=="c")
|
||||||
{
|
{
|
||||||
final = final centralize(z)
|
final = final margin_spaces centralize(z, localmargin)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final = final z
|
final = final margin_spaces z
|
||||||
}
|
}
|
||||||
return final
|
return final
|
||||||
}
|
}
|
||||||
|
@ -309,10 +318,12 @@ BEGIN {
|
||||||
html = 0;
|
html = 0;
|
||||||
nl = 0;
|
nl = 0;
|
||||||
nr = 0;
|
nr = 0;
|
||||||
|
margin = 0;
|
||||||
otext = "";
|
otext = "";
|
||||||
text = "";
|
text = "";
|
||||||
par = "p";
|
par = "p";
|
||||||
col=70;
|
col=70;
|
||||||
|
listitem=0;
|
||||||
c=0; do { lineheader = "=" lineheader; c++ } while ( c < col )
|
c=0; do { lineheader = "=" lineheader; c++ } while ( c < col )
|
||||||
c=0; do { lineheadersmall = "-" lineheadersmall; c++ } while ( c < col )
|
c=0; do { lineheadersmall = "-" lineheadersmall; c++ } while ( c < col )
|
||||||
}
|
}
|
||||||
|
@ -347,38 +358,6 @@ BEGIN {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# html
|
|
||||||
!html && /^<(address|blockquote|center|dir|div|dl|fieldset|form|h[1-6r]|\
|
|
||||||
isindex|menu|noframes|noscript|ol|p|pre|table|ul|!--)/ {
|
|
||||||
if(code)
|
|
||||||
oprint("</pre></code>");
|
|
||||||
for(; !text && block[nl] == "blockquote"; nl--)
|
|
||||||
oprint("</blockquote>");
|
|
||||||
match($0, /^<(address|blockquote|center|dir|div|dl|fieldset|form|h[1-6r]|\
|
|
||||||
isindex|menu|noframes|noscript|ol|p|pre|table|ul|!--)/);
|
|
||||||
htag = substr($0, 2, RLENGTH - 1);
|
|
||||||
if(!match($0, "(<\\/" htag ">)|((^<hr ?\\/?)|(--)>$)"))
|
|
||||||
html = 1;
|
|
||||||
if(html && match($0, /^<hr/))
|
|
||||||
hr = 1;
|
|
||||||
oprint($0);
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
html && (/(^<\/(address|blockquote|center|dir|div|dl|fieldset|form|h[1-6r]|\
|
|
||||||
isindex|menu|noframes|noscript|ol|p|pre|table|ul).*)|(--)>$/ ||
|
|
||||||
(hr && />$/)) {
|
|
||||||
html = 0;
|
|
||||||
hr = 0;
|
|
||||||
oprint($0);
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
oprint($0);
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# List and quote blocks
|
# List and quote blocks
|
||||||
|
|
||||||
# Remove indentation
|
# Remove indentation
|
||||||
|
@ -393,12 +372,13 @@ nnl < nl && !blank && text && ! /^ ? ? ?([*+-]|([0-9]+\.)+)( +| )/ { nnl = nl; }
|
||||||
{
|
{
|
||||||
while(sub(/^> /, ""))
|
while(sub(/^> /, ""))
|
||||||
nblock[++nnl] = "blockquote";
|
nblock[++nnl] = "blockquote";
|
||||||
|
blockquote = nnl;
|
||||||
}
|
}
|
||||||
# Horizontal rules
|
# Horizontal rules
|
||||||
{ hr = 0; }
|
{ hr = 0; }
|
||||||
(blank || (!text && !code)) && /^ ? ? ?([-*_][ ]*)([-*_][ ]*)([-*_][ ]*)+$/ {
|
(blank || (!text && !code)) && /^ ? ? ?([-*_][ ]*)([-*_][ ]*)([-*_][ ]*)+$/ {
|
||||||
if(code){
|
if(code){
|
||||||
oprint("</pre></code>");
|
#oprint("</pre></code>");
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
blank = 0;
|
blank = 0;
|
||||||
|
@ -415,12 +395,15 @@ block[nl] ~ /[ou]l/ && /^$/ {
|
||||||
sub(/^ ? ? ?[*+-]( +| )/, "");
|
sub(/^ ? ? ?[*+-]( +| )/, "");
|
||||||
nnl++;
|
nnl++;
|
||||||
nblock[nnl] = "ul";
|
nblock[nnl] = "ul";
|
||||||
|
listtype="ul";
|
||||||
newli = 1;
|
newli = 1;
|
||||||
}
|
}
|
||||||
(nnl != nl || !text || block[nl] ~ /[ou]l/) && /^ ? ? ?([0-9]+\.)+( +| )/ {
|
(nnl != nl || !text || block[nl] ~ /[ou]l/) && /^ ? ? ?([0-9]+\.)+( +| )/ {
|
||||||
sub(/^ ? ? ?([0-9]+\.)+( +| )/, "");
|
sub(/^ ? ? ?([0-9]+\.)+( +| )/, "");
|
||||||
nnl++;
|
nnl++;
|
||||||
nblock[nnl] = "ol";
|
nblock[nnl] = "ol";
|
||||||
|
listtype="ol";
|
||||||
|
listitem++
|
||||||
newli = 1;
|
newli = 1;
|
||||||
}
|
}
|
||||||
newli {
|
newli {
|
||||||
|
@ -429,7 +412,12 @@ newli {
|
||||||
blank = 0;
|
blank = 0;
|
||||||
printp(par);
|
printp(par);
|
||||||
if(nnl == nl && block[nl] == nblock[nl])
|
if(nnl == nl && block[nl] == nblock[nl])
|
||||||
oprint("</li><li>");
|
#oprint("</li><li>");
|
||||||
|
if(listtype == "ul")
|
||||||
|
printf "- ";
|
||||||
|
if(listtype == "ol")
|
||||||
|
printf "%s - ", listitem;
|
||||||
|
|
||||||
}
|
}
|
||||||
blank && ! /^$/ {
|
blank && ! /^$/ {
|
||||||
if(match(block[nnl], /[ou]l/) && !par)
|
if(match(block[nnl], /[ou]l/) && !par)
|
||||||
|
@ -442,26 +430,36 @@ blank && ! /^$/ {
|
||||||
# Close old blocks and open new ones
|
# Close old blocks and open new ones
|
||||||
nnl != nl || nblock[nl] != block[nl] {
|
nnl != nl || nblock[nl] != block[nl] {
|
||||||
if(code){
|
if(code){
|
||||||
oprint("</pre></code>");
|
#oprint("</pre></code>");
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
printp(par);
|
printp(par);
|
||||||
b = (nnl > nl) ? nblock[nnl] : block[nnl];
|
b = (nnl > nl) ? nblock[nnl] : block[nnl];
|
||||||
par = (match(b, /[ou]l/)) ? "" : "p";
|
par = (match(b, /[ou]l/)) ? "" : "p";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
nnl < nl || (nnl == nl && nblock[nl] != block[nl]) {
|
nnl < nl || (nnl == nl && nblock[nl] != block[nl]) {
|
||||||
for(; nl > nnl || (nnl == nl && pblock[nl] != block[nl]); nl--){
|
for(; nl > nnl || (nnl == nl && pblock[nl] != block[nl]); nl--){
|
||||||
if(match(block[nl], /[ou]l/))
|
if(match(block[nl], /[ou]l/))
|
||||||
oprint("</li>");
|
#oprint("</li>");
|
||||||
oprint("</" block[nl] ">");
|
printf ""
|
||||||
|
#oprint("</" block[nl] ">");
|
||||||
|
#if(listtype == "ol")
|
||||||
|
# listitem = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nnl > nl {
|
nnl > nl {
|
||||||
for(; nl < nnl; nl++){
|
for(; nl < nnl; nl++){
|
||||||
block[nl + 1] = nblock[nl + 1];
|
block[nl + 1] = nblock[nl + 1];
|
||||||
oprint("<" block[nl + 1] ">");
|
#oprint("<" block[nl + 1] ">");
|
||||||
if(match(block[nl + 1], /[ou]l/))
|
if(match(block[nl + 1], /[ou]l/))
|
||||||
oprint("<li>");
|
#oprint("<li>");
|
||||||
|
if(listtype == "ul")
|
||||||
|
printf "- ";
|
||||||
|
#if(listtype == "ol")
|
||||||
|
#printf "%s - ", listitem;
|
||||||
|
#listitem=0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hr {
|
hr {
|
||||||
|
@ -476,19 +474,20 @@ code && /^$/ {
|
||||||
blank = 1;
|
blank = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
!text && sub(/^( | )/, "") {
|
!text && sub(/^( | )/, "") {
|
||||||
if(blanK)
|
if(blanK)
|
||||||
oprint("");
|
oprint("");
|
||||||
blank = 0;
|
blank = 0;
|
||||||
if(!code)
|
#if(!code)
|
||||||
oprint("<code><pre>");
|
# oprint("<code><pre>");
|
||||||
code = 1;
|
code = 1;
|
||||||
$0 = eschtml($0);
|
$0 = eschtml($0);
|
||||||
oprint($0);
|
oprint($0);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
code {
|
code {
|
||||||
oprint("</pre></code>");
|
#oprint("</pre></code>");
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +511,7 @@ text && /^-+$/ {printp("h2"); next;}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (n == 3) {
|
if (n == 3) {
|
||||||
oprint(text centralize($0) "\n" lineheadersmall "\n")
|
oprint("\n" text centralize($0) "\n" lineheadersmall "\n")
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (n > 3) {
|
if (n > 3) {
|
||||||
|
@ -539,15 +538,16 @@ function alen(a, ix, k) {
|
||||||
|
|
||||||
END {
|
END {
|
||||||
if(code){
|
if(code){
|
||||||
oprint("</pre></code>");
|
# oprint("</pre></code>");
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
printp(par);
|
#printp(par);
|
||||||
for(; nl > 0; nl--){
|
#for(; nl > 0; nl--){
|
||||||
if(match(block[nl], /[ou]l/))
|
# if(match(block[nl], /[ou]l/))
|
||||||
oprint("</li>");
|
# listitem=0
|
||||||
oprint("</" block[nl] ">");
|
#oprint("</li>");
|
||||||
}
|
# oprint("</" block[nl] ">");
|
||||||
|
#}
|
||||||
gsub(/<<[^"]*/, "", otext);
|
gsub(/<<[^"]*/, "", otext);
|
||||||
print(otext);
|
print(otext);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/awk -f
|
#!/usr/bin/awk -f
|
||||||
#
|
#
|
||||||
# by: Jesus Galan (yiyus) 2009
|
# by: Jesus Galan (yiyus) 2009
|
||||||
#
|
#
|
|
@ -1,13 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Parse a Markdown file into HTML and return the generated file
|
|
||||||
declare markdown_bin
|
|
||||||
mrkdwn() {
|
|
||||||
out=${1%.md}.html
|
|
||||||
while [[ -f $out ]]
|
|
||||||
do
|
|
||||||
out=${out%.md}.$RANDOM.html
|
|
||||||
done
|
|
||||||
$markdown_bin "$1" > "$out"
|
|
||||||
echo "$out"
|
|
||||||
}
|
|
|
@ -36,18 +36,18 @@ parse_file() {
|
||||||
# Parse possible tags
|
# Parse possible tags
|
||||||
elif [[ $line == "<p>$template_tags_line_header"* ]]; then
|
elif [[ $line == "<p>$template_tags_line_header"* ]]; then
|
||||||
tags=$(echo "$line" | cut -d ":" -f 2- | sed -e 's/<\/p>//g' -e 's/^ *//' -e 's/ *$//' -e 's/, /,/g')
|
tags=$(echo "$line" | cut -d ":" -f 2- | sed -e 's/<\/p>//g' -e 's/^ *//' -e 's/ *$//' -e 's/, /,/g')
|
||||||
IFS=, read -r -a array <<< "$tags"
|
IFS=, read -r -a array <<<"$tags"
|
||||||
|
|
||||||
echo -n "<p>$template_tags_line_header " >> "$content"
|
echo -n "<p>$template_tags_line_header " >>"$content"
|
||||||
for item in "${array[@]}"; do
|
for item in "${array[@]}"; do
|
||||||
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
|
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
|
||||||
done | sed 's/, $/<\/p>/g' >> "$content"
|
done | sed 's/, $/<\/p>/g' >>"$content"
|
||||||
else
|
else
|
||||||
echo "$line" >> "$content"
|
echo "$line" >>"$content"
|
||||||
fi
|
fi
|
||||||
done < "$1"
|
done <"$1"
|
||||||
|
|
||||||
# Create the actual html page
|
# Create the actual html page
|
||||||
create_html_page "$content" "$filename" no "$title" "$2" "$global_author"
|
create_html_page "$content" "$filename" no "$title" "$2" "$global_author"
|
||||||
rm "$content"
|
rm "$content"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,5 @@ posts_with_tags() {
|
||||||
(($# < 1)) && return
|
(($# < 1)) && return
|
||||||
set -- "${@/#/$prefix_tags}"
|
set -- "${@/#/$prefix_tags}"
|
||||||
set -- "${@/%/.html}"
|
set -- "${@/%/.html}"
|
||||||
sed -n '/^<h3><a class="ablack" href="[^"]*">/{s/.*href="\([^"]*\)">.*/\1/;p;}' "$@" 2> /dev/null
|
sed -n '/^<h3><a class="ablack" href="[^"]*">/{s/.*href="\([^"]*\)">.*/\1/;p;}' "$@" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,4 +58,4 @@ rebuild_all_entries() {
|
||||||
#rm "$contentfile"
|
#rm "$contentfile"
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ rebuild_index() {
|
||||||
echo -n "Rebuilding the index "
|
echo -n "Rebuilding the index "
|
||||||
newindexfile=$index_file.$RANDOM
|
newindexfile=$index_file.$RANDOM
|
||||||
contentfile=$newindexfile.content
|
contentfile=$newindexfile.content
|
||||||
while [[ -f $newindexfile ]]; do
|
while [[ -f $newindexfile ]]; do
|
||||||
newindexfile=$index_file.$RANDOM
|
newindexfile=$index_file.$RANDOM
|
||||||
contentfile=$newindexfile.content
|
contentfile=$newindexfile.content
|
||||||
done
|
done
|
||||||
|
@ -29,7 +29,7 @@ rebuild_index() {
|
||||||
{
|
{
|
||||||
n=0
|
n=0
|
||||||
while IFS='' read -r i; do
|
while IFS='' read -r i; do
|
||||||
is_boilerplate_file "$i" && continue;
|
is_boilerplate_file "$i" && continue
|
||||||
if ((n >= number_of_index_articles)); then break; fi
|
if ((n >= number_of_index_articles)); then break; fi
|
||||||
if [[ -n $cut_do ]]; then
|
if [[ -n $cut_do ]]; then
|
||||||
get_html_file_content 'entry' 'entry' 'cut' <"$i" | awk "/$cut_line/ { print \"<p class=\\\"readmore\\\"><a href=\\\"$i\\\">$template_read_more</a></p>\" ; next } 1"
|
get_html_file_content 'entry' 'entry' 'cut' <"$i" | awk "/$cut_line/ { print \"<p class=\\\"readmore\\\"><a href=\\\"$i\\\">$template_read_more</a></p>\" ; next } 1"
|
||||||
|
@ -37,7 +37,7 @@ rebuild_index() {
|
||||||
get_html_file_content 'entry' 'entry' <"$i"
|
get_html_file_content 'entry' 'entry' <"$i"
|
||||||
fi
|
fi
|
||||||
echo -n "." 1>&3
|
echo -n "." 1>&3
|
||||||
n=$(( n + 1 ))
|
n=$((n + 1))
|
||||||
done < <(ls -t ./*.html) # sort by date, newest first
|
done < <(ls -t ./*.html) # sort by date, newest first
|
||||||
|
|
||||||
feed=$blog_feed
|
feed=$blog_feed
|
||||||
|
@ -51,4 +51,4 @@ rebuild_index() {
|
||||||
rm "$contentfile"
|
rm "$contentfile"
|
||||||
mv "$newindexfile" "$index_file"
|
mv "$newindexfile" "$index_file"
|
||||||
chmod 644 "$index_file"
|
chmod 644 "$index_file"
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ declare template_read_more
|
||||||
declare template_tag_title
|
declare template_tag_title
|
||||||
declare global_title
|
declare global_title
|
||||||
declare global_author
|
declare global_author
|
||||||
rebuild_tags() {
|
|
||||||
|
|
||||||
|
rebuild_tags() {
|
||||||
if (($# < 2)); then
|
if (($# < 2)); then
|
||||||
# will process all files and tags
|
# will process all files and tags
|
||||||
files=$(ls -t ./*.html)
|
files=$(ls -t ./*.html)
|
||||||
|
@ -32,10 +32,10 @@ rebuild_tags() {
|
||||||
echo -n "Rebuilding tag pages "
|
echo -n "Rebuilding tag pages "
|
||||||
#n=0
|
#n=0
|
||||||
if [[ -n $all_tags ]]; then
|
if [[ -n $all_tags ]]; then
|
||||||
rm ./"$prefix_tags"*.html &> /dev/null
|
rm ./"$prefix_tags"*.html &>/dev/null
|
||||||
else
|
else
|
||||||
for i in $tags; do
|
for i in $tags; do
|
||||||
rm "./$prefix_tags$i.html" &> /dev/null
|
rm "./$prefix_tags$i.html" &>/dev/null
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
# First we will process all files and create temporal tag files
|
# First we will process all files and create temporal tag files
|
||||||
|
@ -43,7 +43,7 @@ rebuild_tags() {
|
||||||
tmpfile=tmp.$RANDOM
|
tmpfile=tmp.$RANDOM
|
||||||
while [[ -f $tmpfile ]]; do tmpfile=tmp.$RANDOM; done
|
while [[ -f $tmpfile ]]; do tmpfile=tmp.$RANDOM; done
|
||||||
while IFS='' read -r i; do
|
while IFS='' read -r i; do
|
||||||
is_boilerplate_file "$i" && continue;
|
is_boilerplate_file "$i" && continue
|
||||||
echo -n "."
|
echo -n "."
|
||||||
if [[ -n $cut_do ]]; then
|
if [[ -n $cut_do ]]; then
|
||||||
get_html_file_content 'entry' 'entry' 'cut' <"$i" | awk "/$cut_line/ { print \"<p class=\\\"readmore\\\"><a href=\\\"$i\\\">$template_read_more</a></p>\" ; next } 1"
|
get_html_file_content 'entry' 'entry' 'cut' <"$i" | awk "/$cut_line/ { print \"<p class=\\\"readmore\\\"><a href=\\\"$i\\\">$template_read_more</a></p>\" ; next } 1"
|
||||||
|
@ -52,10 +52,10 @@ rebuild_tags() {
|
||||||
fi >"$tmpfile"
|
fi >"$tmpfile"
|
||||||
for tag in $(tags_in_post "$i"); do
|
for tag in $(tags_in_post "$i"); do
|
||||||
if [[ -n $all_tags || " $tags " == *" $tag "* ]]; then
|
if [[ -n $all_tags || " $tags " == *" $tag "* ]]; then
|
||||||
cat "$tmpfile" >> "$prefix_tags$tag".tmp.html
|
cat "$tmpfile" >>"$prefix_tags$tag".tmp.html
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done <<< "$files"
|
done <<<"$files"
|
||||||
rm "$tmpfile"
|
rm "$tmpfile"
|
||||||
# Now generate the tag files with headers, footers, etc
|
# Now generate the tag files with headers, footers, etc
|
||||||
while IFS='' read -r i; do
|
while IFS='' read -r i; do
|
||||||
|
@ -65,4 +65,4 @@ rebuild_tags() {
|
||||||
rm "$i"
|
rm "$i"
|
||||||
done < <(ls -t ./"$prefix_tags"*.tmp.html 2>/dev/null)
|
done < <(ls -t ./"$prefix_tags"*.tmp.html 2>/dev/null)
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Delete all generated content, leaving only this script
|
# Delete all generated content, leaving only this script
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
echo "Are you sure you want to delete all blog entries? Please write \"Yes, I am!\" "
|
echo "Are you sure you want to delete all blog entries? Please write \"Yes, I am!\" "
|
||||||
read -r line
|
read -r line
|
||||||
if [[ $line == "Yes, I am!" ]]; then
|
if [[ $line == "Yes, I am!" ]]; then
|
||||||
rm .*.html ./*.html ./*.css ./*.rss &> /dev/null
|
rm .*.html ./*.html ./*.css ./*.rss &>/dev/null
|
||||||
echo
|
echo
|
||||||
echo "Deleted all posts, stylesheets and feeds."
|
echo "Deleted all posts, stylesheets and feeds."
|
||||||
echo "Kept your old '.backup.tar.gz' just in case, please delete it manually if needed."
|
echo "Kept your old '.backup.tar.gz' just in case, please delete it manually if needed."
|
||||||
else
|
else
|
||||||
echo "Phew! You dodged a bullet there. Nothing was modified."
|
echo "Phew! You dodged a bullet there. Nothing was modified."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
tags_in_post() {
|
tags_in_post() {
|
||||||
sed -n "/^<p>$template_tags_line_header/{s/^<p>$template_tags_line_header//;s/<[^>]*>//g;s/[ ,]\+/ /g;p;}" "$1" | tr ', ' ' '
|
sed -n "/^<p>$template_tags_line_header/{s/^<p>$template_tags_line_header//;s/<[^>]*>//g;s/[ ,]\+/ /g;p;}" "$1" | tr ', ' ' '
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Test if the markdown script is working correctly
|
|
||||||
test_markdown() {
|
|
||||||
declare markdown_bin
|
|
||||||
if [[ -n $markdown_bin ]]; then
|
|
||||||
local m1; m1=$("$markdown_bin" <<< "$'line 1\n\nline 2'")
|
|
||||||
local m2; m2=$("$markdown_bin" <<< "$'line 1\n\nline 2'")
|
|
||||||
local c1=$'<p>line 1</p>\n\n<p>line 2</p>'
|
|
||||||
local c2=$'<p>line 1</p>\n<p>line 2</p>'
|
|
||||||
# shellcheck disable=SC22350 # must enforce order of operations
|
|
||||||
[[ "$m1" == "$c1" ]] || [[ "$m2" == "$c2" ]]
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -4,20 +4,23 @@
|
||||||
#
|
#
|
||||||
# $1 the post file
|
# $1 the post file
|
||||||
# $2 the title
|
# $2 the title
|
||||||
|
|
||||||
|
declare global_twitter_username
|
||||||
|
declare template_tags_line_header
|
||||||
|
declare global_url
|
||||||
|
declare global_twitter_cookieless
|
||||||
|
declare template_twitter_button
|
||||||
|
declare template_twitter_comment
|
||||||
|
declare template_comments
|
||||||
|
|
||||||
twitter_card() {
|
twitter_card() {
|
||||||
declare global_twitter_username
|
|
||||||
declare template_tags_line_header
|
|
||||||
declare global_url
|
|
||||||
declare global_twitter_cookieless
|
|
||||||
declare template_twitter_button
|
|
||||||
declare template_twitter_comment
|
|
||||||
declare template_comments
|
|
||||||
[[ -z $global_twitter_username ]] && return
|
[[ -z $global_twitter_username ]] && return
|
||||||
|
|
||||||
echo "<meta name='twitter:card' content='summary'>"
|
echo "<meta name='twitter:card' content='summary'>"
|
||||||
echo "<meta name='twitter:site' content='@$global_twitter_username'>"
|
echo "<meta name='twitter:site' content='@$global_twitter_username'>"
|
||||||
echo "<meta name='twitter:title' content='$2'>" # Twitter truncates at 70 char
|
echo "<meta name='twitter:title' content='$2'>" # Twitter truncates at 70 char
|
||||||
description=$(grep -v "^<p>$template_tags_line_header" "$1" | sed -e 's/<[^>]*>//g' | head -c 250 | tr '\n' ' ' | sed "s/\"/'/g")
|
description=$(grep -v "^<p>$template_tags_line_header" "$1" | sed -e 's/<[^>]*>//g' | head -c 250 | tr '\n' ' ' | sed "s/\"/'/g")
|
||||||
echo "<meta name='twitter:description' content=\"$description\">"
|
echo "<meta name='twitter:description' content=\"$description\">"
|
||||||
image=$(sed -n 's/.*<img.*src="\([^"]*\)".*/\1/p' "$1" | head -n 1) # First image is fine
|
image=$(sed -n 's/.*<img.*src="\([^"]*\)".*/\1/p' "$1" | head -n 1) # First image is fine
|
||||||
[[ -z $image ]] && return
|
[[ -z $image ]] && return
|
||||||
|
@ -38,13 +41,13 @@ twitter() {
|
||||||
|
|
||||||
echo "<p id='twitter'><a href='http://twitter.com/intent/tweet?url=$1&text=$template_twitter_comment&via=$global_twitter_username'>$template_comments $template_twitter_button</a> "
|
echo "<p id='twitter'><a href='http://twitter.com/intent/tweet?url=$1&text=$template_twitter_comment&via=$global_twitter_username'>$template_comments $template_twitter_button</a> "
|
||||||
echo "<a href='$search_engine""$1'><span id='count-$id'></span></a> </p>"
|
echo "<a href='$search_engine""$1'><span id='count-$id'></span></a> </p>"
|
||||||
return;
|
return
|
||||||
else
|
else
|
||||||
echo "<p id='twitter'>$template_comments ";
|
echo "<p id='twitter'>$template_comments "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "<a href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-text=\"$template_twitter_comment\" data-url=\"$1\""
|
echo "<a href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-text=\"$template_twitter_comment\" data-url=\"$1\""
|
||||||
echo " data-via=\"$global_twitter_username\""
|
echo " data-via=\"$global_twitter_username\""
|
||||||
echo ">$template_twitter_button</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"//platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>"
|
echo ">$template_twitter_button</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"//platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>"
|
||||||
echo "</p>"
|
echo "</p>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Displays the help
|
||||||
|
|
||||||
declare global_software_name
|
declare global_software_name
|
||||||
declare global_software_version
|
declare global_software_version
|
||||||
# Displays the help
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$global_software_name $global_software_version"
|
echo "$global_software_name $global_software_version"
|
||||||
echo "usage: $0 command [filename]"
|
echo "usage: $0 command [filename]"
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
# Manages the creation of the text file and the parsing to html file
|
# Manages the creation of the text file and the parsing to html file
|
||||||
# also the drafts
|
# also the drafts
|
||||||
|
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
declare global_url
|
declare global_url
|
||||||
declare convert_filename
|
declare convert_filename
|
||||||
|
|
||||||
write_entry() {
|
write_entry() {
|
||||||
f=$2
|
f=$2
|
||||||
if [[ -n $f ]]; then
|
if [[ -n $f ]]; then
|
||||||
|
@ -14,10 +16,9 @@ write_entry() {
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
TMPFILE=.entry-$RANDOM.$fmt
|
TMPFILE=.entry-$RANDOM.md
|
||||||
echo -e "Title on this line\n" >> "$TMPFILE"
|
echo -e "Title on this line\n" >>"$TMPFILE"
|
||||||
|
cat <<EOF >>"$TMPFILE"
|
||||||
cat << EOF >> "$TMPFILE"
|
|
||||||
The rest of the text file is a **Markdown** blog post. The process will continue
|
The rest of the text file is a **Markdown** blog post. The process will continue
|
||||||
as soon as you exit your editor.
|
as soon as you exit your editor.
|
||||||
|
|
||||||
|
@ -33,12 +34,10 @@ EOF
|
||||||
|
|
||||||
$EDITOR "$TMPFILE"
|
$EDITOR "$TMPFILE"
|
||||||
|
|
||||||
html_from_md=$(mrkdwn "$TMPFILE")
|
html_from_md=$(make_html "$TMPFILE")
|
||||||
|
parse_file "$html_from_md"
|
||||||
parse_file "$html_from_md"
|
|
||||||
rm "$html_from_md"
|
rm "$html_from_md"
|
||||||
|
|
||||||
|
|
||||||
chmod 644 "$filename"
|
chmod 644 "$filename"
|
||||||
[[ -n $preview_url ]] || preview_url=$global_url
|
[[ -n $preview_url ]] || preview_url=$global_url
|
||||||
echo "To preview the entry, open $preview_url/$filename in your browser"
|
echo "To preview the entry, open $preview_url/$filename in your browser"
|
||||||
|
@ -61,7 +60,7 @@ EOF
|
||||||
[[ -n $convert_filename ]] && title=$(echo "$title" | eval "$convert_filename")
|
[[ -n $convert_filename ]] && title=$(echo "$title" | eval "$convert_filename")
|
||||||
[[ -n $title ]] || title=$RANDOM
|
[[ -n $title ]] || title=$RANDOM
|
||||||
|
|
||||||
draft=drafts/$title.$fmt
|
draft=drafts/$title.md
|
||||||
mv "$TMPFILE" "$draft"
|
mv "$TMPFILE" "$draft"
|
||||||
chmod 600 "$draft"
|
chmod 600 "$draft"
|
||||||
rm "$filename"
|
rm "$filename"
|
||||||
|
@ -80,4 +79,4 @@ EOF
|
||||||
relevant_posts="$(posts_with_tags $relevant_tags) $filename"
|
relevant_posts="$(posts_with_tags $relevant_tags) $filename"
|
||||||
rebuild_tags "$relevant_posts" "$relevant_tags"
|
rebuild_tags "$relevant_posts" "$relevant_tags"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
# A First Level Header
|
||||||
|
|
||||||
|
## A Second Level Header
|
||||||
|
|
||||||
|
Now is the time for all good men to come to
|
||||||
|
the aid of their country. This is just a
|
||||||
|
regular paragraph.
|
||||||
|
|
||||||
|
The quick brown fox jumped over the lazy
|
||||||
|
dog's back.
|
||||||
|
|
||||||
|
### Header 3
|
||||||
|
|
||||||
|
> This is a blockquote.
|
||||||
|
>
|
||||||
|
> This is the second paragraph in the blockquote. This is the second paragraph in the blockquote. This is the second paragraph in the blockquote.
|
||||||
|
>
|
||||||
|
> This is a test
|
||||||
|
>
|
||||||
|
>> Blockcode level2
|
||||||
|
>>
|
||||||
|
>> level2
|
||||||
|
|
||||||
|
Some of these words *are emphasized*.
|
||||||
|
Some of these words _are emphasized also_.
|
||||||
|
|
||||||
|
Use two asterisks for **strong emphasis**.
|
||||||
|
Or, if you prefer, __use two underscores instead__.
|
||||||
|
|
||||||
|
* Candy.
|
||||||
|
* Gum.
|
||||||
|
* Booze.
|
||||||
|
|
||||||
|
1. Candy.
|
||||||
|
2. Gum.
|
||||||
|
3. Booze.
|
||||||
|
|
||||||
|
- Candy.
|
||||||
|
- Gum.
|
||||||
|
- Booze.
|
||||||
|
|
||||||
|
1. Red
|
||||||
|
2. Green
|
||||||
|
3. Blue
|
||||||
|
|
||||||
|
* A list item.
|
||||||
|
|
||||||
|
With multiple paragraphs.
|
||||||
|
|
||||||
|
* Another item in the list.
|
||||||
|
|
||||||
|
|
||||||
|
This is an [example link](http://example.com/).
|
||||||
|
|
||||||
|
|
||||||
|
This is an [example link](http://example.com/ "With a Title").
|
||||||
|
|
||||||
|
|
||||||
|
I get 10 times more traffic from [Google][1] than from
|
||||||
|
[Yahoo][2] or [MSN][3].
|
||||||
|
|
||||||
|
[1]: http://google.com/ "Google"
|
||||||
|
[2]: http://search.yahoo.com/ "Yahoo Search"
|
||||||
|
[3]: http://search.msn.com/ "MSN Search"
|
||||||
|
|
||||||
|
I start my morning with a cup of coffee and
|
||||||
|
[The New York Times][NY Times].
|
||||||
|
|
||||||
|
[ny times]: http://www.nytimes.com/
|
||||||
|
|
||||||
|
|
||||||
|
![alt text](/path/to/img.jpg "Title")
|
||||||
|
|
||||||
|
|
||||||
|
![alt text][id]
|
||||||
|
|
||||||
|
[id]: /path/to/img.jpg "Title"
|
||||||
|
|
||||||
|
|
||||||
|
I strongly recommend against using any `<blink>` tags.
|
||||||
|
|
||||||
|
I wish SmartyPants used named entities like `—`
|
||||||
|
instead of decimal-encoded entites like `—`.
|
15
tildelog.sh
15
tildelog.sh
|
@ -1,12 +1,18 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
# TildeLog, a not-so-simple blog/gemlog/phlog system made for tilde.team
|
# TildeLog, a not-so-simple blog/gemlog/phlog system made for tilde.team
|
||||||
# By Josemar Lohn <j@lo.hn>
|
# By Josemar Lohn <j@lo.hn>
|
||||||
#
|
#
|
||||||
# Heavily based on BashBlog, by Carlos Fenollosa <carlos.fenollosa@gmail.com>
|
# Heavily based on BashBlog, by Carlos Fenollosa <carlos.fenollosa@gmail.com>
|
||||||
|
|
||||||
### BEGIN SOURCEFILES -> DO NOT REMOVE THIS LINE
|
md2html_awk=$(<lib/md2html.awk)
|
||||||
|
md2gemini_awk=$(<lib/md2gemini.awk)
|
||||||
|
md2gopher_awk=$(<lib/md2gopher.awk)
|
||||||
|
|
||||||
|
### BEGIN SOURCEFILES -> DO NOT REMOVE THIS LINE
|
||||||
source ./lib/all_posts.sh
|
source ./lib/all_posts.sh
|
||||||
source ./lib/all_tags.sh
|
source ./lib/all_tags.sh
|
||||||
source ./lib/create_css.sh
|
source ./lib/create_css.sh
|
||||||
|
@ -26,7 +32,7 @@ source ./lib/list_tags.sh
|
||||||
source ./lib/make_gemini.sh
|
source ./lib/make_gemini.sh
|
||||||
source ./lib/make_gophermap.sh
|
source ./lib/make_gophermap.sh
|
||||||
source ./lib/make_rss.sh
|
source ./lib/make_rss.sh
|
||||||
source ./lib/mrkdwn.sh
|
source ./lib/make_html.sh
|
||||||
source ./lib/parse_file.sh
|
source ./lib/parse_file.sh
|
||||||
source ./lib/posts_with_tags.sh
|
source ./lib/posts_with_tags.sh
|
||||||
source ./lib/rebuild_all_entries.sh
|
source ./lib/rebuild_all_entries.sh
|
||||||
|
@ -34,7 +40,6 @@ source ./lib/rebuild_index.sh
|
||||||
source ./lib/rebuild_tags.sh
|
source ./lib/rebuild_tags.sh
|
||||||
source ./lib/reset.sh
|
source ./lib/reset.sh
|
||||||
source ./lib/tags_in_post.sh
|
source ./lib/tags_in_post.sh
|
||||||
source ./lib/test_markdown.sh
|
|
||||||
source ./lib/twitter_card.sh
|
source ./lib/twitter_card.sh
|
||||||
source ./lib/usage.sh
|
source ./lib/usage.sh
|
||||||
source ./lib/write_entry.sh
|
source ./lib/write_entry.sh
|
||||||
|
@ -47,4 +52,4 @@ source ./lib/write_entry.sh
|
||||||
#
|
#
|
||||||
do_main "$@"
|
do_main "$@"
|
||||||
|
|
||||||
# vim: set shiftwidth=4 tabstop=4 expandtab:
|
# vim: set shiftwidth=4 tabstop=4 expandtab:
|
||||||
|
|
Loading…
Reference in New Issue