#!/bin/rc -e . /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 'invalid ref '$refname'' exit } cd $gitfs/$ref/tree if(~ $file '') file='.' hash=`{cat $gitfs/$ref/hash} user_prelude $gituser $repo $hash echo '

ref: '$hash'
' echo $file | htcat | awk -F/ '{ user = ENVIRON["gituser"] repo = ENVIRON["repo"] hash = ENVIRON["hash"] url="/" user "/" repo "/" hash printf("dir: /", url); for(i = 1; i <= NF; i++){ if($i != "."){ url=url"/"$i printf("%s/", url, $i) } } printf("

") }' if(test -f $file){ echo ' View raw version' type=`{file -m $file} switch($type){ case text/* echo '
'
		htcat $file
		echo '	
' case image/* echo '
' case * echo '

Binary file not displayed

' } } if not if(test -d $file){ cd $file echo '
' for(f in `$nl{ls}){ url=`$nl{echo -n $f/f.html | urlencode} fname=`$nl{echo -n $f | htcat} echo -n ''$fname if (test -d $f) echo '/' echo '
' } echo '
' } echo ' '