Annotation of doc/techtips/worktime-2.html, revision 1.1

1.1     ! albertel    1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        !             2: <html>
        !             3:   <head>
        !             4:     <title>Worktime, New Tag</title>
        !             5:   </head>
        !             6: 
        !             7:   <body>
        !             8:     <h1>Worktime, New Tag</h1>
        !             9: 
        !            10:     <h2>Adding a New Tag</h2>
        !            11:     <p>
        !            12:       We will add the tag &lt;blue&gt; to the XML handler. It will
        !            13:       change all text inside of it to be blue when viewing a webpage.
        !            14:     </p>
        !            15: 
        !            16:     <ol>
        !            17:       <li>
        !            18: 	First you will need to add the author role to domcc<br />
        !            19: 	Use the
        !            20: 	CUSR button on the remote, type in the username 'domcc' and then
        !            21: 	add the author role. Logout, and log back in. (You will also need
        !            22: 	to let the webserver have permission to enter domcc's home
        !            23: 	directory, do this by having domcc do <tt>chmod a+x /home/domcc
        !            24: 	</tt>
        !            25:       </li>
        !            26:       <li>
        !            27: 	Next create a homework problem. Something simple. In the text
        !            28: 	section of the homework problem. Surround the text of the
        !            29: 	problem with the tag pair &lt;blue&gt; and &lt;/blue&gt;
        !            30:       </li>
        !            31:       <li>
        !            32: 	When you view the problem you should see no change. (This is
        !            33: 	because by default browsers ignore tags they are unfamiliar
        !            34: 	with.)
        !            35:       </li>
        !            36:       <li>
        !            37: 	Next you will need to edit the londefdef.pm file in the xml
        !            38: 	subdriectory, and we will do the required actions to make a
        !            39: 	new tag handler.
        !            40:       </li>
        !            41:       <li>
        !            42: 	First we need to register the tag with the xml parser. Notice
        !            43: 	that at the top of the londefdef.pm file there is a call to
        !            44: 	register, right in front of the <tt>'m'</tt> put <tt>'blue',</tt>.
        !            45: 	Don't forget the comma.
        !            46:       </li>
        !            47:       <li>
        !            48: 	Next we need to create 2 functions. &amp;start_blue() and
        !            49: 	&amp;end_blue(). They will be called when the parser sees the
        !            50: 	start and end blue tags.
        !            51:       </li>
        !            52:       <li>
        !            53: 	Add 'Code Fragment 1' to the londefdef.pm file. Copy
        !            54: 	londefdef.pm to <tt>/home/httpd/lib/perl/Apache</tt> and
        !            55: 	restart the webserver. This is the last time I will tell you
        !            56: 	this.
        !            57:       </li>
        !            58:       <li>
        !            59: 	Go back and view your homework problem. You should see the two
        !            60: 	messages 'Starting the blue tag now!!!' and 'Ending the blue
        !            61: 	tag now!!!', notice that it appears a second time in the
        !            62: 	bottom section, that is because that is a parse of the answer
        !            63: 	target. We need to stop produicng oputput for any target other
        !            64: 	than web.
        !            65:       </li>
        !            66:       <li>
        !            67: 	Now change the code to be as in Code Fragment 2.
        !            68:       </li>
        !            69:       <li>
        !            70: 	Now it should only appear in the middle of the problem. Now
        !            71: 	lets make it turn the text blue.
        !            72:       <li>
        !            73: 	Change you code to look like Code Fragment 3
        !            74:       </li>
        !            75:       <li>
        !            76: 	Now when you view the problem the text should appear in blue.
        !            77:       </li>
        !            78:     </ol>
        !            79: 
        !            80: <h3>Code fragment 1</h3>
        !            81:     <pre>
        !            82: sub start_blue {
        !            83:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
        !            84:   my $result='';
        !            85:   $result='&lt;br /&gt;Starting the blue tag now!!!&lt;br /&gt;';
        !            86:   return $result;
        !            87: }
        !            88: 
        !            89: sub end_blue {
        !            90:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
        !            91:   my $result='';
        !            92:   $result='&lt;br /&gt;Ending the blue tag now!!!&lt;br /&gt;';
        !            93:   return $result;
        !            94: }
        !            95:     </pre>
        !            96:     
        !            97: <h3>Code fragment 2</h3>
        !            98:         <pre>
        !            99: sub start_blue {
        !           100:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
        !           101:   my $result='';
        !           102: <b>  if ($target eq 'web') {</b>
        !           103:       <i>$result='&lt;br /&gt;Starting the blue tag now!!!&lt;br /&gt;';</i>
        !           104: <b>  }</b>
        !           105:   return $result;
        !           106: }
        !           107: 
        !           108: sub end_blue {
        !           109:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
        !           110:   my $result='';
        !           111: <b>  if ($target eq 'web') {</b>
        !           112:       <i>$result='&lt;br /&gt;Ending the blue tag now!!!&lt;br /&gt;';</i>
        !           113: <b>  }</b>
        !           114:   return $result;
        !           115: }
        !           116:     </pre>
        !           117: <h3>Code fragment 2</h3>
        !           118:         <pre>
        !           119: sub start_blue {
        !           120:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
        !           121:   my $result='';
        !           122:   if ($target eq 'web') {
        !           123:       <i>$result='&lt;font color="blue"&gt;';</i>
        !           124:   }
        !           125:   return $result;
        !           126: }
        !           127: 
        !           128: sub end_blue {
        !           129:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
        !           130:   my $result='';
        !           131:   if ($target eq 'web') {
        !           132:       <i>$result='&lt;/font&gt;';</i>
        !           133:   }
        !           134:   return $result;
        !           135: }
        !           136:     </pre>
        !           137:     <hr>
        !           138:     <address><a href="mailto:albertel@mileva.lite.msu.edu">Guy Albertelli</a></address>
        !           139: <!-- Created: Tue Jun 11 10:09:35 EDT 2002 -->
        !           140: <!-- hhmts start -->
        !           141: Last modified: Tue Jun 11 11:01:29 EDT 2002
        !           142: <!-- hhmts end -->
        !           143:   </body>
        !           144: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>