diff --git a/mozilla/webtools/registry/file.cgi b/mozilla/webtools/registry/file.cgi index 49ef5481c19..91c0c637cdc 100755 --- a/mozilla/webtools/registry/file.cgi +++ b/mozilla/webtools/registry/file.cgi @@ -1,105 +1,38 @@ -#!/usr/bin/perl +#!/usr/bin/perl -wT # -*- Mode: perl; indent-tabs-mode: nil -*- + +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1 # -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. # # The Original Code is the Application Registry. # -# The Initial Developer of the Original Code is Netscape Communications -# Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All +# The Initial Developer of the Original Code is Mozilla Corporation. Portions +# created by Mozilla Corporation are Copyright (C) 2007 Mozilla Foundation. All # Rights Reserved. # -# Contributor(s): +# Contributor(s): Dave Miller +# +# ***** END LICENSE BLOCK ***** -require 'lloydcgi.pl'; -$|=1; +use CGI (qw(-oldstyle_urls)); +use Template; -$filename= $form{"file"}; -$dirname= $form{"dir"}; -$branch= $form{"branch"}; -$cvsroot= $form{"cvsroot"}; -$rev= $form{"rev"}; -$prev_rev= $form{"prev_rev"}; -$linked_text= $form{"linked_text"}; -$linked_text = $filename if $linked_text eq ''; +my $bonsai_root = "../bonsai"; -$branch = $rev if $branch eq '' && $rev =~ /[A-Za-z]/; +my $cgi = new CGI; +$cgi->charset('UTF-8'); -@extra_url = (); -@extra_text = (); +my $template = new Template; -print "Content-type: text/html\n\n\n"; - -print "
\n"; - -&load_extra_data; - - -$i = 0; -while( $i < @extra_text ){ - $t = $extra_text[$i]; - if( $u = $extra_url[$i] ){ - - print("
$t\n"); - } - else { - print("
$t\n"); - } - $i++; -} - -if( @extra_text ){ - print("
\n"); -} - - -$dirname2 = $dirname; - -$dirname2 =~ s/^ns\///; - -print " -$linked_text - -
- View Blame-Annotated Source -"; -if ($prev_rev ne '') { - print "
View Diff $prev_rev vs. $rev"; -} else { - - print "
" - ."View Diff's"; -} - -print "
- View Logs -"; - -print " -
"; - -sub load_extra_data { - local( $i, $u, $t ); - - $i = 0; - while( ($u = $form{"u${i}"}) ne "" || $form{"t${i}"} ne "" ) { - $t = $form{"t${i}"}; - if( $t eq "" ) {$t = $u }; - $extra_url[$i] = $u; - $extra_text[$i] = $t; - $i++; - } -} +print $cgi->header("text/html"); +$template->process("file.html.tmpl", { bonsai_root => $bonsai_root }) || die "Couldn't process template: $@"; diff --git a/mozilla/webtools/registry/file.html.tmpl b/mozilla/webtools/registry/file.html.tmpl new file mode 100644 index 00000000000..916bd4c6c29 --- /dev/null +++ b/mozilla/webtools/registry/file.html.tmpl @@ -0,0 +1,110 @@ +[%# -*- Mode: perl; indent-tabs-mode: nil -*- + +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Application Registry. +# +# The Initial Developer of the Original Code is Mozilla Corporation. Portions +# created by Mozilla Corporation are Copyright (C) 2007 Mozilla Foundation. +# All Rights Reserved. +# +# Contributor(s): Dave Miller +# +# ***** END LICENSE BLOCK ***** + +-%] +[%- USE CGI; + filename = CGI.param('file'); + dirname = CGI.param('dir'); + cvsroot = CGI.param('cvsroot'); + rev = CGI.param('rev'); + prev_rev = CGI.param('prev_rev'); + linked_text = CGI.param('linked_text'); + SET linked_text = filename IF NOT linked_text; + branch = CGI.param('branch'); + SET branch = rev IF (NOT branch) OR rev.match('[A-Za-z]'); + extralist = []; + i = 0; + WHILE CGI.param("u$i") OR CGI.param("t$i"); + u = CGI.param("u$i"); + t = CGI.param("t$i"); + SET t = u IF NOT t; + extralist.push( { url => u, text => t } ); + i = i + 1; + END; +-%] + + + +[% linked_text FILTER html %] - Registry + + + + + + +
+ [% IF extralist.size > 0 %] + [% FOREACH extra IN extralist %] + [% IF extra.url %] + [% extra.text FILTER html %]
+ [% ELSE %] + [% extra.text FILTER html %]
+ [% END %] + [% END %] +
+ [% END %] + [% linked_text FILTER html %]
+ [% FILTER null; + cgi = CGI.new(''); + cgi.param('file', "$dirname/$filename"); + cgi.param('rev', rev); + cgi.param('cvsroot', cvsroot); + END; -%] + View Blame-Annotated Source
+ [% IF prev_rev %] + [% FILTER null; + cgi = CGI.new(''); + cgi.param('diff_mode', 'context'); + cgi.param('whitespace_mode', 'show'); + cgi.param('root', cvsroot); + cgi.param('subdir', dirname); + cgi.param('command', 'DIFF_FRAMESET'); + cgi.param('file', filename); + cgi.param('rev1', rev); + cgi.param('rev2', prev_rev); + END; -%] + View Diff [% prev_rev FILTER html %] vs. [% rev FILTER html %]
+ [% ELSE %] + [% FILTER null; + cgi = CGI.new(''); + cgi.param('subdir', dirname); + cgi.param('files', filename); + cgi.param('command', 'DIRECTORY'); + cgi.param('branch', branch); + cgi.param('root', cvsroot); + END; -%] + View Diffs
+ [% END %] + [% FILTER null; + cgi = CGI.new(''); + cgi.param('file', "$dirname/$filename"); + cgi.param('rev', rev); + cgi.param('root', cvsroot); + END; - %] + View Logs +
+ +