diff options
Diffstat (limited to 'cgi-bin')
-rw-r--r-- | cgi-bin/css/lxrng.css | 6 | ||||
-rw-r--r-- | cgi-bin/js/lxrng-funcs.js | 47 | ||||
-rwxr-xr-x | cgi-bin/lxr | 66 |
3 files changed, 75 insertions, 44 deletions
diff --git a/cgi-bin/css/lxrng.css b/cgi-bin/css/lxrng.css index 9a47d80..637c774 100644 --- a/cgi-bin/css/lxrng.css +++ b/cgi-bin/css/lxrng.css @@ -273,6 +273,12 @@ div.progress { font-style: italic; } +div.error { + font-weight: bold; + font-style: italic; + color: #E04040; +} + form { display: inline; } diff --git a/cgi-bin/js/lxrng-funcs.js b/cgi-bin/js/lxrng-funcs.js index d7c9be8..614879e 100644 --- a/cgi-bin/js/lxrng-funcs.js +++ b/cgi-bin/js/lxrng-funcs.js @@ -74,12 +74,18 @@ var pending_ver; var pending_line; function ajax_nav() { - var file = this.href.replace(/^(http:.*?lxr\/[+]ajax\/|)/, ''); - // alert(loaded_file + ' - ' + file); + var file = this.href.replace(/^(http:.*?\/.*?[+][*]\/|)/, ''); load_file(loaded_tree, file, loaded_ver, ''); return false; } +function ajax_jumpto_line() { + location.hash = location.hash.replace(/\#L\d+$/, '') + + this.href.replace(/.*(\#L\d+)$/, '$1'); + check_hash_navigation(); + return false; +} + function ajax_prefs() { if (use_ajax_navigation) { var full_path = location.href.split(/#/)[0]; @@ -102,12 +108,14 @@ function check_hash_navigation() { if (location.hash.replace(/\#L\d+$/, '') == loaded_hash.replace(/\#L\d+$/, '')) { - var l = location.hash.replace(/.*(\#L\d+)$/, '$1'); + var l = location.hash.replace(/.*#(L\d+)$/, '$1'); var a = document.getElementById(l); if (l && a) { - a.name = location.hash; + a.name = location.hash.replace(/^\#/, ''); location.hash = a.name; + loaded_hash = location.hash; } + hash_check = setTimeout('check_hash_navigation()', 50); } else { // alert(location.hash + ' / ' + loaded_hash); @@ -150,6 +158,7 @@ function load_file(tree, file, ver, line) { function load_file_finalize(content) { var res = document.getElementById('content'); + res.innerHTML = 'Done'; res.innerHTML = content; var head = document.getElementById('current_path'); head.innerHTML = '<a class=\"fref\" href=\".\">' + pending_tree + '</a>'; @@ -165,11 +174,11 @@ function load_file_finalize(content) { } document.title = 'LXR ' + pending_tree + '/' + pending_file; - var full_path = pending_tree; + var full_tree = pending_tree; if (pending_ver) { - full_path = full_path + '+' + pending_ver; + full_tree = full_tree + '+' + pending_ver; } - full_path = full_path + '/' + pending_file.replace(/^\/?/, ''); + var full_path = full_tree + '/' + pending_file.replace(/^\/?/, ''); var pre = document.getElementById('file_contents'); if (pre && pre.className == 'partial') { @@ -178,6 +187,9 @@ function load_file_finalize(content) { [load_file_finalize]); } + if (hash_check) { + clearTimeout(hash_check); + } if (pending_line) { var anchor = document.getElementById('L' + pending_line); if (anchor) { @@ -197,18 +209,18 @@ function load_file_finalize(content) { loaded_tree = pending_tree; loaded_file = pending_file; loaded_ver = pending_ver; - if (hash_check) { - clearTimeout(hash_check); - } hash_check = setTimeout('check_hash_navigation()', 50); +// return; +// TODO: This really takes oodles of time. Consider coding into html. var i; for (i = 0; i < document.links.length; i++) { - if (document.links[i].className == 'fref' || - document.links[i].className == 'line') - { + if (document.links[i].className == 'fref') { document.links[i].onclick = ajax_nav; } + else if (document.links[i].className == 'line') { + document.links[i].onclick = ajax_jumpto_line; + } else if (document.links[i].className == 'sref' || document.links[i].className == 'falt') { @@ -243,8 +255,10 @@ function load_content_finalize(content) { function update_version(verlist, base_url, tree, defversion, path) { if (use_ajax_navigation) { var file = location.hash.replace(/^[^\/]*\//, ''); + var line = file.replace(/.*\#L(\d+)/, '$1'); + file = file.replace(/\#L\d+$/, ''); - load_file(loaded_tree, file, verlist.value, ''); + load_file(loaded_tree, file, verlist.value, line); return false; } else { @@ -279,7 +293,10 @@ function ajax_lookup_anchor(event, anchor) { if (!anchor) anchor = this; - lookup = anchor.href.replace(/^(http:.*?lxr\/[+]ajax\/|)/, ''); + // TODO: Fix +// lookup = anchor.href.replace(/^(http:.*?lxr\/[+]ajax\/|)/, ''); + lookup = anchor.href.replace(/^(http:.*?\/.*?[+][*]\/|)/, ''); + var lvar = document.getElementById('ajax_lookup'); lvar.value = lookup; diff --git a/cgi-bin/lxr b/cgi-bin/lxr index cda9179..a0c0f6e 100755 --- a/cgi-bin/lxr +++ b/cgi-bin/lxr @@ -4,7 +4,6 @@ use strict; use FindBin; use lib "$FindBin::Bin/../lib"; -use lib '/home/argggh/www/lxrng/_deps/share/perl/5.8.4'; use CGI::Carp qw(fatalsToBrowser); use IO::Handle; @@ -51,6 +50,11 @@ sub print_markedup_file { autoflush STDOUT 1; + unless ($node) { + print('<div class="error">File not found.</div>'); + return; + } + if ($node->isa('LXRng::Repo::Directory')) { my $markup = LXRng::Markup::Dir->new('context' => $context, 'node' => $node); @@ -126,29 +130,29 @@ sub print_release_list { } sub source { - my ($context, $template, $query) = @_; + my ($context, $template, $query, $template_extra_args) = @_; - my $pjx = CGI::Ajax->new('pjx_search' => 'lxr', - 'pjx_load_file' => 'lxr', - 'pjx_releases' => 'lxr'); + my $pjx = CGI::Ajax->new('pjx_search' => '', + 'pjx_load_file' => '', + 'pjx_releases' => ''); $pjx->js_encode_function('escape'); - + if ($context->prefs and $context->prefs->{'navmethod'} eq 'ajax') { - my $path = $query->path_info; - $path =~ s,^/[+ ],,; - if ($path ne '') { - $path =~ s,^/+,,; - print($query->redirect($query->url(-full => 1). - '#'.$path)); + if ($context->tree ne '') { + my $base = $context->base_url(1); + my $path = $context->vtree.'/'.$context->path; + print($query->redirect($base.'#'.$path)); } else { print($query->header(-type => 'text/html', -charset => 'utf-8')); - my $base = $query->url(-full => 1); + my $base = $context->base_url(1); + $base =~ s,/*$,/ajax+*/,; + $template->process('main.tt2', {'context' => $context, - 'base_url' => $base.'/+ajax/', + 'base_url' => $base, 'javascript' => $pjx->show_javascript(), 'is_ajax' => 1}) or die $template->error(); @@ -168,11 +172,13 @@ sub source { my $ver = $context->release; my $rep = $context->config->{'repository'}; - my $node = $rep->node($context->path, $ver); + die "No tree given" unless $rep; + my $node = $rep->node($context->path, $ver); die "Node not found: ".$context->path." ($ver)" unless $node; - my %template_args = ('context' => $context, + my %template_args = (%{$template_extra_args || {}}, + 'context' => $context, 'tree' => $context->tree, 'node' => $node, 'base_url' => $context->base_url, @@ -288,7 +294,7 @@ sub search { $$ident[5] &&= $LXRng::Lang::deftypes{$$ident[5]}; use Data::Dumper; - warn Dumper($symname, $symid, $ident, $refs); + # warn Dumper($symname, $symid, $ident, $refs); $template_args{'ident_res'} = {'query' => $symname, 'ident' => $ident, 'refs' => $refs}; @@ -326,26 +332,23 @@ sub search_result { 'search_res' => $result, 'base_url' => $context->base_url); - my $gzip = do_compress_response($query); + if ($context->prefs and $context->prefs->{'navmethod'} eq 'popup') { + my $gzip = do_compress_response($query); - print($query->header(-type => 'text/html', - -charset => 'utf-8', - $gzip ? (-content_encoding => 'gzip') : ())); + print($query->header(-type => 'text/html', + -charset => 'utf-8', + $gzip ? (-content_encoding => 'gzip') : ())); - binmode(\*STDOUT, ":gzip") if $gzip; + binmode(\*STDOUT, ":gzip") if $gzip; - if ($context->prefs and $context->prefs->{'navmethod'} eq 'popup') { $template->process('popup_main.tt2', {%template_args, 'is_popup' => 1}) or die $template->error(); } else { - $template->process('main.tt2', - {%template_args, - 'file_content' => '', - 'is_dir' => 0}) - or die $template->error(); + $context->path(''); + source($context, $template, $query, \%template_args); } } @@ -423,8 +426,13 @@ sub handle_preferences { print($query->header(-type => 'text/html', -charset => 'utf-8')); + my $nav = 'is_replace'; + $nav = 'is_'.$context->prefs->{'navmethod'} if + $context->prefs and $context->prefs->{'navmethod'} ne ''; + $template->process('prefs.tt2', - {'return' => $query->param('return')}) + {'return' => $query->param('return'), + $nav => 1}) or die $template->error(); } } |