X-Git-Url: https://git.danieliu.xyz/?p=pb.git;a=blobdiff_plain;f=pb;fp=pb;h=64972875d8d95ac5761e06ed23d5e44377fae8ab;hp=c3bee842fcc5d1c4232c7c4167545751b5d7abb2;hb=2a037724047c4f54023651b5bf81b4171356409e;hpb=8642e09f89ab92d4d883dd882629cf5d8abee83f diff --git a/pb b/pb index c3bee84..6497287 100755 --- a/pb +++ b/pb @@ -51,6 +51,8 @@ new() { sub() { cat - |\ + sed "1i " |\ + sed "\$a " |\ sed "s|{{TITLE}}|$1|g; s|{{DATE}}|`date +'%a, %b %d %H:%M'`|g; s|{{URL}}|$website_url/$1|g" |\ @@ -76,14 +78,17 @@ publish() { cat $blog_template | sub "$to_publish" \ > "$data_dir/html/$to_publish.html" - index_entry="$(cat "$data_dir/templates/$index_template" | sub "$to_publish")" - - #sed is breaking when trying to add multiple lines for some reason + temp_index="$(mktemp)" # probably bad idea + cat "$data_dir/templates/$index_template" | sub "$to_publish" >> $temp_index + temp_rolling="$(mktemp)" + cat "$data_dir/templates/$rolling_template" | sub "$to_publish" >> $temp_rolling + temp_rss="$(mktemp)" + cat "$data_dir/templates/$rss_template" | sub "$to_publish" >> $temp_rss # Add new entry to blog index (do something about indent??) - - # echo -e "//a \n\n$index_entry\n" - sed -i "//a \n${index_entry}\n" "$blog_index_file" + sed -i "//r $temp_index" "$blog_index_file" + sed -i "//r $temp_rolling" "$rolling_file" + sed -i "//r $temp_rss" "$rss_file" mv "$data_dir/drafts/$to_publish.draft.html" "$data_dir/published/"