Fixed variables problem and removed html edit.
This commit is contained in:
parent
26468aec34
commit
e6161e9717
|
@ -1,6 +1,7 @@
|
||||||
#!/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
|
||||||
|
|
|
@ -23,7 +23,7 @@ do_main() {
|
||||||
|
|
||||||
# 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" ]] &&
|
||||||
|
|
12
lib/edit.sh
12
lib/edit.sh
|
@ -12,12 +12,14 @@
|
||||||
# "keep" to keep old filename
|
# "keep" to keep old filename
|
||||||
# "full" to edit full HTML, and not only text part (keeps old filename)
|
# "full" to edit full HTML, and not only text part (keeps old filename)
|
||||||
# leave empty for default behavior (edit only text part and change name)
|
# leave empty for default behavior (edit only text part and change name)
|
||||||
edit() {
|
|
||||||
declare date_format_full
|
declare date_format_full
|
||||||
declare date_format_timestamp
|
declare date_format_timestamp
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
declare prefix_tags
|
declare prefix_tags
|
||||||
[[ ! -f "${1%%.*}.html" ]] && \
|
edit() {
|
||||||
|
|
||||||
|
[[ ! -f "${1%%.*}.html" ]] &&
|
||||||
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
|
||||||
|
@ -29,13 +31,9 @@ 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
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
# $3 "cut" to remove text from <hr /> to <!-- text end -->
|
# $3 "cut" to remove text from <hr /> to <!-- text end -->
|
||||||
# note that this does not remove <hr /> line itself,
|
# note that this does not remove <hr /> line itself,
|
||||||
# so you can see if text was cut or not
|
# so you can see if text was cut or not
|
||||||
get_html_file_content() {
|
|
||||||
declare cut_line cut_tags
|
declare cut_line cut_tags
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
|
get_html_file_content() {
|
||||||
awk "/<!-- $1 begin -->/, /<!-- $2 end -->/{
|
awk "/<!-- $1 begin -->/, /<!-- $2 end -->/{
|
||||||
if (!/<!-- $1 begin -->/ && !/<!-- $2 end -->/) print
|
if (!/<!-- $1 begin -->/ && !/<!-- $2 end -->/) print
|
||||||
if (\"$3\" == \"cut\" && /$cut_line/){
|
if (\"$3\" == \"cut\" && /$cut_line/){
|
||||||
|
|
|
@ -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,7 +13,6 @@ 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
|
||||||
|
@ -32,7 +31,6 @@ 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_"
|
||||||
|
@ -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
|
||||||
}
|
}
|
|
@ -8,9 +8,6 @@
|
||||||
#
|
#
|
||||||
# Return 0 (bash return value 'true') if the input file is an index, feed, etc
|
# Return 0 (bash return value 'true') if the input file is an index, feed, etc
|
||||||
# or 1 (bash return value 'false') if it is a blogpost
|
# or 1 (bash return value 'false') if it is a blogpost
|
||||||
is_boilerplate_file() {
|
|
||||||
return 1 ### Ugly Hack to Temporally disable the verification
|
|
||||||
|
|
||||||
declare non_blogpost_files
|
declare non_blogpost_files
|
||||||
declare index_file
|
declare index_file
|
||||||
declare archive_index
|
declare archive_index
|
||||||
|
@ -21,6 +18,7 @@ is_boilerplate_file() {
|
||||||
declare header_file
|
declare header_file
|
||||||
declare prefix_tags
|
declare prefix_tags
|
||||||
declare html_exclude
|
declare html_exclude
|
||||||
|
is_boilerplate_file() {
|
||||||
name=${1#./}
|
name=${1#./}
|
||||||
# First check against user-defined non-blogpost pages
|
# First check against user-defined non-blogpost pages
|
||||||
for item in "${non_blogpost_files[@]}"; do
|
for item in "${non_blogpost_files[@]}"; do
|
||||||
|
@ -28,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
|
;;
|
||||||
|
*) # Check for excluded
|
||||||
for excl in "${html_exclude[@]}"; do
|
for excl in "${html_exclude[@]}"; do
|
||||||
[[ $name == "$excl" ]] && return 0
|
[[ $name == "$excl" ]] && return 0
|
||||||
done
|
done
|
||||||
return 1 ;;
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
|
@ -3,10 +3,12 @@
|
||||||
# Displays a list of the tags
|
# Displays a list of the tags
|
||||||
#
|
#
|
||||||
# $2 if "-n", tags will be sorted by number of posts
|
# $2 if "-n", tags will be sorted by number of posts
|
||||||
list_tags() {
|
|
||||||
declare prefix_tags
|
declare prefix_tags
|
||||||
declare template_tags_posts_singular
|
declare template_tags_posts_singular
|
||||||
declare template_tags_posts
|
declare template_tags_posts
|
||||||
|
|
||||||
|
list_tags() {
|
||||||
if [[ $2 == -n ]]; then do_sort=1; else do_sort=0; fi
|
if [[ $2 == -n ]]; then do_sort=1; else do_sort=0; fi
|
||||||
|
|
||||||
if ls "./${prefix_tags}"*.html >/dev/null; then
|
if ls "./${prefix_tags}"*.html >/dev/null; then
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
make_gemini() {
|
|
||||||
declare gemini_index
|
declare gemini_index
|
||||||
|
|
||||||
|
make_gemini() {
|
||||||
|
return
|
||||||
if [ ! -d "${HOME}/public_gemini" ]; then
|
if [ ! -d "${HOME}/public_gemini" ]; then
|
||||||
printf "Creating ~/public_gemini\\n"
|
printf "Creating ~/public_gemini\\n"
|
||||||
mkdir "${HOME}/public_gemini"
|
mkdir "${HOME}/public_gemini"
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
make_gophermap() {
|
|
||||||
declare gophermap
|
declare gophermap
|
||||||
|
|
||||||
|
make_gophermap() {
|
||||||
|
return
|
||||||
if [ ! -d "${HOME}/public_gopher" ]; then
|
if [ ! -d "${HOME}/public_gopher" ]; then
|
||||||
printf "Creating gopher hole\\n"
|
printf "Creating gopher hole\\n"
|
||||||
mkdir "${HOME}/public_gopher"
|
mkdir "${HOME}/public_gopher"
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Generate the feed file
|
# Generate the feed file
|
||||||
make_rss() {
|
|
||||||
declare blog_feed
|
declare blog_feed
|
||||||
declare date_format_full
|
declare date_format_full
|
||||||
declare global_title
|
declare global_title
|
||||||
|
@ -10,6 +9,8 @@ make_rss() {
|
||||||
declare index_file
|
declare index_file
|
||||||
declare number_of_feed_articles
|
declare number_of_feed_articles
|
||||||
declare cut_do
|
declare cut_do
|
||||||
|
make_rss() {
|
||||||
|
|
||||||
echo -n "Making RSS "
|
echo -n "Making RSS "
|
||||||
|
|
||||||
rssfile=$blog_feed.$RANDOM
|
rssfile=$blog_feed.$RANDOM
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/awk -f
|
#!/usr/bin/awk -f
|
||||||
#
|
#
|
||||||
# by: Josemar Lohn <j@lo.hn>
|
# by: Josemar Lohn <j@lo.hn>
|
||||||
# lo.hn on www/gemini/gopher
|
# lo.hn on www/gemini/gopher
|
|
@ -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"
|
|
||||||
}
|
|
|
@ -8,11 +8,13 @@
|
||||||
# note that although timestamp is optional, something must be provided at its
|
# note that although timestamp is optional, something must be provided at its
|
||||||
# place if destination file name is provided, i.e:
|
# place if destination file name is provided, i.e:
|
||||||
# parse_file source.txt "" destination.html
|
# parse_file source.txt "" destination.html
|
||||||
parse_file() {
|
|
||||||
declare convert_filename
|
declare convert_filename
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
declare prefix_tags
|
declare prefix_tags
|
||||||
declare global_author
|
declare global_author
|
||||||
|
|
||||||
|
parse_file() {
|
||||||
# Read for the title and check that the filename is ok
|
# Read for the title and check that the filename is ok
|
||||||
title=""
|
title=""
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
# Finds all posts referenced in a number of tags.
|
# Finds all posts referenced in a number of tags.
|
||||||
# Arguments are tags
|
# Arguments are tags
|
||||||
# Prints one line with space-separated tags to stdout
|
# Prints one line with space-separated tags to stdout
|
||||||
|
|
||||||
|
declare prefix_tags
|
||||||
|
|
||||||
posts_with_tags() {
|
posts_with_tags() {
|
||||||
(($# < 1)) && return
|
(($# < 1)) && return
|
||||||
set -- "${@/#/$prefix_tags}"
|
set -- "${@/#/$prefix_tags}"
|
||||||
|
|
|
@ -2,14 +2,17 @@
|
||||||
|
|
||||||
# Regenerates all the single post entries, keeping the post content but modifying
|
# Regenerates all the single post entries, keeping the post content but modifying
|
||||||
# the title, html structure, etc
|
# the title, html structure, etc
|
||||||
rebuild_all_entries() {
|
|
||||||
declare date_inpost
|
declare date_inpost
|
||||||
declare date_format_full
|
declare date_format_full
|
||||||
declare date_format_timestamp
|
declare date_format_timestamp
|
||||||
|
|
||||||
|
rebuild_all_entries() {
|
||||||
|
|
||||||
echo -n "Rebuilding all entries "
|
echo -n "Rebuilding all entries "
|
||||||
|
|
||||||
for i in ./*.html; do
|
for i in ./*.html; do
|
||||||
is_boilerplate_file "$i" && continue;
|
is_boilerplate_file "$i" && continue
|
||||||
contentfile=.tmp.$RANDOM
|
contentfile=.tmp.$RANDOM
|
||||||
while [[ -f $contentfile ]]; do contentfile=.tmp.$RANDOM; done
|
while [[ -f $contentfile ]]; do contentfile=.tmp.$RANDOM; done
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Generate the index.html with the content of the latest posts
|
# Generate the index.html with the content of the latest posts
|
||||||
rebuild_index() {
|
|
||||||
declare index_file
|
declare index_file
|
||||||
declare number_of_index_articles
|
declare number_of_index_articles
|
||||||
declare cut_do
|
declare cut_do
|
||||||
|
@ -16,6 +16,8 @@ rebuild_index() {
|
||||||
declare global_title
|
declare global_title
|
||||||
declare archive_index
|
declare archive_index
|
||||||
declare tags_index
|
declare tags_index
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -28,7 +30,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"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# example:
|
# example:
|
||||||
# rebuild_tags "one_post.html another_article.html" "example-tag another-tag"
|
# rebuild_tags "one_post.html another_article.html" "example-tag another-tag"
|
||||||
# mind the quotes!
|
# mind the quotes!
|
||||||
rebuild_tags() {
|
|
||||||
declare prefix_tags
|
declare prefix_tags
|
||||||
declare cut_do
|
declare cut_do
|
||||||
declare cut_line
|
declare cut_line
|
||||||
|
@ -17,6 +17,8 @@ rebuild_tags() {
|
||||||
declare template_tag_title
|
declare template_tag_title
|
||||||
declare global_title
|
declare global_title
|
||||||
declare global_author
|
declare global_author
|
||||||
|
|
||||||
|
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)
|
||||||
|
@ -42,7 +44,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"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/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
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
# Finds all tags referenced in one post.
|
# Finds all tags referenced in one post.
|
||||||
# Accepts either filename as first argument, or post content at stdin
|
# Accepts either filename as first argument, or post content at stdin
|
||||||
# Prints one line with space-separated tags to stdout
|
# Prints one line with space-separated tags to stdout
|
||||||
tags_in_post() {
|
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
|
|
||||||
|
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,7 +4,7 @@
|
||||||
#
|
#
|
||||||
# $1 the post file
|
# $1 the post file
|
||||||
# $2 the title
|
# $2 the title
|
||||||
twitter_card() {
|
|
||||||
declare global_twitter_username
|
declare global_twitter_username
|
||||||
declare template_tags_line_header
|
declare template_tags_line_header
|
||||||
declare global_url
|
declare global_url
|
||||||
|
@ -12,6 +12,9 @@ twitter_card() {
|
||||||
declare template_twitter_button
|
declare template_twitter_button
|
||||||
declare template_twitter_comment
|
declare template_twitter_comment
|
||||||
declare template_comments
|
declare template_comments
|
||||||
|
|
||||||
|
twitter_card() {
|
||||||
|
|
||||||
[[ -z $global_twitter_username ]] && return
|
[[ -z $global_twitter_username ]] && return
|
||||||
|
|
||||||
echo "<meta name='twitter:card' content='summary'>"
|
echo "<meta name='twitter:card' content='summary'>"
|
||||||
|
@ -38,9 +41,9 @@ 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\""
|
||||||
|
|
|
@ -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,25 +2,27 @@
|
||||||
|
|
||||||
# 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
|
||||||
extension=${f##*.}
|
extension=${f##*.}
|
||||||
if [[ $extension != md ]]; then
|
if [[ $extension != md ]]; then
|
||||||
f=${f}.md
|
f=${f}.md
|
||||||
fi
|
fi
|
||||||
if [[ -n $f ]]; thenq
|
|
||||||
if [[ -f $f ]]; then
|
if [[ -f $f ]]; then
|
||||||
echo "The file $f doesn't exist"
|
echo "The file $f doesn't exist"
|
||||||
delete_includes
|
delete_includes
|
||||||
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.
|
||||||
|
@ -37,12 +39,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"
|
||||||
|
@ -65,7 +65,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"
|
||||||
|
|
11
tildelog.sh
11
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
|
||||||
|
|
Loading…
Reference in New Issue