From 4dc9db546ea93b016f00da8276e3477101265c15 Mon Sep 17 00:00:00 2001 From: "jake%acutex.net" Date: Wed, 12 Dec 2001 22:41:19 +0000 Subject: [PATCH] Bug 37339 and Bug 80183 - Adding a sidebar.cgi and index.cgi. The sidebar.cgi can currently be used in Mozilla/Netscape 6 and uses XUL that was originally written by Scott Collins . The index.cgi displays both the proper header and footer in the appropriate places. It also changes the links accoding to if you are logged in or not. r= ddk, kiko --- webtools/bugzilla/.cvsignore | 2 +- webtools/bugzilla/checksetup.pl | 45 +++++++ webtools/bugzilla/css/panel.css | 37 ++++++ webtools/bugzilla/index.cgi | 90 +++++++++++++ webtools/bugzilla/index.html | 98 -------------- webtools/bugzilla/quicksearch.html | 4 +- webtools/bugzilla/quicksearch.js | 20 ++- webtools/bugzilla/quicksearchhack.html | 6 +- webtools/bugzilla/sidebar.cgi | 116 +++++++++++++++++ webtools/bugzilla/skins/standard/panel.css | 37 ++++++ webtools/bugzilla/template/default/index.tmpl | 83 ++++++++++++ .../template/default/sidebar/xul.tmpl | 121 ++++++++++++++++++ 12 files changed, 542 insertions(+), 117 deletions(-) create mode 100644 webtools/bugzilla/css/panel.css create mode 100755 webtools/bugzilla/index.cgi delete mode 100644 webtools/bugzilla/index.html create mode 100755 webtools/bugzilla/sidebar.cgi create mode 100644 webtools/bugzilla/skins/standard/panel.css create mode 100644 webtools/bugzilla/template/default/index.tmpl create mode 100644 webtools/bugzilla/template/default/sidebar/xul.tmpl diff --git a/webtools/bugzilla/.cvsignore b/webtools/bugzilla/.cvsignore index 64432ca1ef12..fb345b2b0a87 100644 --- a/webtools/bugzilla/.cvsignore +++ b/webtools/bugzilla/.cvsignore @@ -2,4 +2,4 @@ graphs data localconfig -shadow +index.html diff --git a/webtools/bugzilla/checksetup.pl b/webtools/bugzilla/checksetup.pl index 942c4e2ef3d5..99f2df13591b 100755 --- a/webtools/bugzilla/checksetup.pl +++ b/webtools/bugzilla/checksetup.pl @@ -282,6 +282,21 @@ sub LocalVar ($$) # Set up the defaults for the --LOCAL-- variables below: # +LocalVar('index_html', <<'END'); +# +# With the introduction of a configurable index page using the +# template toolkit, Bugzilla's main index page is now index.cgi. +# Most web servers will allow you to use index.cgi as a directory +# index and many come preconfigured that way, however if yours +# doesn't you'll need an index.html file that provides redirection +# to index.cgi. Setting $index_html to 1 below will allow +# checksetup.pl to create one for you if it doesn't exist. +# NOTE: checksetup.pl will not replace an existing file, so if you +# wish to have checksetup.pl create one for you, you must +# make sure that there isn't already an index.html +$index_html = 0; +END + my $mysql_binaries = `which mysql`; if ($mysql_binaries =~ /no mysql/) { # If which didn't find it, just provide a reasonable default @@ -473,6 +488,7 @@ my $my_db_port = ${*{$main::{'db_port'}}{SCALAR}}; my $my_db_name = ${*{$main::{'db_name'}}{SCALAR}}; my $my_db_user = ${*{$main::{'db_user'}}{SCALAR}}; my $my_db_pass = ${*{$main::{'db_pass'}}{SCALAR}}; +my $my_index_html = ${*{$main::{'index_html'}}{SCALAR}}; my $my_create_htaccess = ${*{$main::{'create_htaccess'}}{SCALAR}}; my $my_webservergroup = ${*{$main::{'webservergroup'}}{SCALAR}}; my @my_severities = @{*{$main::{'severities'}}{ARRAY}}; @@ -637,6 +653,35 @@ END } +if ($my_index_html) { + if (!-e "index.html") { + print "Creating index.html...\n"; + open HTML, ">index.html"; + print HTML <<'END'; + + + + + + +

I think you are looking for index.cgi

