diff --git a/bob b/bob index 1768d97..f11ba75 100755 --- a/bob +++ b/bob @@ -35,10 +35,10 @@ _get_blog_lang() _add_header() { - post_name=$1 - lang=$2 - dark=$3 + blog_name=$2 + lang=$3 + dark=$4 css="../css/poststyle.css" if [[ $dark =~ "y" ]]; then @@ -57,6 +57,9 @@ _add_header()
+
+

$blog_name

+
EOF } @@ -66,6 +69,7 @@ _add_footer() cat >> ./posts/$post_name.html << EOF
@@ -114,7 +118,7 @@ publish() # Append the names to the array posts_names+=(${BASH_REMATCH[1]}) fi - _create_posts "./drafts/${list[i]}" "$lang" "$dark" + _create_posts "./drafts/${list[i]}" "$blog_name" "$lang" "$dark" done # function to update the index.html @@ -125,15 +129,16 @@ publish() _create_posts() { draft=$1 - lang=$2 - dark=$3 + blog_name=$2 + lang=$3 + dark=$4 # Convert the markdown file $draft into html # and store the result in $content content=`multimarkdown --nolabels $draft` # Regex to extract the simple post name - md_regex="([a-zA-Z]+)\.(md|markdown)" + md_regex="([a-zA-Z\-]+)\.(md|markdown)" if [[ $draft =~ $md_regex ]]; then # If the file have md or markdown extension, cut it @@ -142,9 +147,8 @@ _create_posts() # if not and it has no extension, keep it this way post_name=$draft fi - # Integrate the html converted content into a proper html file - _build_post "$post_name" "$content" "$lang" "$dark" + _build_post "$post_name" "$blog_name" "$content" "$lang" "$dark" } _build_post() @@ -152,11 +156,12 @@ _build_post() # Create the html file of the post $post_name with the # previsouly converted markdown to html $content post_name=$1 - content=$2 - lang=$3 - dark=$4 + blog_name=$2 + content=$3 + lang=$4 + dark=$5 - _add_header "$post_name" "$lang" "$dark" + _add_header "$post_name" "$blog_name" "$lang" "$dark" echo $content >> ./posts/$post_name.html _add_footer "$post_name" } @@ -201,7 +206,7 @@ then fi # Regex to extract just the name of the post -post_regex="([a-zA-Z]+)\.md" +post_regex="([a-zA-Z\-]+)\.(md|markdown)" for (( i=0; i<${#drafts_list[@]}; i++ )); do @@ -240,6 +245,7 @@ _add_post_link() url=$1 post_name=$2 date=$3 + post_name=${post_name//\-/ } echo "
  • " >> index.html echo "$post_name" >> index.html echo "$date" >> index.html @@ -361,11 +367,27 @@ cat > ./css/poststyle.css << EOF body { font-family: 'IBM Plex Mono', monospace; } +header a { + text-decoration: none; +} +header a:hover { + text-decoration: underline; +} +header { + margin-bottom: 6vh; +} .post { width: 70vw; margin-right: auto; margin-left: auto; } +footer { + width: 70vw; + margin-top: 6vh; + margin-right: auto; + margin-left: auto; + font-size: 1.3vh; +} EOF cat > ./css/poststyle.dark.css << EOF @@ -374,11 +396,29 @@ body { background: #222; color: #e1e1e1; } +header a { + color: #777; + text-decoration: none; +} +header a:hover { + text-decoration: underline; + color: #e1e1e1; +} +header { + margin-bottom: 6vh; +} .post { width: 70vw; margin-right: auto; margin-left: auto; } +footer { + width: 70vw; + margin-top: 6vh; + margin-right: auto; + margin-left: auto; + font-size: 1.3vh; +} EOF } @@ -419,6 +459,12 @@ change_mode() delete_posts() { + # posts=`ls ./posts/` + # echo $posts/ + # if [ "$posts" == "/" ]; then + # echo empty + # fi + rm ./posts/*.html } @@ -447,28 +493,38 @@ usage() echo " -l change the language of the blog (not implemented yet)" } -while getopts ":ihpdm" opt; do - case ${opt} in - i ) - init - ;; - p ) - publish - ;; - h ) - usage - ;; - m ) - change_mode - ;; - d ) - delete_posts - ;; - \? ) - usage - ;; - : ) - usage - ;; - esac -done +# while getopts ":ihpdm" opt; do +# case ${opt} in +# i ) +# init +# ;; +# p ) +# publish +# ;; +# h ) +# usage +# ;; +# m ) +# change_mode +# ;; +# d ) +# delete_posts +# ;; +# \? ) +# usage +# ;; +# : ) +# usage +# ;; +# esac +# done + +if [[ $# -eq 0 ]]; then + usage +elif [[ "$1" == "init" ]]; then + init +elif [[ "$1" == "publish" ]]; then + publish +elif [[ "$1" == "help" ]]; then + usage +fi