From: paul Date: Tue, 16 Jun 2015 16:35:10 +0000 (+0000) Subject: improvements in subversion browser X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=233efbaf5a599d99851e43f16651ddb037d6f0e5;p=busy improvements in subversion browser svn path=/trunk/; revision=69 --- diff --git a/pages/Subversion.sh b/pages/Subversion.sh index c771ee0..1e506a8 100755 --- a/pages/Subversion.sh +++ b/pages/Subversion.sh @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Busy. If not, see . -url="$(echo "$_GET[\"i\"]" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')" +url="$(echo "$_GET[\"i\"]" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;s:/+:/:g;p}')" rev="$(echo "$_GET[\"r\"]" |sed -rn '1{/^[0-9]+$/p}')" baseuri=$(sed -rn 's:^svnRepo=(.*)$:\1:p' project.meta) @@ -25,12 +25,13 @@ 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 "/$(basename "$tmp") " - tmp="$(dirname "$tmp")/" + tmp="${url%/*}" + until [ "$tmp" = "${tmp#/}" ]; do + echo "${tmp##*/}/ " + tmp="${tmp%/*}" done \ | tac + echo "${url##*/}" } svn_revisions(){ @@ -46,21 +47,19 @@ svn_changelog(){ } svn_showurl(){ - if (egrep -q '^(.*/|)$' <<<"$url"); then + if [ -z "$url" -o "${url%/}" != "$url" ]; then # we are showing a directory svn propget svn:externals -r "$rev" "${baseuri}/${url}" \ | sed -rn "s;^([^ ]+) (.+)$;\2/ [external include from \1]
;p" svn ls -r "$rev" "${baseuri}/${url}" \ - | sed -r "s:^.*$:&
:g" + | sed -r "s:^.*$:&
:g" else # we are showing a file - echo -E "$url" |egrep -vq '\.' && \ + if [ "$url" = "${url#*.}" ] && \ lang=txt \ - || lang=$( - source-highlight --lang-list \ - | grep -o "^${url##*.} " || echo sh - ) + || lang="$(source-highlight --lang-list |grep -o "^${url##*.} ")" + lang="${lang:-sh}" lang="${lang% }" svn cat -r "$rev" "${baseuri}/${url}" \ | source-highlight -s "$lang" diff --git a/templates/Subversion.page b/templates/Subversion.page index 73cb146..866b965 100755 --- a/templates/Subversion.page +++ b/templates/Subversion.page @@ -3,7 +3,7 @@ cat <

Path:

- [root] + [root]/ $(svn_path)

Revisions: