lastrev=$(svn info "$baseuri" |sed -rn 's;^Revision: *([0-9]+);\1;p')
[ -z "$rev" ] && rev="$lastrev"
+svn_path(){
+ tmp="$url"
+ until [ -z "$tmp" -o "$tmp" = '//' -o "$tmp" = './' ]; do
+ echo "<a href='?p=Subversion&i=$tmp&r=$rev'>/$(basename "$tmp")</a> "
+ tmp="$(dirname "$tmp")/"
+ done \
+ | tac
+}
+
+svn_revisions(){
+ for i in {1.."$lastrev"}; do
+ echo "<a href='?p=Subversion&i=$url&r=$i'>$i</a>"
+ done
+}
+
+svn_changelog(){
+ svn log "${baseuri}/${url}" \
+ | sed -rn '2,${s:^-+$:</div>:g;
+ s:^r([0-9]+) \| ([a-zA-Z0-9]+) \| ([0-9: -]+) .+$:<div class="changelog"><h2>Revision \1 by \2<br>at \3</h2>:g;p}'
+}
+
+svn_showurl(){
+ if (egrep -q '^(.*/|)$' <<<"$url"); then
+ # we are showing a directory
+ svn propget svn:externals -r "$rev" "${baseuri}/${url}" \
+ | sed -rn "s;^([^ ]+) (.+)$;<span class='extern'>\2/</span> [external include from <a href='\1'>\1</a>]<br>;p"
+
+ svn ls -r "$rev" "${baseuri}/${url}" \
+ | sed -r "s:^.*$:<a href='?p=Subversion\&i=$url/&\&r=$rev'>&</a><br>:g"
+ else
+ # we are showing a file
+ echo -E "$url" |egrep -vq '\.' && \
+ lang=txt \
+ || lang=$(
+ source-highlight --lang-list \
+ | grep -o "^${url##*.} " || echo sh
+ )
+ svn cat -r "$rev" "${baseuri}/${url}" \
+ | source-highlight -s "$lang"
+ fi
+}
+
case "$1" in
title)
echo "Code"
<div id="LEFT">
<h1>Path:</h1>
<a href='?p=Subversion&i=/&r=$rev'>[root]</a>
- $(tmp="$url"
- until [ -z "$tmp" -o "$tmp" = '//' -o "$tmp" = './' ]; do
- echo "<a href='?p=Subversion&i=$tmp&r=$rev'>/$(basename "$tmp")</a> "
- tmp="$(dirname "$tmp")/"
- done |tac)
+ $(svn_path)
<hr>
<h1>Revisions:</h1>
- $(for i in {1.."$lastrev"}; do
- echo "<a href='?p=Subversion&i=$url&r=$i'>$i</a>"
- done)
+ $(svn_revisions)
</div>
<div id="RIGHT">
<h1>Changelog:</h1><hr>
- $(svn log $(egrep -q '^(.*/|)$' <<<"$url" && echo '') "${baseuri}/${url}" |\
- sed -rn '2,${s:^-+$:</div>:g;
- s:^r([0-9]+) \| ([a-zA-Z0-9]+) \| ([0-9: -]+) .+$:<div class="changelog"><h2>Revision \1 by \2<br>at \3</h2>:g;p}')
+ $(svn_changelog)
</div>
- <div id="MAIN">
- <div class='wikitext'><h1>$(basename "$url"), Revision "$rev":</h1>
- $(if (egrep -q '^(.*/|)$' <<<"$url"); then #are we showing a directory
- svn ls -r "$rev" "${baseuri}/${url}" |sed -r "s:^.*$:<a href='?p=Subversion\&i=$url/&\&r=$rev'>&</a><br>:g"
- echo '</div>'
- else #or are we showing a file
- lang=$(source-highlight --lang-list |cut -d\ -f1 |grep -x "$(sed 's:.*\.::g' <<<"$url")" || echo sh)
- grep -q '\.' <<<"$url" || lang=txt
- svn cat -r "$rev" "${baseuri}/${url}" |source-highlight -s "$lang"
- fi)
+ <div id="MAIN"><div class='wikitext'>
+ <h1>$(basename "$url"), Revision "$rev":</h1>
+ $(svn_showurl)
</div></div>
SVNEND