diff options
| -rw-r--r-- | lib/LXRng/Markup/File.pm | 5 | ||||
| -rw-r--r-- | lib/LXRng/Web.pm | 26 | ||||
| -rw-r--r-- | webroot/.static/css/lxrng.css | 28 | ||||
| -rw-r--r-- | webroot/.static/js/lxrng-funcs.js | 63 | 
4 files changed, 65 insertions, 57 deletions
| diff --git a/lib/LXRng/Markup/File.pm b/lib/LXRng/Markup/File.pm index d94952c..c3d576c 100644 --- a/lib/LXRng/Markup/File.pm +++ b/lib/LXRng/Markup/File.pm @@ -49,9 +49,8 @@ sub make_format_newline {  	$line++;  	$nl = safe_html($nl); -	return qq{$nl}. -	    qq{<a href="$name#L$line" class="line">$line</a>}. -	    qq{<a id="L$line" name="L$line"></a>}; +	return sprintf('%s<a href="%s#L%d" id="L%d" class="line" name="L%d">%4d</a>', +		       $nl, $name, $line, $line, $line, $line);      }  } diff --git a/lib/LXRng/Web.pm b/lib/LXRng/Web.pm index 36e6f55..0a49a16 100644 --- a/lib/LXRng/Web.pm +++ b/lib/LXRng/Web.pm @@ -88,13 +88,14 @@ sub print_markedup_file {  				  $context->release));  	my $cfile;  	$shaid =~ s,^(..)(..),$1/$2/,; +	$shaid .= '_2'; # Cache file format generation indicator  	$cfile = $context->config->{'cache'}.'/'.$shaid  	    if exists $context->config->{'cache'};  	if ($cfile and -e "$cfile/.complete") { -	    print("<pre id=\"file_contents\">"); +	    print("<div id=\"file_contents\">");  	    while (-r "$cfile/$line") { -		print("<div class=\"".($focus ? "done" : "pending"). +		print("<pre class=\"".($focus ? "done" : "pending").  		      "\" id=\"$shaid/$line\">");  		if ($focus) {  		    open(my $cache, '<', "$cfile/$line"); @@ -105,9 +106,9 @@ sub print_markedup_file {  		    close($cache);  		}  		else { -		    print("\n" x FRAGMENT_SIZE); +		    print("<a class=\"line\"></a>\n" x FRAGMENT_SIZE);  		} -		print("</div>"); +		print("</pre>");  		$line += FRAGMENT_SIZE;  		if (defined($fline)) { @@ -115,7 +116,7 @@ sub print_markedup_file {  			      and $line > ($fline - FRAGMENT_SIZE));  		}  	    } -	    print("</pre>\n"); +	    print("</div>\n");  	}  	else {  	    my $cache; @@ -131,8 +132,8 @@ sub print_markedup_file {  	    my $markup = LXRng::Markup::File->new('context' => $context);  	    my $subst  = $lang->markuphandlers($context, $node, $markup); -	    print("<pre id=\"file_contents\">". -		  "<div class=\"".($focus ? "done" : "pending"). +	    print("<div id=\"file_contents\">". +		  "<pre class=\"".($focus ? "done" : "pending").  		  "\" id=\"$shaid/0\">");  	    while (1) {  		my @frags = map { split(/(?<=\n)/, $_) } @@ -144,13 +145,14 @@ sub print_markedup_file {  		    if ($f =~ /\n$/s) {  			$line++;  			if ($line % FRAGMENT_SIZE == 0) { -			    print("\n" x FRAGMENT_SIZE) unless $focus; +			    print("<a class=\"line\"></a>\n" x FRAGMENT_SIZE) +				unless $focus;  			    if (defined($fline)) {  				$focus = ($line <= ($fline + 100)  					  and $line > ($fline - FRAGMENT_SIZE));  			    } -			    print("</div>". -				  "<div class=\"". +			    print("</pre>". +				  "<pre class=\"".  				  ($focus ? "done" : "pending").  				  "\" id=\"$shaid/$line\">");  			    if ($cache) { @@ -161,7 +163,7 @@ sub print_markedup_file {  		    }  		}  	    } -	    print("</div></pre>\n"); +	    print("</pre></div>\n");  	    if ($cache) {  		close($cache);  		open($cache, '>', "$cfile/.complete"); @@ -517,7 +519,7 @@ sub handle_ajax_request {      elsif ($context->param('fname') eq 'pjx_load_fragment') {  	my $shaid = $context->param('frag');  	return unless $shaid =~  -	    m|^[0-9a-z]{2}/[0-9a-z]{2}/[0-9a-z]{36}/[0-9]+$|; +	    m|^[0-9a-z]{2}/[0-9a-z]{2}/[0-9a-z]{36}_\d+/[0-9]+$|;  	return unless exists $context->config->{'cache'};  	my $cfile = $context->config->{'cache'}.'/'.$shaid;  	return unless -e $cfile; diff --git a/webroot/.static/css/lxrng.css b/webroot/.static/css/lxrng.css index 8b34b90..e5f5417 100644 --- a/webroot/.static/css/lxrng.css +++ b/webroot/.static/css/lxrng.css @@ -146,27 +146,27 @@ span.close-button {  	margin-right: 3px;  } -/* a.line:before { -	content: attr(id); -} */ +div#file_contents { +	padding-top: 10px; +}  pre { -	margin-left: 3.8em; +	margin-left: 0px; +	margin-top: 0px; +	margin-bottom: 0px; +	padding-top: 0px; +	padding-bottom: 0px;  }  a.line { -	position: absolute; -	top: auto; -	left: 0px; -	height: 2ex; -	width: 3em; -	text-align: right; -	padding-right: 3px; -  	border: solid;  	border-width: 1px;  	border-color: #000000; -	margin-left: 3px; +	margin-left: 0px; +	margin-right: 7px; +	padding-left: 3px; +	padding-right: 3px; +	  	background: #F0F0F0;  } @@ -248,7 +248,7 @@ div#content {  	min-height: 250px;  } -div.pending { +pre.pending {  	background-image: url(../gfx/loading.gif);  	background-position: top left;  	background-repeat: repeat-y; diff --git a/webroot/.static/js/lxrng-funcs.js b/webroot/.static/js/lxrng-funcs.js index c508dc9..2df711c 100644 --- a/webroot/.static/js/lxrng-funcs.js +++ b/webroot/.static/js/lxrng-funcs.js @@ -86,7 +86,6 @@ var loaded_hash;  var loaded_tree;  var loaded_file;  var loaded_ver; -var loaded_line;  var pending_tree;  var pending_file; @@ -132,7 +131,7 @@ function check_hash_navigation() {  			var a = document.getElementById(l);  			if (l && a) {  				a.name = location.hash.replace(/^\#/, ''); -				location.hash = a.name; +				document.location.hash = a.name;  				loaded_hash = location.hash;  			}  			hash_check = setTimeout('check_hash_navigation()', 50); @@ -210,16 +209,16 @@ function ajaxify_link_handlers(links) {  }  function load_next_pending_fragment() { -	var pre = document.getElementById('file_contents'); -	if (!pre) +	var listing = document.getElementById('file_contents'); +	if (!listing)  		return; -	for (var i = 0; i < pre.childNodes.length; i++) { -		if ((pre.childNodes[i].nodeName == 'DIV') && -		    (pre.childNodes[i].className == 'pending')) +	for (var i = 0; i < listing.childNodes.length; i++) { +		if ((listing.childNodes[i].nodeName == 'PRE') && +		    (listing.childNodes[i].className == 'pending'))  		{  			pjx_load_fragment(['tree__' + pending_tree, -					   'frag__' + pre.childNodes[i].id], +					   'frag__' + listing.childNodes[i].id],  					  [load_fragment_finalize]);  			return;  		} @@ -228,12 +227,22 @@ function load_next_pending_fragment() {  function load_fragment_finalize(content) {  	var split = content.indexOf('|'); -	var div = document.getElementById(content.substr(0, split)); +	var id = content.substr(0, split); +	var div = document.getElementById(id);  	if (!div)  		return; -	div.innerHTML = content.substr(split+1); -	div.className = 'done'; +	// Work around IE oddity where whitespace is collapsed on  +	// assignment to innerHTML unless contained in pre-tags... +	if (div.outerHTML) { +		div.outerHTML = '<pre class="done" id="' + id + '">' + +			content.substr(split+1) + '</pre>'; +		div = document.getElementById(id); +	} +	else { +		div.innerHTML = content.substr(split+1); +		div.className = 'done'; +	}  	var links = div.getElementsByTagName('a');  	ajaxify_link_handlers(links); @@ -282,25 +291,17 @@ function load_file_finalize(content) {  	if (hash_check) {  		clearTimeout(hash_check);  	} -	if (pending_line) { -		var anchor = document.getElementById('L' + pending_line); -		if (anchor) { -			anchor.name = full_path + '#L' + pending_line; -			location.hash = full_path + '#L' + pending_line; -		} -		else { -			location.hash = full_path; -		} -		loaded_line = pending_line; -	} -	else { -		location.hash = full_path; -		loaded_line = 0; -	} + +	location.hash = full_path;  	loaded_hash = location.hash;  	loaded_tree = pending_tree;  	loaded_file = pending_file;  	loaded_ver = pending_ver; + +	if (pending_line) { +		location.hash = full_path + '#L' + pending_line; +	} +  	hash_check = setTimeout('check_hash_navigation()', 50);  	ajaxify_link_handlers(document.links); @@ -320,8 +321,14 @@ function load_content() {  	}  	tree = tree[0].replace(/^#/, '');  	var file = location.hash.replace(/^[^\/]*\/?/, ''); -	var line = file.replace(/.*\#L(\d+)/, '$1'); -	file = file.replace(/\#L\d+$/, ''); +	var line = file.split('#L'); +	if (line.length > 1) { +		file = line[0]; +		line = line[1]; +	} +	else { +		line = ''; +	}  	load_file(tree, file, ver, line);  	pjx_releases(['tree__' + tree, 'NO_CACHE'], | 
