demo-html-unlocked/code/addunlocked-html.sh

50 lines
1.3 KiB
Shell
Executable file

#!/bin/bash
cd "$(mktemp -d ${TMPDIR:-/tmp}/dl-XXXXXXX)"
set -eu
git init
git annex init
set -x
echo size5 >| size5
echo 1 >| size1
echo 1 >| size1.html
echo 1000000000000000000 >| large
echo 1000000000000000000.html >| large.html
# Generate circle.svg -- will got into locked annex
echo '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<circle cx="100" cy="100" r="80" fill="red" />
</svg>' > circle.svg
# Generate HTML that references the SVG -- need to go into unlocked annex
echo '<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>Circle</title></head>
<body>
<h1>My Circle</h1>
<img src="circle.svg" alt="A red circle">
</body>
</html>' > index.html
# specify that all htmls should be "annex add"ed unlocked!
# If you comment it out -- you will see that browser then would fail to show circle
git annex config --set annex.addunlocked 'include=*.html'
# all "large" files will go under annex, either locked or unlocked!
git annex config --set annex.largefiles 'largerthan=3b'
# must be "git annex add" since "git add" would then make annex add to unlocked all of them
# git annex add *
# git commit -m 'added populated files'
# test with datalad save!
datalad save -m "saving with datalad"
git show
ls -l
# Must show circle just fine if .html was unlocked
xdg-open file:///$PWD/index.html