From 233efbaf5a599d99851e43f16651ddb037d6f0e5 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 16 Jun 2015 16:35:10 +0000 Subject: [PATCH] improvements in subversion browser svn path=/trunk/; revision=69 --- pages/Subversion.sh | 23 +++++++++++------------ templates/Subversion.page | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) 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:

-- 2.39.2