| 25 |
|
UPLOAD_INFO="" # path to a file on your hard drive with the login info needed to upload a report |
| 26 |
|
|
| 27 |
|
# Fixed strings -- see the occurrences of these variables to learn their purpose |
| 28 |
< |
AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3146.0 Safari/537.36" |
| 28 |
> |
AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" |
| 29 |
|
ARCHIVE_API="http://archive.org/wayback/available" |
| 30 |
|
ARCHIVE_GENERIC="https://web.archive.org/web/*" |
| 31 |
|
ARCHIVE_OK_CODES="statuscodes=200&statuscodes=203&statuscodes=206" |
| 32 |
|
CHROME="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" |
| 33 |
|
CHROME_SCREENSHOT="screenshot.png" |
| 34 |
< |
CURL_CODES="http://iritscen.oni2.net/wiki/curl_codes.txt" |
| 34 |
> |
CURL_CODES="http://iritscen.oni2.net/val/curl_codes.txt" |
| 35 |
|
EXPECT_SCRIPT_NAME="val_expect_sftp.txt" |
| 36 |
< |
HTTP_CODES="http://iritscen.oni2.net/wiki/http_codes.txt" |
| 36 |
> |
HTTP_CODES="http://iritscen.oni2.net/val/http_codes.txt" |
| 37 |
|
MY_WIKI_PAGE="http://wiki.oni2.net/User:Iritscen" |
| 38 |
|
THIS_DIR=$(cd $(dirname $0); pwd) |
| 39 |
|
WORKING_DIR=$(pwd) |
| 50 |
|
|
| 51 |
|
# These arrays tells us which HTTP response codes are OK (good) and which are NG (no good). Pages that |
| 52 |
|
# return NG codes will not be screenshotted. Remember to update http_codes.txt if you add a new code. |
| 53 |
< |
declare -a OK_CODES=(200 301 302 307 401 405 406 501) |
| 54 |
< |
declare -a NG_CODES=(000 403 404 410 500 503) |
| 53 |
> |
declare -a OK_CODES=(200 301 307 401 405 406 501) |
| 54 |
> |
declare -a NG_CODES=(000 302 403 404 410 500 503) |
| 55 |
|
|
| 56 |
|
# Characters not allowed in a URL. Curly braces are sometimes used on the wiki to build a link using |
| 57 |
|
# transcluded text, and if the transclusion fails, then the braces show up in the URL |
| 745 |
|
if [ $STATUS == "NG" ] && [ $SUGGEST_SNAPSHOTS -eq 1 ]; then |
| 746 |
|
ARCHIVE_QUERY=$(curl --silent --max-time 10 "$ARCHIVE_API?url=$URL&$ARCHIVE_OK_CODES") |
| 747 |
|
|
| 748 |
< |
# Isolate "url" property in response and log it if received... |
| 749 |
< |
if [[ "$ARCHIVE_QUERY" == *\"url\":* ]]; then |
| 750 |
< |
SNAPSHOT_URL=${ARCHIVE_QUERY#*\"url\":\"} |
| 751 |
< |
SNAPSHOT_URL=${SNAPSHOT_URL%\",\"timestamp*} |
| 748 |
> |
# Isolate "url" property in response and log it if a "closest" snapshot was received... |
| 749 |
> |
if [[ "$ARCHIVE_QUERY" == *\"closest\":* ]]; then |
| 750 |
> |
SNAPSHOT_URL=${ARCHIVE_QUERY##*\"url\": \"} |
| 751 |
> |
SNAPSHOT_URL=${SNAPSHOT_URL%\", \"timestamp*} |
| 752 |
|
valPrint t " IA suggests $SNAPSHOT_URL" |
| 753 |
|
valPrint r " IA suggests {\field{\*\fldinst{HYPERLINK \"$SNAPSHOT_URL\"}}{\fldrslt $SNAPSHOT_URL}}" |
| 754 |
|
valPrint hn "<tr><td colspan=\"2\" align=\"right\">IA suggests</td><td><a href=\"$SNAPSHOT_URL\" target=\"_blank\">$SNAPSHOT_URL</a></td></tr>" |