+ + +END + close HTML; + } + else { + open HTML, "index.html"; + if (! grep /index\.cgi/, ) { + print "\n\n"; + print "*** It appears that you still have an old index.html hanging\n"; + print " around. The contents of this file should be moved into a\n"; + print " template and placed in the 'template/custom' directory.\n\n"; + } + close HTML; + } +} + # Just to be sure ... unlink "data/versioncache"; diff --git a/webtools/bugzilla/css/panel.css b/webtools/bugzilla/css/panel.css new file mode 100644 index 000000000000..23b52705e283 --- /dev/null +++ b/webtools/bugzilla/css/panel.css @@ -0,0 +1,37 @@ +body + { + font-family: sans-serif; + font-size: 10pt; + background-color: white; + } + +ul + { + padding-left: 12px; + } + +radio + { + -moz-user-select: ignore; + } + +.text-link + { + margin-left: 3px; + } + +.text-link:hover + { + text-decoration: underline; + cursor: pointer; + } + +.descriptive-content + { + color: #AAAAAA; + } + +.descriptive-content[focused=true] + { + color: black; + } diff --git a/webtools/bugzilla/index.cgi b/webtools/bugzilla/index.cgi new file mode 100755 index 000000000000..5c300992dbd4 --- /dev/null +++ b/webtools/bugzilla/index.cgi @@ -0,0 +1,90 @@ +#!/usr/bonsaitools/bin/perl -wT +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# 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 Bugzilla Bug Tracking System. +# +# The Initial Developer of the Original Code is Netscape Communications +# Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): Jacob Steenhagen +# + +# Suppress silly "used only once" warnings +use vars qw{ %COOKIE }; + + +############################################################################### +# Script Initialization +############################################################################### + +# Make it harder for us to do dangerous things in Perl. +use diagnostics; +use strict; + +# Include the Bugzilla CGI and general utility library. +use lib "."; +require "CGI.pl"; + +# Establish a connection to the database backend. +ConnectToDatabase(); + +# Use the template toolkit (http://www.template-toolkit.org/) to generate +# the user interface (HTML pages and mail messages) using templates in the +# "template/" subdirectory. +use Template; + +# Create the global template object that processes templates and specify +# configuration parameters that apply to all templates processed in this script. +my $template = Template->new( + { + # Colon-separated list of directories containing templates. + INCLUDE_PATH => "template/custom:template/default", + # Allow templates to be specified with relative paths. + RELATIVE => 1, + POST_CHOMP => 1, + } +); + +# Define the global variables and functions that will be passed to the UI +# template. Individual functions add their own values to this hash before +# sending them to the templates they process. +my $vars = + { + # Function for retrieving global parameters. + 'Param' => \&Param , + + # Function for processing global parameters that contain references + # to other global parameters. + 'PerformSubsts' => \&PerformSubsts + }; + +# Check whether or not the user is logged in and, if so, set the $::userid +# and $::usergroupset variables. +quietly_check_login(); + +############################################################################### +# Main Body Execution +############################################################################### + +$vars->{'username'} = $::COOKIE{'Bugzilla_login'} || ''; +$vars->{'subst'} = { 'userid' => $vars->{'username'} }; + +# Return the appropriate HTTP response headers. +print "Content-Type: text/html\n\n"; + +# Generate and return the UI (HTML page) from the appropriate template. +$template->process("index.tmpl", $vars) + || DisplayError("Template process failed: " . $template->error()) + && exit; diff --git a/webtools/bugzilla/index.html b/webtools/bugzilla/index.html deleted file mode 100644 index 3a1a76ff6c4e..000000000000 --- a/webtools/bugzilla/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - -Bugzilla Main Page - - -
- - - - - -
- - - - - -
- - Main Page - -
- - - -
- -
- - This is Bugzilla: the Mozilla bug system. For more - information about what Bugzilla is and what it can do, see - mozilla.org's - bug pages. -
- - - - - -This is where we put in lots of nifty words explaining all about -bugzilla. - -

- -But it all boils down to a choice of: -
-Query existing bug reports
-Enter a new bug report
-Get summary reports
-

-Open a new Bugzilla account
-Forget the currently stored login
-Change password or user preferences
-

- - - -

