Francois Gouget : testbot/web: Make it possible for web pages to set their page title.

Alexandre Julliard julliard at winehq.org
Thu Oct 25 13:29:48 CDT 2012


Module: tools
Branch: master
Commit: c1d75ee839c357dfb32b2ce0b13e39fb7daa4011
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=c1d75ee839c357dfb32b2ce0b13e39fb7daa4011

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Oct 25 19:14:57 2012 +0200

testbot/web: Make it possible for web pages to set their page title.

Previously they could set their header but not the label that appears in the Web browser's tab or title bar.

---

 testbot/lib/ObjectModel/CGI/Page.pm     |   14 ++++++++++++++
 testbot/lib/WineTestBot/CGI/PageBase.pm |   14 +++++++++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/testbot/lib/ObjectModel/CGI/Page.pm b/testbot/lib/ObjectModel/CGI/Page.pm
index a21ad36..0661519 100644
--- a/testbot/lib/ObjectModel/CGI/Page.pm
+++ b/testbot/lib/ObjectModel/CGI/Page.pm
@@ -102,6 +102,20 @@ sub SetCookies
   $self->{PageBase}->SetCookies($self);
 }
 
+sub GetPageTitle
+{
+  my $self = shift;
+
+  return $self->{PageBase}->GetPageTitle($self);
+}
+
+sub GetTitle
+{
+  my $self = shift;
+
+  return undef;
+}
+
 sub GenerateHeader
 {
   my $self = shift;
diff --git a/testbot/lib/WineTestBot/CGI/PageBase.pm b/testbot/lib/WineTestBot/CGI/PageBase.pm
index 141833f..5439ebf 100644
--- a/testbot/lib/WineTestBot/CGI/PageBase.pm
+++ b/testbot/lib/WineTestBot/CGI/PageBase.pm
@@ -195,16 +195,28 @@ sub SetCookies
   }
 }
 
+sub GetPageTitle
+{
+  my $self = shift;
+  my $Page = $_[0];
+
+  my $Title = $Page->GetTitle() || "";
+  $Title .= " - " if ($Title ne "");
+  $Title .= "${ProjectName} Test Bot";
+  return $Title;
+}
+
 sub GenerateHeader
 {
   my $self = shift;
   my $Page = $_[0];
 
+  my $Title = $Page->CGI->escapeHTML($Page->GetPageTitle());
   print <<EOF;
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html>
 <head>
-  <title>${ProjectName} Test Bot</title>
+  <title>$Title</title>
   <link rel='icon' href='/${ProjectName}FavIcon.png' type='image/png'>
   <link rel='shortcut icon' href='/${ProjectName}FavIcon.png' type='image/png'>
   <link rel='stylesheet' href='/${ProjectName}TestBot.css' type='text/css' media='screen'>




More information about the wine-cvs mailing list