. "$_EXEC/tools.sh"
. "$_EXEC/acl.sh"
-page="$1"
+LIST=true DIFF=
+while [ $# -gt 0 ]; do case $1 in
+ --list)
+ LIST=true
+ shift 1
+ ;;
+ --no-list)
+ LIST=
+ shift 1
+ ;;
+ --diff)
+ DIFF=true
+ shift 1
+ ;;
+ --no-diff)
+ DIFF=
+ shift 1
+ ;;
+ *)page="$1"
+ shift 1
+ ;;
+esac; done
+
page_abs="$(page_abs "$page")"
+page_default="${page_abs%:*/}"
if ! acl_read "$page_abs"; then
return 0
-elif [ "$REV_PAGES" != true ]; then
- printf '<div class="macro revisions error">GIT is not available to handle revisioning.</div>'
fi
-printf '<ul class="macro revisions">\n'
+printf '<div class="macro revisions">\n'
+
+if [ "$REV_PAGES" != true ]; then
+ printf '<div class="error">GIT is not available to handle revisioning.</div>'
+fi
+
+if [ "$LIST" = true ]; then
+ printf '<ul>\n'
IFS=" "
{ git -C "$_DATA" log --date=format:"%a, %x %H:%M" \
--pretty=format:"%h %cd %s" \
printf '<li><span class="hash"><a href="%s">%s</a></span><span class="date">%s</span><span class="user">%s</span></li>\n' \
"$(HTML "${page%/}/[revision]/$hash")" "$(HTML "$hash")" "$(HTML "$date")" "$(HTML "$user")"
done
-printf '</ul>\n'
+ printf '</ul>\n'
+fi
+
+if [ "$DIFF" = true -a "$LANGUAGE_DEFAULT" -a "$page_default" != "$page_abs" ]; then
+ commit="$(git -C "$_DATA" log --pretty=format:%H -- "pages${page_abs}#page.md" |head -n1)"
+ printf '<section class="diff"><h2>Latest changes to original language page</h2>'
+ git -C "$_DATA" diff -U3 "$commit" -- "pages${page_default}#page.md" |tail -n+5 \
+ | while read -r diff; do case $diff in
+ @@\ *\ @@*)
+ line="${diff#@@ * @@}"
+ num="${diff%"${line}"}"
+ printf '<span class="linenum">%s</span>\n' "$(HTML "$num")"
+ printf '<span class="line">%s</span>\n' "$(HTML "$line")"
+ ;;
+ -*) printf '<span class="linedel">%s</span>\n' "$(HTML "$diff")";;
+ +*) printf '<span class="lineadd">%s</span>\n' "$(HTML "$diff")";;
+ \ *) printf '<span class="line">%s</span>\n' "$(HTML "$diff")";;
+ \\\ *) printf '<span class="linenote">%s</span>\n' "$(HTML "$diff")";;
+ esac; done
+ printf '</section>'
+fi
+
+printf '</div>\n'
margin-right: 1em;
}
+.revisions .diff span {
+ font-family: monospace;
+ display: block;
+ white-space: pre;
+ line-height: 1.375em;
+}
+.revisions .diff span.linenum { color: #D60; }
+.revisions .diff span.linedel { color: #A00; }
+.revisions .diff span.lineadd { color: #0A0; }
+.revisions .diff span.linenote { color: #AAA; }
+
+
[id$="/[attachment]"] input[type=radio].tab ~ div.tab {
display: block;
padding-top: 1em;