diff --git a/index.html b/index.html index b915268..d14a184 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,11 @@ +

 
 
-
 
 
diff --git a/update_quine.sh b/update_quine.sh
index 25ed26c..71ace72 100755
--- a/update_quine.sh
+++ b/update_quine.sh
@@ -3,14 +3,15 @@
 set -euET -o pipefail
 
 directory="${1:-.}"
+vanity="${2:-0}"
 
 temp_file="$(mktemp)"
 hexdump="$(mktemp)"
 
 if test -z "$directory" -o "$directory" = "-h" -o "$directory" = "--help"; then
   echo 'Usage: ./update-quine.sh [path/to/directory]'
-  echo 'The given directory should contain a file named index.html, which should contain the markers XXX_PLACEHOLDER_START_XXX and XXX_PLACEHOLDER_END_XXX'
-  echo "Please note that the strings PLACEHOLDER, PLACEHOLDER_START, PLACEHOLDER_DELETE and PLACEHOLDER_END must not appear wrapped with XXX_thestring_XXX anywhere else in the .html file" 
+  echo 'The given directory should contain a file named index.html, which should contain the markers XXX_PLACE''HOLDER_START_XXX and XXX_PLACE''HOLDER_END_XXX'
+  echo 'Please note that the strings XXX_PLACE''HOLDER_XXX, XXX_PLACE''HOLDER_START_XXX, XXX_PLACE''HOLDER_DELETE_XXX and XXX_PLACE''HOLDER_END_XXX must not appear anywhere else in the .html file'
   exit 1
 fi
 
@@ -20,7 +21,7 @@ sed -i -e 's/XXX_PLACE''HOLDER_START_XXX/&\n\/\/ XXX_PLACE''HOLDER_DELETE_XXX/'
 sed -i -e '/XXX_PLACE''HOLDER_DELETE_XXX/,/XXX_PLACE''HOLDER_END_XXX/d' "$directory"/index.html
 
 # Generate template that will be used for the quine (var src1 = "the marker"; everything else unchanged)
-printf %s\\n 'var src1 = "XXX_PLACEHOLDER_XXX";' >> "$temp_file"
+printf %s\\n 'var src1 = "XXX_PLACE''HOLDER_XXX";' >> "$temp_file"
 
 # Generate contents to be put after the start marker
 printf %s\\n 'var hexLineWidth = 160;'              >> "$temp_file"
@@ -30,11 +31,12 @@ printf %s '  return ' >> "$temp_file"
 # TODO: use ipfs dag get instead of ipfs object get
 partial_hash="$(ipfs add --pin=false --hidden -Qr "$directory")"
 ipfs object get "$partial_hash" \
-| jq '.Links |= map(if .Name == "index.html" then { "Name": .Name, "Hash": "XXX_PLACEHOLDER_HASH_XXX", "Size": "XXX_PLACEHOLDER_SIZE_XXX" } else . end)' \
-| sed -e '2,$s/^/  /' -e '$s/$/;/' -e 's/["'\'']XXX_PLACEHOLDER_HASH_XXX["'\'']/index_html.hash/' -e 's/["'\'']XXX_PLACEHOLDER_SIZE_XXX["'\'']/index_html.block.length/' \
+| jq '.Links |= map(if .Name == "index.html" then { "Name": .Name, "Hash": "XXX_PLACE''HOLDER_HASH_XXX", "Size": "XXX_PLACE''HOLDER_SIZE_XXX" } else . end)' \
+| sed -e '2,$s/^/  /' -e '$s/$/;/' -e 's/["'\'']XXX_PLACE''HOLDER_HASH_XXX["'\'']/index_html.hash/' -e 's/["'\'']XXX_PLACE''HOLDER_SIZE_XXX["'\'']/index_html.block.length/' \
 >> "$temp_file"
 printf %s\\n '}' >> "$temp_file"
 
+printf %s\\n 'var XXX_VANI''TY_XXX = 0;' >> "$temp_file"
 printf %s\\n '// XXX_PLACE''HOLDER_END_XXX' >> "$temp_file"
 
 # Add the generated contents after the start marker
@@ -48,6 +50,8 @@ xxd -ps < "$directory"/index.html | tr -d \\n | fold -w 160 | sed -e 's/.*''/"&"
 sed -i -e '/var src1 = "XXX_PLACE''HOLDER_XXX";/ r '"$hexdump" "$directory"/index.html
 # Remove the line with the placeholder
 sed -i -e '/var src1 = "XXX_PLACE''HOLDER_XXX";/ d' "$directory"/index.html
+# Add the desired vanity value
+sed -i -e 's/var XXX_VANI''TY_XXX = 0;/var XXX_VANI''TY_XXX = '"$vanity"';/' "$directory"/index.html
 
 echo "The hash given by the page should be:"
 ipfs cid base32 "$(ipfs add --hidden -Qr "$directory")"