Skip to content

Commit

Permalink
add changing example commands
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed May 23, 2024
1 parent 5a8ecea commit bb94c7e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions localinstall.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/bin/bash

dirLocal=$(pwd)

# go to the version folder
if [ -z "$1" ]; then
echo "The variable is empty. Provide the relative path to the previewer version you wish to make an all-local instance of."
echo "Provide the relative path to the previewer version you wish to make an all-local instance of, e.g. previewers/v1.4."
exit 1
fi

if [ -z "$2" ]; then
echo "To update the example curl commands, add the base URL for your local previewer installation as the second parameter."
echo "E.g. https://yourinstitution.org/mypreviewerdir to have the Text previewer at https://yourinstitution.org/mypreviewerdir/previewers/v1.4/TextPreview.html"
echo "The version will match the relative path you provide"
echo ""
fi

folder="$1"
cd "${folder}"

Expand All @@ -17,7 +26,7 @@ cat urls_js.txt

echo Downloading local copies of remote CSS files:
sed -n 's/.*<link.*href="\(http[^"]*\)".*/\1/p' *.html | sort -u | sed -n 's/^\(.*\/\)*\(.*\)/sed -i \x27s,\0\,lib\/\2,\x27 *.html/p' > replace_css.sh
sed -n 's/.*<link.*href="\(http[^"]*\)".*/\1/p' *.html | sort -u ?urls_css.txt
sed -n 's/.*<link.*href="\(http[^"]*\)".*/\1/p' *.html | sort -u > urls_css.txt
source replace_css.sh
cat urls_css.txt

Expand All @@ -30,7 +39,7 @@ while read url; do
done < "../urls_js.txt"


cd "${folder}"
cd ".."
if [ ! -d ./css ]; then
mkdir ./css
fi
Expand All @@ -41,6 +50,16 @@ done < "../urls_css.txt"

cd ..


if [ ! -z "$2" ]; then
cd "${dirLocal}"
echo Changing example curl commands to use local URLs
localurl="$2"
sed -i "s,https://gdcc.github.io/dataverse-previewers/previewers/v1.[34],$localurl/$folder,g" *curlcommands.md
echo Done changing example curl commands to use local URLs
cd "${folder}"
fi

echo Cleaning Up...
rm urls_js.txt
rm urls_css.txt
Expand Down

0 comments on commit bb94c7e

Please sign in to comment.