Commits

Ben Bass committed d1219c0

intial asset bundle support

Comments (0)

Files changed (2)

     echo "  -s <pattern>"
     echo "        search for given pattern"
     echo "  -t    time track mode"
+    echo "  -i    import [FILEPATH]"
+    echo "  -x    export to [FILEPATH.tar]"
     echo " (Note these options are mutually exclusive)"
     echo
     exit 1
     shift
 fi
 
-OPTION_CHARS="alfsth"
+OPTION_CHARS="alfstixh"
 MODE='';
 while getopts "$OPTION_CHARS" option ; do
     case $option in
         's')
             if [[ -z $MODE ]] ; then MODE="SEARCH"; else usage; fi
             ;;
+        'i')
+            if [[ -z $MODE ]] ; then MODE="IMPORT"; else usage; fi
+            ;;
+        'x')
+            if [[ -z $MODE ]] ; then MODE="EXPORT"; else usage; fi
+            ;;
         'h')
             usage
             ;;
 
 shift $(($OPTIND - 1))
 
-# only 'search' can (and must) have additional arguments
-if [[ $MODE != "SEARCH" ]] && [[ -n $1 ]]; then
+# only search/import/export can (and must) have additional arguments
+if ! [[ $MODE =~ SEARCH|IMPORT|EXPORT ]] && [[ -n $1 ]]; then
     echo "Too many arguments: $@"
     echo
     usage
-elif [[ $MODE == "SEARCH" ]] && [[ -z $1 ]]; then
-    echo "Not enough arguments - search option requires pattern"
+elif [[ $MODE =~ SEARCH|IMPORT|EXPORT ]]  && [[ -z $1 ]]; then
+    echo "Not enough arguments - $MODE option requires an argument"
     echo
     usage
 fi
     mkdir -p $TARGET_DIR
     TARGET_PATH="$TARGET_DIR/$CATEGORY"
     HIST_FILE="$TARGET_DIR/.hist.$CATEGORY"
+    ASSETS_PATH="$TARGET_DIR/$CATEGORY.assets"
 else
     # edit the 'main' file
     TARGET_PATH="$EDITFILE_DIR/${MAJOR_NAME}"
     HIST_FILE="$EDITFILE_DIR/.hist.${MAJOR_NAME}"
+    ASSETS_PATH="$TARGET_DIR/${MAJOR_NAME}.assets"
 fi
 
 # support for various extensions.
     'SEARCH')
         grep -n --color "$@" "$TARGET_PATH"
         ;;
+    'IMPORT')
+        mkdir -p "${ASSETS_PATH}"
+        cp "$1" "${ASSETS_PATH}"
+        echo "Imported $1 to ${ASSETS_PATH}"
+        ;;
+    'EXPORT')
+        EXT_PATH=""
+        if test -d ${ASSETS_PATH} ; then
+            EXT_PATH="$(basename ${ASSETS_PATH})"
+        fi
+        (cd "$(dirname ${TARGET_PATH})"; tar -cf "$1" $(basename "$TARGET_PATH") ${EXT_PATH})
+        echo "Exported ${TARGET_PATH} bundle to  $1"
+        ;;
     'TRACK')
         now=$(date '+%Y/%m/%d %H:%M')
         # read history from previous
 exclamation mark simply runs the command; double '!!command' inserts the result
 into the target file.
 
+Storing assets
+--------------
+
+``editfile`` is about reducing the friction in being able to write. No need to
+think about where the document ends up, no need to go through a long startup
+procedure when making a new document. And more. So in writing more, I found
+my next use-case is being able to store non-text data alongside the text.
+
+Ideally I'd like to be able to include a highly efficient DSL which creates
+SVG diagrams in all my documents, but I've not yet found anything ideal;
+blockdiag_ comes close, but I want something which is already *right* in it's
+default styling, and blockdiag isn't that, for me.
+
+.. _blockdiag: http://blockdiag.com
+
+Anyway, sometimes a diagram isn't enough anyway, and I need a photo, or a piece
+of music. Or some other binary file.
+
+Importing a file
+~~~~~~~~~~~~~~~~
+
+    $ blog a-wonderful-blog-post -i ~/photo1.jpg
+    $ blog a-wonderful-blog-post -i ~/photo2.jpg
+
+Exporting bundles
+~~~~~~~~~~~~~~~~~
+
+    $ blog a-wonderful-blog-post -x ~/blog-post.tar
+
+
+Exporting content
+~~~~~~~~~~~~~~~~~
+
 Direct use of 'editfile'
 ------------------------
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.