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 <scc@mozilla.org>. 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
This commit is contained in:
jake%acutex.net 2001-12-12 22:41:19 +00:00
Родитель 2451f6c4f4
Коммит 356464f357
11 изменённых файлов: 505 добавлений и 19 удалений

Просмотреть файл

@ -2,4 +2,4 @@
graphs
data
localconfig
shadow
index.html

Просмотреть файл

@ -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';
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=index.cgi">
</HEAD>
<BODY>
<H1>I think you are looking for <a href="index.cgi">index.cgi</a></H1>
</BODY>
</HTML>
END
close HTML;
}
else {
open HTML, "index.html";
if (! grep /index\.cgi/, <HTML>) {
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";

Просмотреть файл

90
webtools/bugzilla/index.cgi Executable file
Просмотреть файл

@ -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 <jake@acutex.net>
#
# 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;

Просмотреть файл

@ -18,10 +18,8 @@ you may prefer <a href="quicksearchhack.html">this form</a>.
Type in one or more words (or word fragments) to search for:
<!-- The name of the form must be "f" (used in "quicksearch.js"). -->
<form name="f" action="show_bug.cgi" method="get"
onsubmit="QuickSearch(); return false;">
onsubmit="QuickSearch(f.id.value); return false;">
<table>
<tr>
<td><input type="text" size="40" name="id"/></td>

Просмотреть файл

@ -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]+$/,"");

Просмотреть файл

@ -12,16 +12,14 @@
Type in one or more words (or word fragments) to search for:
<!-- The name of the form must be "f" (used in "quicksearch.js"). -->
<form name="f" action="show_bug.cgi" method="get"
onsubmit="QuickSearch(); return false;">
onsubmit="QuickSearch(f.id.value); return false;">
<table>
<tr>
<td><input type="text" size="40" name="id"/></td>
<td align=left><input type="submit" name="run" value="Search"/></td>
<td align=left><input type="button" name="load" value="Load Query"
onclick="LoadQuery();" />
onclick="LoadQuery(f.id.value);" />
</td>
</tr>
</table>

116
webtools/bugzilla/sidebar.cgi Executable file
Просмотреть файл

@ -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 <jake@acutex.net>
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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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 <terry@mozilla.org>
# Jacob Steenhagen <jake@acutex.net>
#%]
[% INCLUDE global/header
title = 'Bugzilla Main Page'
%]
<script type="text/javascript" language="JavaScript">
<!--
function addSidebar() {
if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
{
window.sidebar.addPanel ("Bugzilla", "[% Param('urlbase') %]sidebar.cgi", "");
}
else
{
var rv = window.confirm ("This page is enhanced for use with Netscape 6. " + "Would you like to upgrade now?");
if (rv)
document.location.href = "http://home.netscape.com/download/index.html";
}
}
//-->
</script>
<table width="100%"><tr>
<td>
<p>This is where we put in lots of nifty words explaining all about Bugzilla.</p>
But it all boils down to a choice of:
<p>
<a href="query.cgi">Query existing bug reports</a><br>
<a href="enter_bug.cgi">Enter a new bug report</a><br>
<a href="reports.cgi">Get summary reports</a><br>
</p><p>
[% IF username %]
<a href="[% PerformSubsts(Param('mybugstemplate'), subst) %]">My Bugs</a><br>
<a href="userprefs.cgi">Change password or user preferences</a><br>
<a href="relogin.cgi">Logout [% username %]</a><br>
[% ELSE %]
<a href="query.cgi?GoAheadAndLogIn=1">Log in to an existing account</a><br>
<a href="createaccount.cgi">Open a new Bugzilla account</a><br>
[% END %]
</p><p>
<a href="javascript:addSidebar()">Add to Sidebar</a> (Requires Mozilla or Netscape 6)<br>
</p>
<form name="f" action="show_bug.cgi" method="get"
onsubmit="QuickSearch(f.id.value); return false;">
<p>
Enter a bug # or some search terms:<br>
<input type="text" name="id">
<input type="submit" value="Show">
<a href="quicksearch.html">[Help]</a>
</p>
</form>
</td>
<td align="right"><img src="ant.jpg" width=329 height=220 border=2 alt="ant.jpg [8.5k]"></td>
</tr></table>
<script type="text/javascript" language="JavaScript" src="localconfig.js"></script>
<script type="text/javascript" language="JavaScript" src="quicksearch.js"></script>
[% INCLUDE global/footer %]

