public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Gnatsweb help page
@ 2001-04-04 16:58 Yngve Svendsen
  0 siblings, 0 replies; only message in thread
From: Yngve Svendsen @ 2001-04-04 16:58 UTC (permalink / raw)
  To: gnats-devel

Changes Gnatsweb to display the gnatsweb.html page as help text when the 
main menu Help button is clicked.

Yngve Svendsen
IS Engineer
Clustra AS, Trondheim, Norway
yngve.svendsen@clustra.com


2001-04-05  Yngve Svendsen  <yngve.svendsen@clustra.com>

         * gnatsweb.pl (help_page): If present, return the gnatsweb.html
         document installed with Gnatsweb, stripped with send_html, as
         help text. Ported from Gnatsweb 2.7 beta.

         * gnatsweb.pl (send_html): New subroutine that strips off
         everything outside <BODY> and </BODY> in an HTML document and
         returns the contents. Ported from Gnatsweb 2.7 beta.


Index: gnatsweb.pl
===================================================================
RCS file: /cvs/gnats/gnats/contrib/gnatsweb/gnatsweb.pl,v
retrieving revision 2.31
diff -u -p -r2.31 gnatsweb.pl
--- gnatsweb.pl	2001/04/04 22:16:28	2.31
+++ gnatsweb.pl	2001/04/04 22:56:10
@@ -2064,17 +2064,51 @@ sub delete_stored_query
    }
  }

+# send_html -
+#     Send HTML help file, after first trimming out everything but
+#     <body>..</body>.  This is done in this way for convenience of
+#     installation.  If the gnatsweb.html is installed into the cgi-bin
+#     directory along with the gnatsweb.pl file, then it can't be loaded
+#     directly by Apache.  So, we send it indirectly through gnatsweb.pl.
+#     This approach has the benefit that the resulting page has the
+#     customized gnatsweb look.
+#
+sub send_html
+{
+  my $file = shift;
+  open(HTML, "$file") || die "Can't open $file: $!";
+  undef $/; # slurp file whole
+  my $html = <HTML>;
+  close(HTML);
+
+  # send just the stuff inside <body>..</body>
+  $html =~ s/.*<body>//is;
+  $html =~ s/<\/body>.*//is;
+
+  print $html;
+}
+
  sub help_page
  {
-  my $page = 'Help';
+  my $html_file = $q->param('help_file') || 'gnatsweb.html';
+  my $page      = $q->param('help_title') || 'Help';
+  my $heading   = $page;
    page_start_html($page);
-  page_heading($page, 'Help', 1);
+  page_heading($page, $heading);

-  print p('Welcome to our problem report database.');
-  print p('This web interface is called gnatsweb, ',
-          'the database system itself is called gnats.');
-  print p('For details, please ',
-          a({-href=>"$gnats_info_top"}, 'refer to our documentation'));
+  # If send_html doesn't work, print some default, very limited, help text.
+  if (!send_html($html_file))
+  {
+    print p('Welcome to our problem report database. ',
+            'You\'ll notice that here we call them "problem reports" ',
+            'or "PR\'s", not "bugs".');
+    print p('This web interface is called "gnatsweb". ',
+            'The database system itself is called "gnats".',
+            'You may want to peruse ',
+            a({-href=>"$gnats_info_top"}, 'the gnats manual'),
+            'to read about bug lifecycles and the like, ',
+            'but then again, you may not.');
+  }

    page_footer($page);
    page_end_html($page);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-04 16:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-04 16:58 PATCH: Gnatsweb help page Yngve Svendsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).