From: paul Date: Thu, 29 Mar 2012 01:26:53 +0000 (+0000) Subject: simplified svn browser X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=e443a984b0487e82c7cac9abdc62418d5139d4af;p=busy simplified svn browser svn path=/trunk/; revision=40 --- diff --git a/Subversion.page b/Subversion.page index fe6bdb6..adc89b8 100755 --- a/Subversion.page +++ b/Subversion.page @@ -1,48 +1,44 @@ #!/bin/zsh -url="$(egrep -o '(^|&)(i=).+(&|$)' <<<"${QUERY_STRING}" |sed -r 's:^&?i=::;s:&.*::;s:\+: :g;s:%:\\x:g')" -url="$(echo -e "${url}" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' |head -n1)" -rev="$(egrep -o '(^|&)(r=)[0-9]+(&|$)' <<<"${QUERY_STRING}" |tr -d 'r=&')" +url="$(sed -rn 's:\+: :g;s:%:\\x:g;s:^(.*&)?i=([^&]+)(&.*)?$:\2:p' <<<"${QUERY_STRING}")" +url="$(echo -e "${url}" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')" +rev="$(sed -rn '/^(.*&)?r=([0-9]+)(&.*)?$/{s:^(.*&)?r=([0-9]+)(&.*)?$:\2:;s:\+: :g;s:%:\\x:g;p}' <<<"${QUERY_STRING}")" -baseuri=$(egrep '^svnRepo=.*$' project.meta |cut -d= -f2-) -lastrev=$(svn info "$baseuri" |egrep '^Revision:' |cut -d\ -f2) +baseuri=$(sed -rn 's:^svnRepo=(.*)$:\1:p' project.meta) +lastrev=$(svn info "$baseuri" |sed -rn 's;^Revision: *([0-9]+);\1;p') [ -z "$rev" ] && rev="$lastrev" cat <

Path:

[root] -SVNEND -tmp=$url -until [ -z "$tmp" -o "$tmp" = // ]; do - echo "/$(basename "$tmp") " - tmp=$(dirname "$tmp")/ -done |tac -echo '

Revisions:

' -for i in {1.."$lastrev"}; do - echo "$i" -done - -cat </$(basename "$tmp") " + tmp=$(dirname "$tmp")/ + done |tac) +
+

Revisions:

+ $(for i in {1.."$lastrev"}; do + echo "$i" + done) :g; -s:^r([0-9]+) \| ([a-zA-Z0-9]+) \| ([0-9: -]+) .+$:

Revision \1 by \2
at \3

:g;p}') + sed -rn '2,${s:^-+$:
:g; + s:^r([0-9]+) \| ([a-zA-Z0-9]+) \| ([0-9: -]+) .+$:

Revision \1 by \2
at \3

:g;p}')

$(basename "$url"), Revision "$rev":

-SVNEND -if (egrep -q '^(.*/|)$' <<<"$url"); then - svn ls -r "$rev" "${baseuri}/${url}" |sed -r "s:^.*$:&
:g" - echo '
' -else - 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" #|sed 's:<:\<:g;s:>:\>:g;' -fi -cat <&
:g" + echo '
' + 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) SVNEND