From 7e32887fab7481868ffd68ecf7be5d32b84d089d Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 22 May 2024 09:30:15 -0400 Subject: [PATCH 1/5] Local Install script building on @BenediktMeierUIT download script --- localinstall.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 localinstall.sh diff --git a/localinstall.sh b/localinstall.sh new file mode 100644 index 0000000..91f7c9c --- /dev/null +++ b/localinstall.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +dirLocal=$(pwd) + + +# go to the version folder +if [ -z "$1" ]; then + echo "The variable is empty." + exit 1 +fi +folder="$1" +cd "${folder}" + + +sed -n 's/.*src="\(http[^"]*\)".*/\1/p' *.html | sort -u | sed -n 's/^\(.*\/\)*\(.*\)/sed -i \x27s,\0\,lib\/\2,\x27 *.html/p' > replace_js.sh +sed -n 's/.*src="\(http[^"]*\)".*/\1/p' *.html | sort -u > urls_js.txt +source replace_js.sh + + +if [ ! -d ./lib ]; then + mkdir ./lib +fi +cd ./lib +while read url; do + wget --quiet $url +done < "../urls_js.txt" + + +cd ".." +if [ ! -d ./css ]; then + mkdir ./css +fi +cd ./css +while read url; do + wget --quiet $url +done < "${dirLocal}/urls_css.txt" + +exit 0 From 5a8eceaf5f327de5e74fade5aa9ac69c2a1205e3 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 22 May 2024 09:36:17 -0400 Subject: [PATCH 2/5] updates --- localinstall.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/localinstall.sh b/localinstall.sh index 91f7c9c..38faf27 100644 --- a/localinstall.sh +++ b/localinstall.sh @@ -1,21 +1,25 @@ #!/bin/bash -dirLocal=$(pwd) - # go to the version folder if [ -z "$1" ]; then - echo "The variable is empty." + echo "The variable is empty. Provide the relative path to the previewer version you wish to make an all-local instance of." exit 1 fi folder="$1" cd "${folder}" - +echo Downloading local copies of remote JavaScript libraries: sed -n 's/.*src="\(http[^"]*\)".*/\1/p' *.html | sort -u | sed -n 's/^\(.*\/\)*\(.*\)/sed -i \x27s,\0\,lib\/\2,\x27 *.html/p' > replace_js.sh sed -n 's/.*src="\(http[^"]*\)".*/\1/p' *.html | sort -u > urls_js.txt source replace_js.sh +cat urls_js.txt +echo Downloading local copies of remote CSS files: +sed -n 's/.* replace_css.sh +sed -n 's/.* Date: Thu, 23 May 2024 18:19:43 -0400 Subject: [PATCH 3/5] add changing example commands --- localinstall.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/localinstall.sh b/localinstall.sh index 38faf27..d6f3456 100644 --- a/localinstall.sh +++ b/localinstall.sh @@ -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}" @@ -17,7 +26,7 @@ cat urls_js.txt echo Downloading local copies of remote CSS files: sed -n 's/.* replace_css.sh -sed -n 's/.* urls_css.txt source replace_css.sh cat urls_css.txt @@ -30,7 +39,7 @@ while read url; do done < "../urls_js.txt" -cd "${folder}" +cd ".." if [ ! -d ./css ]; then mkdir ./css fi @@ -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 From f506dffec053ac2cc4e8d1bf5c1278df3d96f561 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Thu, 23 May 2024 18:34:37 -0400 Subject: [PATCH 4/5] updated instructions --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4035347..ca4c495 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,12 @@ or, to just change between versions after you've switched to using the gdcc repo update externaltool set toolurl=REPLACE(toolurl, 'v1.2', 'v1.3'); +## Fully Local Installation +By default previewers reference several JavaScript libraries from their original web locations. If you would like to have a local installation that don't require access to other websites, you can use the localinstall.sh script. Download the repository to your local machine, change to the root directory where the localinstall.sh script is and run + + ./localinstall.sh previewers/v1.4 https:/// + +and the script will download all external JavaScript and css files required by the previewers for the version you specified and will update the example configuration commands in the 6.1curlcommands.md, 5.2curlcommands.md and pre5.2curlcommands.md files to reference your local URL. In the case above, using the parameters previewers/v1.4 and https://example.com/path would result example curl commands where the TextPreview.html would be available at https://example.com/path/previewers/v1.4/TextPreview.html. ## How do they work? From 889013c87fd0391c0834a0d2be7336823d8f99a1 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 24 May 2024 15:01:55 -0400 Subject: [PATCH 5/5] minor text edits --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca4c495..b2162bc 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ or, to just change between versions after you've switched to using the gdcc repo update externaltool set toolurl=REPLACE(toolurl, 'v1.2', 'v1.3'); ## Fully Local Installation -By default previewers reference several JavaScript libraries from their original web locations. If you would like to have a local installation that don't require access to other websites, you can use the localinstall.sh script. Download the repository to your local machine, change to the root directory where the localinstall.sh script is and run +By default, previewers reference several JavaScript libraries and style files from their original web locations. If you would like to have a local installation that doesn't require access to other websites, you can use the localinstall.sh script. Download the repository to your local machine, change to the root directory where the localinstall.sh script is and run ./localinstall.sh previewers/v1.4 https:///