Просмотреть файл

@ -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 <jake@acutex.net>
# Scott Collins <scc@mozilla.org>
#%]
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="[% Param('urlbase') %]css/panel.css" type="text/css"?>
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
orient="vertical"
onload="document.getElementById('query-field').addEventListener('keypress', initial_keypress_handler, true)">
// Load QuickSearch libraries
<script type="text/javascript" language="JavaScript" src="localconfig.js"/>
<script type="text/javascript" language="JavaScript" src="quicksearch.js"/>
<script type="text/javascript" language="JavaScript">
// Tell QuickSearch that the source of this is the sidebar
var sidebar = 1;
function load_relative_url( aRelativeURL ) {
aRelativeURL = '[% Param('urlbase') %]' + aRelativeURL;
_content.location = aRelativeURL;
}
function initial_keypress_handler( aEvent ) {
this.removeAttribute("class");
this.addEventListener("keypress", normal_keypress_handler, true);
this.removeEventListener("keypress", initial_keypress_handler, true);
}
function normal_keypress_handler( aEvent ) {
if ( aEvent.keyCode == 13 )
QuickSearch(this.value);
}
</script>
<textbox id="query-field" class="descriptive-content" value="enter query" onfocus="this.setSelectionRange(0,this.value.length)"/>
<separator class="groove"/>
<box autostretch="never" valign="top">
<box orient="vertical" flex="1">
<text class="text-link" onclick="load_relative_url('query.cgi')" value="new query"/>
<text class="text-link" onclick="load_relative_url('reports.cgi')" value="reports"/>
<text class="text-link" onclick="load_relative_url('enter_bug.cgi')" value="new bug"/>
<separator class="thin"/>
[% IF username %]
<text class="text-link" onclick="load_relative_url('userprefs.cgi')" value="edit prefs"/>
[% END %]
[% IF UserInGroup('tweakparams') %]
<text class="text-link" onclick="load_relative_url('editparams.cgi')" value="edit params"/>
[% END %]
[% IF UserInGroup('editusers') || blessgroupset %]
<text class="text-link" onclick="load_relative_url('editusers.cgi')" value="edit users"/>
[% END %]
[% IF UserInGroup('editcomponents') %]
<text class="text-link" onclick="load_relative_url('editcomponents.cgi')" value="edit components"/>
[% END %]
[% IF UserInGroup('creategroups') %]
<text class="text-link" onclick="load_relative_url('editgroups.cgi')" value="edit groups"/>
[% END %]
[% IF UserInGroup('editkeywords') %]
<text class="text-link" onclick="load_relative_url('editkeywords.cgi')" value="edit keywords"/>
[% END %]
[% IF UserInGroup('tweakparams') %]
<text class="text-link" onclick="load_relative_url('sanitycheck.cgi')" value="sanity check"/>
[% END %]
[% IF username %]
<text class="text-link" onclick="load_relative_url('relogin.cgi')" value="logout [% username FILTER html %]"/>
<separator class="thin"/>
[% END %]
[% IF mybugsurl %]
<text class="text-link" onclick="load_relative_url('[% mybugsurl FILTER html %]')" value="my bugs"/>
[% END %]
[% IF anyvotesallowed && username %]
<text class="text-link" onclick="load_relative_url('showvotes.cgi')" value="my votes"/>
[% END %]
[% FOREACH name = namedqueries %]
<text class="text-link" onclick="load_relative_url('buglist.cgi?cmdtype=runnamed&amp;namedcmd=[% name FILTER url %]')" value="[% name FILTER html %]"/>
[% END %]
[% IF NOT username %]
<text class="text-link" onclick="load_relative_url('createaccount.cgi')" value="new user"/>
<text class="text-link" onclick="load_relative_url('query.cgi?GoAheadAndLogIn=1')" value="log in"/>
[% END %]
</box>
</box>
<spring flex="1"/>
<box orient="horizontal">
<spring flex="1"/>
<html align="right">
<html:a class="text-link" href="[% Param('urlbase') %]sidebar.cgi">reload</html:a>
</html>
</box>
</window>