|
@@ -184,10 +184,10 @@ The initialization of the database is accomplished by creating the containing di
|
|
|
#+BEGIN_SRC sh
|
|
|
function initialize {
|
|
|
OLD=`pwd`
|
|
|
- mkdir -p ${LIBRARYDIRECTORY}
|
|
|
- cd ${LIBRARYDIRECTORY}
|
|
|
- [[ ! -e `basename ${LIBRARYFILE}` ]] && \
|
|
|
- cat <<EOF > `basename ${LIBRARYFILE}`
|
|
|
+ mkdir -p ${LIBRARY_DIRECTORY}
|
|
|
+ cd ${LIBRARY_DIRECTORY}
|
|
|
+ [[ ! -e `basename ${LIBRARY_FILE}` ]] && \
|
|
|
+ cat <<EOF > `basename ${LIBRARY_FILE}`
|
|
|
<<file-format>>
|
|
|
EOF
|
|
|
}
|
|
@@ -213,13 +213,13 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
FIRST=$1
|
|
|
if [[ $FIRST == "init" ]] ; then
|
|
|
OLD=`pwd`
|
|
|
- cd ${LIBRARYDIRECTORY}
|
|
|
+ cd ${LIBRARY_DIRECTORY}
|
|
|
git $@
|
|
|
cd ${OLD}
|
|
|
else
|
|
|
if [[ $GIT == "detect" ]] ; then
|
|
|
OLD=`pwd`
|
|
|
- cd ${LIBRARYDIRECTORY}
|
|
|
+ cd ${LIBRARY_DIRECTORY}
|
|
|
git "$@"
|
|
|
cd ${OLD}
|
|
|
fi
|
|
@@ -237,7 +237,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
#+Name: handle-query
|
|
|
#+BEGIN_SRC sh
|
|
|
function run_query {
|
|
|
- recsel -t Book "$@" ${LIBRARYFILE}
|
|
|
+ recsel -t Book "$@" ${LIBRARY_FILE}
|
|
|
}
|
|
|
#+END_SRC
|
|
|
|
|
@@ -291,8 +291,8 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
-f ISBN -v "${ISBN}" \
|
|
|
-f Location -v "${LOCATION}" \
|
|
|
-f Card -v UNPRINTED \
|
|
|
- ${LIBRARYFILE}
|
|
|
- do_git add `basename ${LIBRARYFILE}`
|
|
|
+ ${LIBRARY_FILE}
|
|
|
+ do_git add `basename ${LIBRARY_FILE}`
|
|
|
do_git commit -m "Added record for \"${TITLE}\""
|
|
|
}
|
|
|
#+END_SRC
|
|
@@ -318,7 +318,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
add_single
|
|
|
done
|
|
|
GIT=${GITOLD}
|
|
|
- do_git add `basename ${LIBRARYFILE}`
|
|
|
+ do_git add `basename ${LIBRARY_FILE}`
|
|
|
do_git commit -m "Added ${1} records"
|
|
|
}
|
|
|
#+END_SRC
|
|
@@ -341,7 +341,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
shift
|
|
|
case ${NAME} in
|
|
|
list)
|
|
|
- for report in ${LIBRARYDIRECTORY}/reports/*.report ;
|
|
|
+ for report in ${LIBRARY_DIRECTORY}/reports/*.report ;
|
|
|
do
|
|
|
echo " - $(basename -- ${report} .report)"
|
|
|
done
|
|
@@ -353,12 +353,12 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
fi
|
|
|
REPORT=$1
|
|
|
shift
|
|
|
- echo "# -*- mode: shell-script -*-" > ${LIBRARYDIRECTORY}/reports/${REPORT}.report
|
|
|
- emacsclient --alternate-editor="" -n ${LIBRARYDIRECTORY}/reports/${REPORT}.report
|
|
|
+ echo "# -*- mode: shell-script -*-" > ${LIBRARY_DIRECTORY}/reports/${REPORT}.report
|
|
|
+ emacsclient --alternate-editor="" -n ${LIBRARY_DIRECTORY}/reports/${REPORT}.report
|
|
|
;;
|
|
|
,*)
|
|
|
- if [[ -e ${LIBRARYDIRECTORY}/reports/${NAME}.report ]] ; then
|
|
|
- sh ${LIBRARYDIRECTORY}/reports/${NAME}.report $@
|
|
|
+ if [[ -e ${LIBRARY_DIRECTORY}/reports/${NAME}.report ]] ; then
|
|
|
+ sh ${LIBRARY_DIRECTORY}/reports/${NAME}.report $@
|
|
|
fi
|
|
|
esac
|
|
|
}
|
|
@@ -386,18 +386,18 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
if [[ $FIELD = "Withdrawn" ]] ; then
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "Withdrawn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
|
|
|
- ${LIBRARYFILE}
|
|
|
+ ${LIBRARY_FILE}
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "Location" -S "WITHDRAWN" \
|
|
|
- ${LIBRARYFILE}
|
|
|
+ ${LIBRARY_FILE}
|
|
|
else
|
|
|
VALUE=$1
|
|
|
shift
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "${FIELD}" -s "${VALUE}" \
|
|
|
- ${LIBRARYFILE}
|
|
|
+ ${LIBRARY_FILE}
|
|
|
fi
|
|
|
- do_git add `basename ${LIBRARYFILE}`
|
|
|
+ do_git add `basename ${LIBRARY_FILE}`
|
|
|
do_git commit -m "Edited record id ${ID}"
|
|
|
}
|
|
|
|
|
@@ -414,8 +414,8 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
shift
|
|
|
TMPDIR=. recset -e "${MATCHEXPRESSION}" \
|
|
|
-f "${FIELDNAME}" -S "${VALUE}" \
|
|
|
- ${LIBRARYFILE}
|
|
|
- do_git add $(basename ${LIBRARYFILE})
|
|
|
+ ${LIBRARY_FILE}
|
|
|
+ do_git add $(basename ${LIBRARY_FILE})
|
|
|
if [[ $1 != "" ]] ; then
|
|
|
do_git commit -m "${1}"
|
|
|
else
|
|
@@ -446,11 +446,11 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "LoanTo" -S "${NAME}" \
|
|
|
- ${LIBRARYFILE}
|
|
|
+ ${LIBRARY_FILE}
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "LoanOn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
|
|
|
- ${LIBRARYFILE}
|
|
|
- do_git add `basename ${LIBRARYFILE}`
|
|
|
+ ${LIBRARY_FILE}
|
|
|
+ do_git add `basename ${LIBRARY_FILE}`
|
|
|
do_git commit -m "Loaned Book ${ID} to ${NAME}"
|
|
|
}
|
|
|
|
|
@@ -465,12 +465,12 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "LoanTo" -d \
|
|
|
- ${LIBRARYFILE}
|
|
|
+ ${LIBRARY_FILE}
|
|
|
TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
-f "LoanOn" -d \
|
|
|
- ${LIBRARYFILE}
|
|
|
+ ${LIBRARY_FILE}
|
|
|
|
|
|
- do_git add `basename ${LIBRARYFILE}`
|
|
|
+ do_git add `basename ${LIBRARY_FILE}`
|
|
|
do_git commit -m "Returned Book ${ID}"
|
|
|
}
|
|
|
#+END_SRC
|
|
@@ -523,8 +523,8 @@ Finally, this is what puts the application together. Placing each function in i
|
|
|
#+Caption: Packaging
|
|
|
#+Name: packaging
|
|
|
#+BEGIN_SRC sh :tangle "~/bin/library" :shebang "#!/bin/sh"
|
|
|
- LIBRARYFILE=~/.library/library.rec
|
|
|
- LIBRARYDIRECTORY=~/.library
|
|
|
+ LIBRARY_FILE=~/.library/library.rec
|
|
|
+ LIBRARY_DIRECTORY=~/.library
|
|
|
GIT=detect
|
|
|
export LIBRARY_DEFAULT_FIELDS=${LIBRARY_DEFAULT_FIELDS:-ID,Title,Author,LCCN,Location,Course}
|
|
|
|