sidebar.cgi 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env perl -wT
  2. # -*- Mode: perl; indent-tabs-mode: nil -*-
  3. #
  4. # The contents of this file are subject to the Mozilla Public
  5. # License Version 1.1 (the "License"); you may not use this file
  6. # except in compliance with the License. You may obtain a copy of
  7. # the License at http://www.mozilla.org/MPL/
  8. #
  9. # Software distributed under the License is distributed on an "AS
  10. # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11. # implied. See the License for the specific language governing
  12. # rights and limitations under the License.
  13. #
  14. # The Original Code is the Bugzilla Bug Tracking System.
  15. #
  16. # Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
  17. use strict;
  18. use lib qw(. lib);
  19. use Bugzilla;
  20. use Bugzilla::Error;
  21. Bugzilla->login();
  22. my $cgi = Bugzilla->cgi;
  23. my $template = Bugzilla->template;
  24. ###############################################################################
  25. # Main Body Execution
  26. ###############################################################################
  27. # This sidebar is currently for use with Mozilla based web browsers.
  28. # Internet Explorer 6 is supposed to have a similar feature, but it
  29. # most likely won't support XUL ;) When that does come out, this
  30. # can be expanded to output normal HTML for IE. Until then, I like
  31. # the way Scott's sidebar looks so I'm using that as the base for
  32. # this file.
  33. # http://bugzilla.mozilla.org/show_bug.cgi?id=37339
  34. my $useragent = $ENV{HTTP_USER_AGENT};
  35. if ($useragent =~ m:Mozilla/([1-9][0-9]*):i && $1 >= 5 && $useragent !~ m/compatible/i) {
  36. print $cgi->header("application/vnd.mozilla.xul+xml");
  37. # Generate and return the XUL from the appropriate template.
  38. $template->process("sidebar.xul.tmpl")
  39. || ThrowTemplateError($template->error());
  40. } else {
  41. ThrowUserError("sidebar_supports_mozilla_only");
  42. }