3 # Copyright 2014 Paul Hänsch
5 # This file is part of Busy
7 # Busy is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # Busy is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with Busy. If not, see <http://www.gnu.org/licenses/>.
20 url="$(echo "$_GET[\"i\"]" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
21 rev="$(echo "$_GET[\"r\"]" |sed -rn '1{/^[0-9]+$/p}')"
23 baseuri=$(sed -rn 's:^svnRepo=(.*)$:\1:p' project.meta)
24 lastrev=$(svn info "$baseuri" |sed -rn 's;^Revision: *([0-9]+);\1;p')
25 [ -z "$rev" ] && rev="$lastrev"
29 until [ -z "$tmp" -o "$tmp" = '//' -o "$tmp" = './' ]; do
30 echo "<a href='?p=Subversion&i=$tmp&r=$rev'>/$(basename "$tmp")</a> "
31 tmp="$(dirname "$tmp")/"
37 for i in {1.."$lastrev"}; do
38 echo "<a href='?p=Subversion&i=$url&r=$i'>$i</a>"
43 svn log "${baseuri}/${url}" \
44 | sed -rn '2,${s:^-+$:</div>:g;
45 s:^r([0-9]+) \| ([a-zA-Z0-9]+) \| ([0-9: -]+) .+$:<div class="changelog"><h2>Revision \1 by \2<br>at \3</h2>:g;p}'
49 if (egrep -q '^(.*/|)$' <<<"$url"); then
50 # we are showing a directory
51 svn propget svn:externals -r "$rev" "${baseuri}/${url}" \
52 | sed -rn "s;^([^ ]+) (.+)$;<span class='extern'>\2/</span> [external include from <a href='\1'>\1</a>]<br>;p"
54 svn ls -r "$rev" "${baseuri}/${url}" \
55 | sed -r "s:^.*$:<a href='?p=Subversion\&i=$url/&\&r=$rev'>&</a><br>:g"
57 # we are showing a file
58 echo -E "$url" |egrep -vq '\.' && \
61 source-highlight --lang-list \
62 | grep -o "^${url##*.} " || echo sh
64 svn cat -r "$rev" "${baseuri}/${url}" \
65 | source-highlight -s "$lang"
74 cat ${_EXEC}/templates/Subversion.css
77 #. ${_EXEC}/templates/text_subversion.sh
78 . ${_EXEC}/templates/Subversion.page