commit:2d62063d1fd2673740e99c3d1e8fd60ab0714c6f
author:Chip Black
committer:Chip Black
date:Wed Aug 9 23:59:12 2017 -0500
parents:953e4433f95f78f7c0dccf51c556edfd050fbf75
Update profile formatting and add photo
diff --git a/cgi-bin/html.lib b/cgi-bin/html.lib
line changes: +31/-1
index f1cb9aa..e97caab
--- a/cgi-bin/html.lib
+++ b/cgi-bin/html.lib
@@ -1,18 +1,48 @@
 sub html_head {
+    $background = shift;
+    $width = shift || 640;
     print <<EOD
 <html>
 <head>
 <title>FriendNet! - A place for friends</title>
 </head>
-<body bgcolor=lightblue color=black>
+<body bgcolor=lightblue color=black background=$background>
+<table width=$width><tr><td>
 EOD
 }
 
 sub html_foot {
     print <<EOD
+</td></tr></table>
 </body>
 </html>
 EOD
 }
 
+sub h1 {
+    "<h1>@_</h1>";
+}
+
+sub h2 {
+    "<h2>@_</h2>";
+}
+
+sub img {
+    $src = shift;
+    "<img src=$src" . attr_expando(@_) . ">";
+}
+
+sub friendnet {
+    "<font color=red>Friend</font><font color=blue>Net!</font>";
+}
+
+sub attr_expando {
+    %attr = @_;
+    $s = '';
+    for $k (keys %attr) {
+        $s .= " $k=$attr{$k}";
+    }
+    return $s;
+}
+
 1;

diff --git a/cgi-bin/profile.pl b/cgi-bin/profile.pl
line changes: +10/-16
index d2dca20..1b15806
--- a/cgi-bin/profile.pl
+++ b/cgi-bin/profile.pl
@@ -8,33 +8,27 @@ $logged_in = $cookies{loggedin} eq $formdata{u};
 
 print "Content-type: text/html\r\n\r\n";
 
-&html_head;
-
 %profile = profile_load($formdata{u});
 
-print <<EOD;
-<h1>FriendNet!</h1>
-<h2>$formdata{u}</h2>
-EOD
+&html_head($profile{dogs} ? "/img/dog.gif" : '');
 
-if ($profile{dogs}) {
-    print <<EOD
-<style>
-body { background-image: url(/img/dog.gif) }
-</style>
-EOD
+print h1(&friendnet);
+if ($profile{photo}) {
+    print img("/images/$profile{photo}", align => right, width => 200);
 }
+print h2($formdata{u});
+
 
 print <<EOD;
-<table>
+<table bgcolor=purple border=2 cellpadding=4>
   <tr>
-    <td>Favorite Pearl Jam album:</td><td>$profile{pearljam}</td>
+    <td><font color=white><b>Favorite Pearl Jam album:</b></font></td><td><font color=white>$profile{pearljam}</font></td>
   </tr>
   <tr>
-    <td>College:</td><td>$profile{college}</td>
+    <td><font color=white><b>College:</b></font></td><td><font color=white>$profile{college}</font></td>
   </tr>
   <tr>
-    <td>Sex:</td><td>$profile{sex}</td>
+    <td><font color=white>Sex:</font></td><td><font color=white>$profile{sex}</font></td>
   </tr>
 </table>
 EOD