- Enter a bug # or some search terms:
- - - [Help] -
- - - - - diff --git a/webtools/bugzilla/quicksearch.html b/webtools/bugzilla/quicksearch.html index 900180065bf4..df7e85ccf006 100644 --- a/webtools/bugzilla/quicksearch.html +++ b/webtools/bugzilla/quicksearch.html @@ -18,10 +18,8 @@ you may prefer this form. Type in one or more words (or word fragments) to search for: - -
+ onsubmit="QuickSearch(f.id.value); return false;"> diff --git a/webtools/bugzilla/quicksearch.js b/webtools/bugzilla/quicksearch.js index 7778d3598daa..e8834a7222a3 100644 --- a/webtools/bugzilla/quicksearch.js +++ b/webtools/bugzilla/quicksearch.js @@ -46,8 +46,11 @@ function do_shift(l) { } function go_to (url) { - document.location.href = url; - //window.open(url, "other" ); + if (sidebar == 1) { + load_relative_url(url); + } else { + document.location.href = url; + } } function map(l, f) { @@ -600,8 +603,7 @@ function unique_id () { return (new Date()).getTime(); } -function ShowURL(mode) { - var input = document.f.id.value; +function ShowURL(mode,input) { var searchURL = make_query_URL(bugzilla+"buglist.cgi", input, false); if (searchURL != no_result) { var pieces = searchURL.replace(/[\?]/g,"\n?").replace(/[\&]/g,"\n&"); @@ -684,7 +686,7 @@ function Search(url, input, searchLong) { // derived from http://www.cs.hmc.edu/~jruderma/s/bugz.html // QuickSearch combines lookup-by-bug-number and search -// in a single textbox. It's name must be document.f.id . +// in a single textbox. // // type nothing: // --> go to bugzilla front page @@ -696,10 +698,8 @@ function Search(url, input, searchLong) { // --> search summary, product, component, keywords, status whiteboard // (and URL if it's an IP address, a host.name, or an absolute://URL) -function QuickSearch () +function QuickSearch (input) { - var input = document.f.id.value; - //remove leading and trailing whitespace input = input.replace(/^[\s]+/,"").replace(/[\s]+$/,""); @@ -726,9 +726,7 @@ function QuickSearch () return; } -function LoadQuery() { - var input = document.f.id.value; - +function LoadQuery(input) { //remove leading and trailing whitespace input = input.replace(/^[\s]+/,"").replace(/[\s]+$/,""); diff --git a/webtools/bugzilla/quicksearchhack.html b/webtools/bugzilla/quicksearchhack.html index 7d788f626219..70dcb4b555c4 100644 --- a/webtools/bugzilla/quicksearchhack.html +++ b/webtools/bugzilla/quicksearchhack.html @@ -12,16 +12,14 @@ Type in one or more words (or word fragments) to search for: - - + onsubmit="QuickSearch(f.id.value); return false;">
+ onclick="LoadQuery(f.id.value);" />
diff --git a/webtools/bugzilla/sidebar.cgi b/webtools/bugzilla/sidebar.cgi new file mode 100755 index 000000000000..587b0c53434f --- /dev/null +++ b/webtools/bugzilla/sidebar.cgi @@ -0,0 +1,116 @@ +#!/usr/bonsaitools/bin/perl -wT +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# 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 Bugzilla Bug Tracking System. +# +# Contributor(s): Jacob Steenhagen + +use strict; +use diagnostics; + +use lib "."; +require "CGI.pl"; + +# Shut up "Used Only Once" errors +use vars qw { $anyvotesallowed }; + +ConnectToDatabase(); + +# Use the template toolkit (http://www.template-toolkit.org/) to generate +# the user interface (HTML pages and mail messages) using templates in the +# "template/" subdirectory. +use Template; + +# Create the global template object that processes templates and specify +# configuration parameters that apply to all templates processed in this script. +my $template = Template->new( + { + # Colon-separated list of directories containing templates. + INCLUDE_PATH => "template/custom:template/default", + # Allow templates to be specified with relative paths. + RELATIVE => 1, + POST_CHOMP =>1, + # Functions for processing text within templates + FILTERS => + { + url => \&url_quote, + }, + } +); + +# Define the global variables and functions that will be passed to the UI +# template. Individual functions add their own values to this hash before +# sending them to the templates they process. +my $vars = + { + # Function for retrieving global parameters. + 'Param' => \&Param , + + # Function that tells us if the logged in user is in a specific group. + 'UserInGroup' => \&UserInGroup , + }; + + +# Needed for $::anyvotesallowed +GetVersionTable(); + +# Check to see if the user has logged in yet. +quietly_check_login(); + +############################################################################### +# Main Body Execution +############################################################################### + +$vars->{'username'} = $::COOKIE{'Bugzilla_login'} || ''; +$vars->{'anyvotesallowed'} = $::anyvotesallowed; + +if (defined $::COOKIE{'Bugzilla_login'}) { + SendSQL("SELECT mybugslink, userid, blessgroupset FROM profiles " . + "WHERE login_name = " . SqlQuote($::COOKIE{'Bugzilla_login'})); + my ($mybugslink, $userid, $blessgroupset) = (FetchSQLData()); + $vars->{'userid'} = $userid; + $vars->{'blessgroupset'} = $blessgroupset; + if ($mybugslink) { + my $mybugstemplate = Param("mybugstemplate"); + my %substs = ( 'userid' => url_quote($::COOKIE{'Bugzilla_login'}) ); + $vars->{'mybugsurl'} = PerformSubsts($mybugstemplate, \%substs); + } + SendSQL("SELECT name FROM namedqueries WHERE userid = $userid AND linkinfooter"); + while (MoreSQLData()) { + my ($name) = FetchSQLData(); + push(@{$vars->{'namedqueries'}}, $name); + } +} + +# This sidebar is currently for use with Mozilla based web browsers. +# Internet Explorer 6 is supposed to have a similar feature, but it +# most likely won't support XUL ;) When that does come out, this +# can be expanded to output normal HTML for IE. Until then, I like +# the way Scott's sidebar looks so I'm using that as the base for +# this file. +# http://bugzilla.mozilla.org/show_bug.cgi?id=37339 + +my $useragent = $ENV{HTTP_USER_AGENT}; +if ($useragent =~ m:Mozilla/([1-9][0-9]*):i && $1 >= 5 && $useragent !~ m/compatible/i) { + print "Content-type: application/vnd.mozilla.xul+xml\n\n"; + # Generate and return the XUL from the appropriate template. + $template->process("sidebar/xul.tmpl", $vars) + || DisplayError("Template process failed: " . $template->error()) + && exit; +} else { + DisplayError("sidebar.cgi currently only supports Mozilla based web browsers"); + exit; +} + + + diff --git a/webtools/bugzilla/skins/standard/panel.css b/webtools/bugzilla/skins/standard/panel.css new file mode 100644 index 000000000000..23b52705e283 --- /dev/null +++ b/webtools/bugzilla/skins/standard/panel.css @@ -0,0 +1,37 @@ +body + { + font-family: sans-serif; + font-size: 10pt; + background-color: white; + } + +ul + { + padding-left: 12px; + } + +radio + { + -moz-user-select: ignore; + } + +.text-link + { + margin-left: 3px; + } + +.text-link:hover + { + text-decoration: underline; + cursor: pointer; + } + +.descriptive-content + { + color: #AAAAAA; + } + +.descriptive-content[focused=true] + { + color: black; + } diff --git a/webtools/bugzilla/template/default/index.tmpl b/webtools/bugzilla/template/default/index.tmpl new file mode 100644 index 000000000000..8c1af4ed6c8f --- /dev/null +++ b/webtools/bugzilla/template/default/index.tmpl @@ -0,0 +1,83 @@ +[%# -*- mode: html -*- %] +[%# 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 Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is Netscape Communications + # Corporation. Portions created by Netscape are + # Copyright (C) 1998 Netscape Communications Corporation. All + # Rights Reserved. + # + # Contributor(s): Terry Weissman + # Jacob Steenhagen + #%] + +[% INCLUDE global/header + title = 'Bugzilla Main Page' +%] + + + + + + + +
+

This is where we put in lots of nifty words explaining all about Bugzilla.

+ + But it all boils down to a choice of: +

+ Query existing bug reports
+ Enter a new bug report
+ Get summary reports
+

+[% IF username %] + My Bugs
+ Change password or user preferences
+ Logout [% username %]
+[% ELSE %] + Log in to an existing account
+ Open a new Bugzilla account
+[% END %] +

+ Add to Sidebar (Requires Mozilla or Netscape 6)
+

+ +

+ Enter a bug # or some search terms:
+ + + [Help] +

+ +
ant.jpg [8.5k]
+ + + + + +[% INCLUDE global/footer %] diff --git a/webtools/bugzilla/template/default/sidebar/xul.tmpl b/webtools/bugzilla/template/default/sidebar/xul.tmpl new file mode 100644 index 000000000000..1794d5f50341 --- /dev/null +++ b/webtools/bugzilla/template/default/sidebar/xul.tmpl @@ -0,0 +1,121 @@ +[%# -*- mode: sgml -*- %] +[%# 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 Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is Netscape Communications + # Corporation. Portions created by Netscape are + # Copyright (C) 1998 Netscape Communications Corporation. All + # Rights Reserved. + # + # Contributor(s): Jacob Steenhagen + # Scott Collins + #%] + + + + + +// Load QuickSearch libraries + + + + + + + + + + + + + +[% IF username %] + +[% END %] +[% IF UserInGroup('tweakparams') %] + +[% END %] +[% IF UserInGroup('editusers') || blessgroupset %] + +[% END %] +[% IF UserInGroup('editcomponents') %] + +[% END %] +[% IF UserInGroup('creategroups') %] + +[% END %] +[% IF UserInGroup('editkeywords') %] + +[% END %] +[% IF UserInGroup('tweakparams') %] + +[% END %] +[% IF username %] + + +[% END %] + +[% IF mybugsurl %] + +[% END %] +[% IF anyvotesallowed && username %] + +[% END %] + +[% FOREACH name = namedqueries %] + +[% END %] + +[% IF NOT username %] + + +[% END %] + + + + + + + + + reload + + +