shithub: shithub

ref: c5847bcde2ed8d1e5891e79b186a14e46cfa0bfa
dir: /view/

View raw version
#!/bin/rc

. /sys/lib/shithub/common.rc

cd $1
shift

rfork ne
nl='
'

gituser=$1
repo=$2
refname=$3
file=$4

repons $gituser $repo
if(! ref=`{resolveref $refname}){
	echo '<b>invalid ref '$refname'</b>'
	exit
}
cd $gitfs/$ref/tree
if(~ $file '')
	file='.'
hash=`{cat $gitfs/$ref/hash}

http_response
user_prelude $gituser $repo $hash

echo '	<p>
	<b>ref:</b> <a href="'/$gituser/$repo/browse/$hash/'">'$hash'</a><br/>
	<b>raw:</b>	<a href="'/$gituser/$repo/viewraw/$hash/$file'">view</a>
	</p>'

echo /$gituser/$repo/browse/$hash $repo /$file |breadcrumb

if(test -f $file){
	type=`{file -m $file}
	switch($type){
	case text/*
		echo '	<pre id="code">'
		htcat $file
		echo '	</pre>'
	case image/*
		echo '	<br/><div><img src="'/$gituser/$repo/viewraw/$hash/$file'" /></div>'
	case *
		echo '	<p>Binary file not displayed</p>'
	}
}
echo '	</body>
	</html>'