Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generatePostHtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# $1 = Input file
# $2 = Post ID
if [[ $# < 2 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
if [[ $# -lt 2 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 <path-to-post> <post-id>"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion getPostTitle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

#STDIN = post content
head -n 1 | sed -r 's/^#+//g'
head -n 1 | sed -r 's/^[# ]+//g'
4 changes: 2 additions & 2 deletions idUnpublish
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash

if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 <post-id>"
exit 1
fi

postid="$1"

echo -n "Unpublish $postid? [y/N] "
read confirm
read -r confirm
if [[ "$confirm" = "y" ]]; then
rm "public/posts/$postid.html"
rm "source/post_date/$postid"
Expand Down
7 changes: 3 additions & 4 deletions makeIndex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 <num-posts>"
exit 1
fi
Expand All @@ -16,10 +16,9 @@ function postList() {
#Get post list in reverse order and retrieve the last $indexLength posts
#Generates HTML for them with the title and blurbs
#Then removes the last two lines of the output to delete the extra <hr/>
cat source/post_list \
| perl -e 'print reverse <>' \
perl -e 'print reverse <>' < source/post_list \
| head -n "$indexLength" \
| while read postid; do
| while read -r postid; do
#Escape single quotes
link="$(echo "posts/$postid.html" | sed "s/'/\\&#39;/g")"
echo "
Expand Down
18 changes: 9 additions & 9 deletions publish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 <path-to-post>"
exit 1
fi
Expand Down Expand Up @@ -31,7 +31,7 @@ blurb="$(tail -n +2 < "$file" \
date="$(date '+%b %d, %Y')"

#Replace spaces with dashes in the title, and lowercase it
postid="$(echo $title | ./getPostID)"
postid="$(echo "$title" | ./getPostID)"

echo "ID: $postid"
echo "Title: $title"
Expand All @@ -40,28 +40,28 @@ echo ""

if grep "$postid" "source/post_list" &> /dev/null; then
echo -n "Post exists with ID '$postid'. Update post? [y/N] "
read confirm_post
read -r confirm_post
if [[ "$confirm_post" != "y" ]]; then
exit 1
fi
else
echo -n "Are you sure you want to post '$title'? [y/N] "
read confirm_post
read -r confirm_post
if [[ "$confirm_post" != "y" ]]; then
exit 1
else
echo -n $title > "source/post_title/$postid"
echo -n $date > "source/post_date/$postid"
echo $postid >> "source/post_list"
echo -n "$title" > "source/post_title/$postid"
echo -n "$date" > "source/post_date/$postid"
echo "$postid" >> "source/post_list"
fi
fi

#Regenerate blurb when editing posts
echo -n $blurb > "source/post_blurb/$postid"
echo -n "$blurb" > "source/post_blurb/$postid"
./generatePostHtml "$file" "$postid"

POST="source/post_content/$postid.html" \
TITLE="$title"
TITLE="$title" \
./makePost > "./public/posts/$postid.html"

./makeIndices
4 changes: 2 additions & 2 deletions regenPosts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
find ./posts -type f \
| while read postfile; do
| while read -r postfile; do
title="$(./getPostTitle < "$postfile")"
postid="$(echo $title | ./getPostID)"
postid="$(echo "$title" | ./getPostID)"
if grep "$postid" "source/post_list" &> /dev/null; then
echo "Regenerating $postid"
./generatePostHtml "$postfile" "$postid"
Expand Down
4 changes: 2 additions & 2 deletions unpublish
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 <path-to-post>"
exit 1
fi

title="$(./getPostTitle < "$1")"
postid="$(echo $title | ./getPostID)"
postid="$(echo "$title" | ./getPostID)"
./unpublish "$postid"