Compare commits
2 Commits
ff37a61556
...
3ed87d6bc6
Author | SHA1 | Date |
---|---|---|
Josemar Lohn | 3ed87d6bc6 | |
Josemar Lohn | e12648d054 |
|
@ -47,6 +47,8 @@ create_html_page() {
|
|||
|
||||
file_url=${filename#./}
|
||||
file_url=${file_url%.rebuilt} # Get the correct URL when rebuilding
|
||||
file_url=${file_url%.html}
|
||||
file_url=${file_url%.md}.html # Get the correct link
|
||||
# one blog entry
|
||||
if [[ $index == no ]]; then
|
||||
echo '<!-- entry begin -->' # marks the beginning of the whole post
|
||||
|
|
|
@ -77,7 +77,10 @@ do_main() {
|
|||
all_posts
|
||||
all_tags
|
||||
make_rss
|
||||
echo 'making gophermap'
|
||||
make_gophermap
|
||||
echo 'making geminicapsule'
|
||||
make_gemini
|
||||
echo 'deleting includes'
|
||||
delete_includes
|
||||
}
|
||||
|
|
|
@ -12,14 +12,13 @@
|
|||
# "keep" to keep 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)
|
||||
|
||||
declare date_format_full
|
||||
declare date_format_timestamp
|
||||
declare template_tags_line_header
|
||||
declare prefix_tags
|
||||
edit() {
|
||||
|
||||
[[ ! -f "${1%%.*}.html" ]] &&
|
||||
[[ ! -f "${1%%.*}.html" ]] && \
|
||||
printf "Can't edit post \"%s.html\", did you mean to use \"bb.sh post <draft_file>\"?\\n" "${1%%.*}" && exit 1
|
||||
|
||||
# Original post timestamp
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
# $3 "cut" to remove text from <hr /> to <!-- text end -->
|
||||
# note that this does not remove <hr /> line itself,
|
||||
# so you can see if text was cut or not
|
||||
declare cut_line cut_tags
|
||||
declare cut_line
|
||||
declare cut_tags
|
||||
declare template_tags_line_header
|
||||
get_html_file_content() {
|
||||
awk "/<!-- $1 begin -->/, /<!-- $2 end -->/{
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
# Return the post author
|
||||
#
|
||||
# $1 the html file
|
||||
declare global_author
|
||||
get_post_author() {
|
||||
awk '/<div class="subtitle">.+/, /<!-- text begin -->/{if (!/<div class="subtitle">.+/ && !/<!-- text begin -->/) print}' "$1" | sed 's/<\/div>//g'
|
||||
# awk '/<div class="subtitle">.+/, /<!-- text begin -->/{if (!/<div class="subtitle">.+/ && !/<!-- text begin -->/) print}' "$1" | sed 's/<\/div>//g'
|
||||
echo $global_author
|
||||
}
|
|
@ -3,16 +3,14 @@
|
|||
# Displays a list of the tags
|
||||
#
|
||||
# $2 if "-n", tags will be sorted by number of posts
|
||||
|
||||
declare prefix_tags
|
||||
declare template_tags_posts_singular
|
||||
declare template_tags_posts
|
||||
|
||||
list_tags() {
|
||||
list_tags() {
|
||||
if [[ $2 == -n ]]; then do_sort=1; else do_sort=0; fi
|
||||
|
||||
if ls "./${prefix_tags}"*.html >/dev/null; then
|
||||
echo "No posts yet. Use 'bb.sh post' to create one" && return
|
||||
if ls "./${prefix_tags}"*.html > /dev/null; then
|
||||
echo "No posts yet. Use '$0 post' to create one" && return
|
||||
fi
|
||||
|
||||
lines=""
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
declare gemini_index
|
||||
|
||||
make_gemini() {
|
||||
return
|
||||
|
||||
if [ ! -d "${HOME}/public_gemini" ]; then
|
||||
printf "Creating ~/public_gemini\\n"
|
||||
mkdir "${HOME}/public_gemini"
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
declare gophermap
|
||||
|
||||
make_gophermap() {
|
||||
return
|
||||
if [ ! -d "${HOME}/public_gopher" ]; then
|
||||
printf "Creating gopher hole\\n"
|
||||
mkdir "${HOME}/public_gopher"
|
||||
|
@ -25,5 +22,5 @@ make_gophermap() {
|
|||
EOF
|
||||
chmod +x "${HOME}/public_html/blog/${gophermap}"
|
||||
fi
|
||||
chmod 644 "./*.md"
|
||||
chmod 644 ./*.md
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ declare index_file
|
|||
declare number_of_feed_articles
|
||||
declare cut_do
|
||||
make_rss() {
|
||||
|
||||
|
||||
echo -n "Making RSS "
|
||||
|
||||
rssfile=$blog_feed.$RANDOM
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
# Based on md2html by Jesus Galan (yiyus) 2009
|
||||
#
|
||||
#
|
||||
# Usage: md2gemini.awk file.md > file.html
|
||||
# Usage: md2gemini.awk file.md > file.gmi
|
||||
|
||||
1
|
|
@ -6,7 +6,7 @@
|
|||
# Based on md2html by Jesus Galan (yiyus) 2009
|
||||
#
|
||||
#
|
||||
# Usage: md2gopher.awk file.md > file.html
|
||||
# Usage: md2gopher.awk file.md > file.txt
|
||||
|
||||
function eschtml(t) {
|
||||
#gsub("&", "\\&", t);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/awk -f
|
||||
#
|
||||
# by: Josemar Lohn <j@lo.hn>
|
||||
# lo.hn on www/gemini/gopher
|
||||
# by: Jesus Galan (yiyus) 2009
|
||||
#
|
||||
# Based on md2html by Jesus Galan (yiyus) 2009
|
||||
# Updated By Josemar Lohn <j@lo.hn>
|
||||
# lo.hn on www/gemini/gopher
|
||||
#
|
||||
#
|
||||
# Usage: md2html.awk file.md > file.html
|
||||
|
|
|
@ -8,12 +8,10 @@
|
|||
# note that although timestamp is optional, something must be provided at its
|
||||
# place if destination file name is provided, i.e:
|
||||
# parse_file source.txt "" destination.html
|
||||
|
||||
declare convert_filename
|
||||
declare template_tags_line_header
|
||||
declare prefix_tags
|
||||
declare global_author
|
||||
|
||||
parse_file() {
|
||||
# Read for the title and check that the filename is ok
|
||||
title=""
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
# Finds all posts referenced in a number of tags.
|
||||
# Arguments are tags
|
||||
# Prints one line with space-separated tags to stdout
|
||||
|
||||
declare prefix_tags
|
||||
|
||||
posts_with_tags() {
|
||||
(($# < 1)) && return
|
||||
set -- "${@/#/$prefix_tags}"
|
||||
|
|
|
@ -2,39 +2,60 @@
|
|||
|
||||
# Regenerates all the single post entries, keeping the post content but modifying
|
||||
# the title, html structure, etc
|
||||
|
||||
declare date_inpost
|
||||
#declare date_inpost
|
||||
declare date_format_full
|
||||
declare date_format_timestamp
|
||||
|
||||
declare markdown_bin
|
||||
declare template_tags_line_header
|
||||
declare prefix_tags
|
||||
rebuild_all_entries() {
|
||||
|
||||
echo -n "Rebuilding all entries "
|
||||
|
||||
for i in ./*.html; do
|
||||
is_boilerplate_file "$i" && continue
|
||||
for i in ./*.md; do
|
||||
is_boilerplate_file "$i" && continue;
|
||||
contentfile=.tmp.$RANDOM
|
||||
while [[ -f $contentfile ]]; do contentfile=.tmp.$RANDOM; done
|
||||
|
||||
echo -n "."
|
||||
# Get the title and entry, and rebuild the html structure from scratch (divs, title, description...)
|
||||
title=$(get_post_title "$i")
|
||||
$markdown_bin <"$i" >> "$contentfile"
|
||||
|
||||
get_html_file_content 'text' 'text' <"$i" >>"$contentfile"
|
||||
|
||||
#Get Tags
|
||||
while IFS='' read -r line; do
|
||||
if [[ $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')
|
||||
IFS=, read -r -a array <<< "$tags"
|
||||
echo -n "<p>$template_tags_line_header " >> "${contentfile}.tmp"
|
||||
for item in "${array[@]}"; do
|
||||
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
|
||||
done | sed 's/, $/<\/p>/g' >> "${contentfile}.tmp"
|
||||
else
|
||||
echo "$line" >> "${contentfile}.tmp"
|
||||
fi
|
||||
done < "$contentfile"
|
||||
cp "${contentfile}" "$contentfile.old"
|
||||
mv "${contentfile}.tmp" "$contentfile"
|
||||
|
||||
# Read timestamp from post, if present, and sync file timestamp
|
||||
timestamp=$(awk '/<!-- '"$date_inpost"': .+ -->/ { print }' "$i" | cut -d '#' -f 2)
|
||||
[[ -n $timestamp ]] && touch -t "$timestamp" "$i"
|
||||
|
||||
#timestamp=$(awk '/<!-- '"$date_inpost"': .+ -->/ { print }' "$i" | cut -d '#' -f 2)
|
||||
#[[ -n $timestamp ]] && touch -t "$timestamp" "$i"
|
||||
|
||||
# Read timestamp from file in correct format for 'create_html_page'
|
||||
|
||||
timestamp=$(LC_ALL=C date -r "$i" +"$date_format_full")
|
||||
|
||||
create_html_page "$contentfile" "$i.rebuilt" no "$title" "$timestamp" "$(get_post_author "$i")"
|
||||
# keep the original timestamp!
|
||||
timestamp=$(LC_ALL=C date -r "$i" +"$date_format_timestamp")
|
||||
mv "$i.rebuilt" "$i"
|
||||
chmod 644 "$i"
|
||||
touch -t "$timestamp" "$i"
|
||||
rm "$contentfile"
|
||||
newfile=${i%.md}.html
|
||||
mv "$i.rebuilt" "$newfile"
|
||||
chmod 644 "$newfile"
|
||||
touch -t "$timestamp" "$newfile"
|
||||
#rm "$contentfile"
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Generate the index.html with the content of the latest posts
|
||||
|
||||
declare index_file
|
||||
declare number_of_index_articles
|
||||
declare cut_do
|
||||
|
@ -16,8 +15,8 @@ declare global_feedburner
|
|||
declare global_title
|
||||
declare archive_index
|
||||
declare tags_index
|
||||
|
||||
rebuild_index() {
|
||||
|
||||
echo -n "Rebuilding the index "
|
||||
newindexfile=$index_file.$RANDOM
|
||||
contentfile=$newindexfile.content
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
# example:
|
||||
# rebuild_tags "one_post.html another_article.html" "example-tag another-tag"
|
||||
# mind the quotes!
|
||||
|
||||
declare prefix_tags
|
||||
declare cut_do
|
||||
declare cut_line
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
# Finds all tags referenced in one post.
|
||||
# Accepts either filename as first argument, or post content at stdin
|
||||
# Prints one line with space-separated tags to stdout
|
||||
|
||||
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 ', ' ' '
|
||||
}
|
||||
|
|
|
@ -9,13 +9,8 @@ declare convert_filename
|
|||
|
||||
write_entry() {
|
||||
f=$2
|
||||
|
||||
if [[ -n $f ]]; then
|
||||
extension=${f##*.}
|
||||
if [[ $extension != md ]]; then
|
||||
f=${f}.md
|
||||
fi
|
||||
if [[ -f $f ]]; then
|
||||
if [[ ! -f $f ]]; then
|
||||
echo "The file $f doesn't exist"
|
||||
delete_includes
|
||||
exit
|
||||
|
|
|
@ -7,7 +7,7 @@ Describe 'do_main()'
|
|||
It 'Call function do_main without paramenters'
|
||||
When call do_main
|
||||
The line 1 of output should eq "You're not in your blog directory. Moving you there now"
|
||||
#The line 2 of output should eq "tildelog 0.1"
|
||||
The line 2 of output should eq "tildelog 0.1"
|
||||
#The line 3 of output should eq "usage: ./tildelog.sh command [filename]"
|
||||
End
|
||||
End
|
||||
|
|
Loading…
Reference in New Issue