Browse Source

Phlogging script

Bob Mottram 11 years ago
parent
commit
fa433494ef
1 changed files with 145 additions and 0 deletions
  1. 145
    0
      beaglebone.txt

+ 145
- 0
beaglebone.txt View File

@@ -2803,6 +2803,8 @@ If you are using a self-signed certificate then at the login screen scroll down
2803 2803
 More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
2804 2804
 
2805 2805
 ** Install Gopher
2806
+*** Server setup
2807
+
2806 2808
 Gopher is an old internet protocol which originated a few years before the web and is purely text based.  It can be quite fun to build a gopher site and browse the gopherverse.  One thing to keep in mind is that there is no security with gopher, so any text transmitted is trivially interceptable by systems such as [[https://en.wikipedia.org/wiki/XKeyscore][Xkeyscore]] or deep packet inspection.
2807 2809
 
2808 2810
 To set up a gopher server:
@@ -3010,6 +3012,149 @@ gopher://mydomainname.com
3010 3012
 
3011 3013
 There is a browser addon for Gopher called "overbite".  Installing that should enable you to view your site.
3012 3014
 
3015
+*** A phlogging script
3016
+
3017
+A phlog is the gopher equivalent of a blog on the web.  You can create a script which makes phlogging easy.
3018
+
3019
+#+BEGIN_SRC: bash
3020
+emacs /usr/bin/mkphlog
3021
+#+END_SRC
3022
+
3023
+Add the following:
3024
+
3025
+#+BEGIN_SRC: bash
3026
+#!/bin/sh
3027
+
3028
+# mkphlog - a utility to ease the creation of phlogs.
3029
+#           Organizes phlog posts in separate directories.
3030
+# Created by octotep; anyone can distribute, modify, and
3031
+# share this file however they please.
3032
+#
3033
+# Version 0.3
3034
+#
3035
+# Modified by Bob Mottram
3036
+#
3037
+# Please note, all date strings are in the form of mm/dd/yy(yy)
3038
+
3039
+# The base of the entire gopher site.
3040
+gopherRoot="/var/gopher"
3041
+
3042
+# The name of the phlog directory (contained in $gopherHome)
3043
+phlogDirName="phlog"
3044
+
3045
+# Default editor, unless the user has one specified in env
3046
+editor=${EDITOR:-emacs}
3047
+
3048
+# Default timezone, unless the user has one specified in env
3049
+TZ=${TZ:-UTC}
3050
+
3051
+# Tells the script how many lines the title of the main page spans.
3052
+# Used to insert the newest post at the top.
3053
+# Titles created by mkphlog are 3 lines.
3054
+# Isn't used if $addTitleToMain is false
3055
+titleLineCount=3
3056
+
3057
+entryDate=`date +%Y-%m-%d`
3058
+
3059
+# Creates the phlog directory if it dosen't already exist.
3060
+CreatePhlogDir() {
3061
+    mkdir $phlogDirName
3062
+    chmod 755 $phlogDirName
3063
+    cd $phlogDirName
3064
+    echo "Phlog directory created."
3065
+}
3066
+
3067
+# Updates the main phlog listing
3068
+UpdatePhlogListing() {
3069
+    # Just in case the user didn't specify a title
3070
+    if [ "$postTitleAns" = "" ] ; then
3071
+	echo -n "Do you want to create a blank post? (y/n) "
3072
+	read blankPostAns
3073
+	case $blankPostAns in
3074
+	    y* | Y* ) $postTitleAns="New Post" ;;
3075
+		    n* | N* ) echo "Goodbye, then." ; exit 1 ;;
3076
+			    * ) exit 1 ;;
3077
+				  esac
3078
+    fi
3079
+
3080
+    cd $gopherRoot/$phlogDirName/
3081
+    title2=$(echo "${postTitleAns}" | tr " " _)
3082
+    postfilename="${entryDate}_${title2}.txt"
3083
+    touch ${postfilename}
3084
+    echo $postTitleAns >> ${postfilename}
3085
+    date "+%A %b %e %l:%M:%S %Y" >> ${postfilename}
3086
+    echo "------------------------------" >> ${postfilename}
3087
+    echo >> ${postfilename}
3088
+}
3089
+
3090
+
3091
+if [ -d $gopherRoot ] ; then
3092
+    cd $gopherRoot
3093
+else
3094
+    echo "You don't have a gopherspace set-up. Please run the gopher server setup instructions."
3095
+    exit 1
3096
+fi
3097
+
3098
+if [ -d $phlogDirName ] ; then
3099
+    cd $phlogDirName
3100
+else
3101
+    echo -n "Do you want to create a phlog directory? (y/n) "
3102
+    read phlogDirAns
3103
+    case $phlogDirAns in
3104
+	y* | Y* ) CreatePhlogDir ;;
3105
+	n* | N* ) exit 1 ;;
3106
+	* ) exit 1 ;;
3107
+    esac
3108
+fi
3109
+
3110
+echo -n "Would you like to create a phlog entry for today? (y/n) "
3111
+read phlogAns
3112
+case $phlogAns in
3113
+    y* | Y* ) echo "Creating today's phlog entry..." ;;
3114
+    n* | N* ) exit 0 ;;
3115
+    * ) exit 1 ;;
3116
+esac
3117
+
3118
+# Make sure there isn't a post for that day, lest we overwrite it.
3119
+if [ ! -d $entryDate ]; then
3120
+    echo -n "Title: "
3121
+    read postTitleAns
3122
+    title2=$(echo "${postTitleAns}" | tr " " _)
3123
+    postfilename="${entryDate}_${title2}.txt"
3124
+    touch ${postfilename}
3125
+    chmod 644 ${postfilename}
3126
+    UpdatePhlogListing
3127
+    echo -n "Would you like to edit the post with $editor? (y/n) "
3128
+    read editorAns
3129
+    case $editorAns in
3130
+	y* | Y* ) $editor $gopherRoot/$phlogDirName/${postfilename} ;;
3131
+	n* | N* ) exit 0 ;;
3132
+	* ) exit 0 ;;
3133
+    esac
3134
+
3135
+    rm $gopherRoot/$phlogDirName/${postfilename}~
3136
+else
3137
+    echo "There is already a post for today."
3138
+    echo -n "Would you like to edit the post with $editor? (y/n) "
3139
+    read editorAns
3140
+    case $editorAns in
3141
+	y* | Y* ) $editor $gopherRoot/$phlogDirName/$entryDate*.txt ;;
3142
+	n* | N* ) exit 0 ;;
3143
+	* ) exit 1 ;;
3144
+    esac
3145
+    rm $gopherRoot/$phlogDirName/${postfilename}.txt~
3146
+fi
3147
+exit 0
3148
+#+END_SRC
3149
+
3150
+Save and exit.
3151
+
3152
+#+BEGHIN_SRC: bash
3153
+chmod +x /usr/bin/mkphlog
3154
+#+END_SRC
3155
+
3156
+Now entering the command /mkphlog/ will allow you to create a phlog entry.
3157
+
3013 3158
 ** Install Owncloud
3014 3159
 
3015 3160
 #+BEGIN_VERSE