3 # Format js/src/doc documentation in SOURCEDIR, place formatted files in OUTPUTDIR,
4 # and post all changed pages to MDN using KEYID and SECRET to identify the poster.
5 # See js/src/doc/README.md for general usage information.
9 # ./publish.sh SOURCEDIR OUTPUTDIR KEYID SECRET
11 # Pages are tagged with the current Mercurial parent changeset ID.
15 progname
=$
(basename $0)
16 doc
=$
(cd $
(dirname $0); pwd)
24 $doc/format.sh
--mdn "$sourcedir" "$outputdir"
26 config
=$sourcedir/config.sh
28 watermark
=$lib/extract-watermark.sh
30 # Fetch a URL, with caching disabled.
32 curl
--silent -XGET "$1" \
33 -H"Cache-Control: no-cache, no-store, must-revalidate" \
34 -H"Pragma: no-cache" \
38 source $lib/dummy-config.sh
44 local formatted_file
=$outputdir/${INPUT_FILE/md/html}
46 # Extract the watermark from the formatted file.
47 local local_watermark
=$
("$watermark" < "$formatted_file")
49 # Get the existing page, and extract its watermark, if any.
50 local public_watermark
=$
(fetch
"$URL?raw" |
"$watermark")
52 if [ "$local_watermark" != "$public_watermark" ]; then
53 echo "$progname: Updating: $URL" >&2
55 status
=$
(curl
--silent -X PUT
-H"Content-Type: text/html" --upload-file "$formatted_file" -u "$keyid:$secret" "$URL")
60 echo "$progname: Error posting $URL, from $config: $status" >&2
65 echo "$progname: Unchanged: $URL" >&2
69 # MDN can't currently update attached resources. But we can verify that the current
70 # published versions match what we have.
73 local file=$sourcedir/$2
76 if cmp "$file" <(fetch
"$url") > /dev
/null
; then
77 echo "$progname: Unchanged: $url" >&2
79 echo "$progname: Warning: resource out of date: $url" >&2