couple fixes + docs
authorDaniel Liu <mr.picklepinosaur@gmail.com>
Wed, 25 Nov 2020 05:23:10 +0000 (00:23 -0500)
committerDaniel Liu <mr.picklepinosaur@gmail.com>
Wed, 25 Nov 2020 05:23:10 +0000 (00:23 -0500)
README.md
blog/templates/index_entry.html [deleted file]
blog/templates/rolling_entry.html [deleted file]
blog/templates/rss_entry.html [deleted file]
pb

index 455cc74..bed46c7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -17,11 +17,13 @@ In each of these files, you need to include the comments:
 
 # Usage
 ### n / new
+Takes in a name for your blog post, put the name inside quotations if you want to have spaces. Also, only alphanumeric characters, underscores, dashes and spaces are allowed in the blog name (at this point).
 
 ### p / publish
+Publishes a draft, which means that it takes the html snippet you wrote and shoves it inside your template file.
 
 ### d / delete
-
+Deletes an already published blog post, this does not delete your draft.
 
 # Configuration
 For more fine tuned configuration, navigate to the data\_dir directory that was created (by default it's blog/) and find the templates folder.
diff --git a/blog/templates/index_entry.html b/blog/templates/index_entry.html
deleted file mode 100644 (file)
index b460195..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<p id="{{TITLE}}">{{TITLE}}</p>
-<h1>antoher line</h1>
diff --git a/blog/templates/rolling_entry.html b/blog/templates/rolling_entry.html
deleted file mode 100644 (file)
index 89d7419..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<div id="{{TITLE}}">
-<h2>{{TITLE}}</h2>
-<p>{{DATE}}</p></div>
diff --git a/blog/templates/rss_entry.html b/blog/templates/rss_entry.html
deleted file mode 100644 (file)
index 3aa997a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<item>
-<title>{{TITLE}}</title>
-<link></link>
-<description><\description>
-<\item>
diff --git a/pb b/pb
index 6497287..3bc32e9 100755 (executable)
--- a/pb
+++ b/pb
@@ -22,8 +22,8 @@ init() {
 
     mkdir -p "$data_dir/drafts" "$data_dir/published" "$data_dir/html" "$data_dir/templates" 
 
-    echo '<p id="{{TITLE}}">{{TITLE}}</p>' >> "$data_dir/templates/$index_template"
-    echo -e '<div id="{{TITLE}}">\n<h2>{{TITLE}}</h2>\n<p>{{DATE}}</p></div>' >> "$data_dir/templates/$rolling_template"
+    echo '<p>{{TITLE}}</p>' >> "$data_dir/templates/$index_template"
+    echo -e '<div>\n<h2>{{TITLE}}</h2>\n<p>{{DATE}}</p>\n<p>{{BODY}}</p>\n</div>' >> "$data_dir/templates/$rolling_template"
     echo -e '<item>\n<title>{{TITLE}}</title>\n<link></link>\n<description><\description>\n<\item>' \
         >> "$data_dir/templates/$rss_template"
 
@@ -33,19 +33,19 @@ init() {
 refresh() {
 
     read -p "Are you sure you want to refresh? [y/n] " ask
-    [ "$ask" != "y" ] && exit 0
+    [ "$ask" != "y" ] && echo "Aborting..." && exit 0
 
     # delete everything between tokens (remove dupe code)
     echo -e "$blog_index_file\n$rolling_file\n$rss_file" | xargs sed -i "/<!-- BLOG START -->/,/<!-- BLOG END -->/{/<!-- BLOG START -->/!{/<!-- BLOG END -->/!d}}"
 
     # deletes all html files and republishes all published files
-
-    echo "Refreshed."
+    echo "Successfully refreshed."
 }
 
 new() {
     [ -z "$1" ] && echo "Please give your blog post a name (you should put it inside quotations)" && exit 1 
-    sanitized=`echo -n "$1" | sed -e 's/[^A-Za-z0-9 _-]//g'| sed -e 's/ /-/g'`
+    sanitized=`echo -n "$1" | sed -e 's/[^A-Za-z0-9 _-]//g'`
+    [ -f "$data_dir/drafts/$sanitized.draft.html" ] && echo "Blog of that name already exists." && exit 1
     $EDITOR "$data_dir/drafts/$sanitized.draft.html"
 }