LabArchives API usage


Usage examples

#!/bin/bash

###############################################################################
#
# You must include the following at the top of you script for the script
# upload command
#
###############################################################################
SCRIPTPATH="$(
    cd "$(dirname "$0")"
    pwd -P
)"
SCRIPTNAME="$(echo $0 | awk -F './' '{print $2}')"
script="$SCRIPTPATH/$SCRIPTNAME"

# These are some base commands to further simplify use.
heading='la_page_entry.sh -n "$notebook" -f "$lafolder" -p "$lapage" -t "heading" -e'
plaintext='la_page_entry.sh -n "$notebook" -f "$lafolder" -p "$lapage" -t "plain text entry" -e'
scriptenvupload='laout.sh -n "$notebook" -f "$lafolder" -p "$lapage" -s "$script"'
fileuploadtop='la_upload.sh -n "$notebook" -p "$lapage" -a "$filetoupload" file'
fileuploadsub='la_upload.sh -n "$notebook" -f "$lafolder" -p "$lapage" -a "$filetoupload" file'
diruploadtop='la_upload.sh -n "$notebook" -d "$dirtoupload" directory'
diruploadtofolder='la_upload.sh -n "$notebook" -f "$lafolder" -d "$dirtoupload" directory'
filesumtop='la_upload.sh -n "$notebook" -p "$lapage" -a "$filetosum" lasum_file'
filesumsub='la_upload.sh -n "$notebook" -f "$lafolder" -p "$lapage" -a "$filetosum" lasum_file'
dirsumtop='la_upload.sh -n "$notebook" -p "$lapage" -d "$dirtosum" lasum_directory'
dirsumsub='la_upload.sh -n "$notebook" -f "$lafolder" -p "$lapage" -d "$dirtosum" lasum_directory'

###############################################################################
#
# The following are optional variables and are used here to demonstrate
# simplifying multiple notebook entries.
#
###############################################################################
notebook="Trent's second notebook"
lafolder="My tests"
lapage="Uploaded files"
homedir=$HOME
filetoupload="$homedir/Desktop/Test top/test1.txt"
dirtoupload="$homedir/Desktop/Test top"
filetosum="$homedir/Desktop/Test top/test1.txt"
dirtosum="$homedir/Desktop/Test top"

###############################################################################
#
# Some examples for adding data to LabArchives
#
# Where the variables $lapage and $lafolder are used there must already exist
# a corresponding page or folder in your LabArchives notebook
#
###############################################################################

# Add heading
eval $(echo $heading \"Run 1\")

# Add entry text
eval $(echo $plaintext \"We used the white mice for this experiment.\")

# Upload script and environment info
eval $(echo $scriptenvupload)

# File uploads will upload duplicate files
# Upload a file to top level
eval $(echo $fileuploadtop)

# Upload a file to a specific LA folder
eval $(echo $fileuploadsub)

# Directory uploads will only upload files once.  If run again will upload new files only.  It won't delete files.
# Upload a directory to top level
eval $(echo $diruploadtop)

# Upload a directory to specific LA folder
eval $(echo $diruploadtofolder)

# Add file name with shasum to page
eval $(echo $filesumtop)

# Add file name with shasum to page in a specific LA folder
eval $(echo $filesumsub)

# Add all file names with shasums in a directory in an attachment to a page at the top level in the notebook
eval $(echo $dirsumtop)

# Add all file names with shasums in a directory in an attachment to a page in a specific folder
eval $(echo $dirsumsub)