#! /usr/bin/perl -w # ######################################## # # displays resources page for DTN site # written by benjamin ramey # bsr@rameydesign.net # april, 2004 # ######################################## $data_file = "./data/resources_data.txt"; print "Content-type: text/html\n\n"; &Print_Top_HTML; &Articles; &Books_And_Other; &On_Leadership; &Teaching_Outlines; &Tools_For_Min; &Tools_For_Personal; &Links; &Print_Bottom_HTML; exit; ################################################################################################################################################ # SUB ROUTINES FOR DYNAMIC HTML ################################################################################################################################################ sub Articles { my $in_section = 0; print<<"HTML";
\ \; Articles\ \;\ \;\ \;\ \; \ \;
\ \; Click on "view article", next to each article to open it up in a new window.
    HTML open( INFILE, $data_file ) or print "ERROR: Could not open $data_file."; while( my $file_line = ) { if( $file_line =~ m// ) { $in_section = 1; } if( $file_line =~ m/<\/articlesection>/ ) { $in_section = 0; } if( ($file_line =~ m/(.*)<\/title>/) && $in_section ) { print "<li>$1 | \n\t"; } if( ($file_line =~ m/<link>(.*)<\/link>/) && $in_section ) { my $link = $1; $link =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/articles/$link', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">view article</a></li>\n"; } } close( INFILE ); print<<"HTML"; </ul> </td> </tr> </table> HTML } sub Books_And_Other { my $in_section = 0; print<<"HTML"; <table class="section_table" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="corner">\ \;</td> <td class="header" align="left">Books & Other Information\ \;\ \;\ \;<span class="top_anchor">/ <a name="books_other_info" href="#top">top</a> /</span></td> <td>\ \;</td> </tr> <tr> <td align="left" valign="top">\ \;</td> <td colspan="2" class="content_column"> HTML open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>"; while( my $file_line = <INFILE> ) { if( $file_line =~ m/<books_otherinfo>/ ) { $in_section = 1; } if( $file_line =~ m/<\/books_otherinfo>/ ) { $in_section = 0; } if( ($file_line =~ m/<name>(.*)<\/name>/) && $in_section ) { my $section_name = $1; print<<"HTML"; <b style="text-decoration: underline">$section_name:</b> <blockquote> HTML $file_line = <INFILE>; chomp( $file_line ); $file_line =~ s/.*<files>(.*)<\/files>.*/$1/; my @files = split( /,/, $file_line ); foreach my $file ( @files ) { my $display_name = $file; $display_name =~ s/\.htm//; $file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/books/$section_name/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a><br />\n"; } print "\t\t\t</blockquote>\n"; } } close( INFILE ); print<<"HTML"; </td> </tr> </table> HTML } sub On_Leadership { my $in_section = 0; print<<"HTML"; <table class="section_table" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="corner">\ \;</td> <td class="header" align="left">On Leadership\ \;\ \;\ \;<span class="top_anchor">/ <a name="on_leadership" href="#top">top</a> /</span></td> <td>\ \;</td> </tr> <tr> <td align="left" valign="top">\ \;</td> <td colspan="2" class="content_column"> <b>Click on each link to open a window with the subject material in it.</b> <ul> HTML open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>"; while( my $file_line = <INFILE> ) { if( $file_line =~ m/<onleadership>/ ) { $in_section = 1; } if( $file_line =~ m/<\/onleadership>/ ) { $in_section = 0; } if( ($file_line =~ m/<file>(.*)<\/file>/) && $in_section ) { my $file = $1; my $display_name = $file; $display_name =~ s/\.htm//; $file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/onleadership/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n"; } } close( INFILE ); print<<"HTML"; </ul> </td> </tr> </table> HTML } sub Teaching_Outlines { my $in_section = 0; print<<"HTML"; <table class="section_table" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="corner">\ \;</td> <td class="header" align="left">Teaching Outlines\ \;\ \;\ \;<span class="top_anchor">/ <a name="teaching_outlines" href="#top">top</a> /</span></td> <td>\ \;</td> </tr> <tr> <td align="left" valign="top">\ \;</td> <td colspan="2" class="content_column"> <b>Click on each link to open a window with the subject material in it.</b> <ul> HTML open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>"; while( my $file_line = <INFILE> ) { if( $file_line =~ m/<teachingoutlines>/ ) { $in_section = 1; } if( $file_line =~ m/<\/teachingoutlines>/ ) { $in_section = 0; } if( ($file_line =~ m/<file>(.*)<\/file>/) && $in_section ) { my $file = $1; my $display_name = $file; $display_name =~ s/\.htm//; $file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/teachingoutlines/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n"; } } close( INFILE ); print<<"HTML"; </ul> </td> </tr> </table> HTML } sub Tools_For_Min { my $in_section = 0; print<<"HTML"; <table class="section_table" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="corner">\ \;</td> <td class="header" align="left">Tools For Ministry: Local Church\ \;\ \;\ \;<span class="top_anchor">/ <a name="tools_for_min" href="#top">top</a> /</span></td> <td>\ \;</td> </tr> <tr> <td align="left" valign="top">\ \;</td> <td colspan="2" class="content_column"> <b>Click on each link to open a window with the subject material in it.</b> HTML open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>"; my $in_top = 0; while( my $file_line = <INFILE> ) { if( $file_line =~ m/<toolsforministry>/ ) { $in_section = 1; } if( $file_line =~ m/<\/toolsforministry>/ ) { $in_section = 0; } if( ($file_line =~ m/<top>/) && $in_section ) { print "\t\t<ul>\n"; $in_top = 1; while( ($file_line = <INFILE>) && $in_top ) { if( $file_line =~ m/<\/top>/ ) { $in_top = 0; } elsif( $file_line =~ m/<file>(.*)<\/file>/ ) { my $file = $1; my $display_name = $file; $display_name =~ s/\.\w{3}$//; $file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/toolsforministry/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n"; } } print "\t\t</ul>\n"; } if( ($file_line =~ m/<subsection>/) && $in_section ) { &Do_Subsection( \*INFILE, "toolsforministry" ); } } close( INFILE ); print<<"HTML"; </td> </tr> </table> HTML } sub Tools_For_Personal { my $in_section = 0; print<<"HTML"; <table class="section_table" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="corner">\ \;</td> <td class="header" align="left">Tools For Personal\ \;\ \;\ \;<span class="top_anchor">/ <a name="tools_for_personal" href="#top">top</a> /</span></td> <td>\ \;</td> </tr> <tr> <td align="left" valign="top">\ \;</td> <td colspan="2" class="content_column"> <b>Click on each link to open a window with the subject material in it.</b> HTML open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>"; my $in_top = 0; while( my $file_line = <INFILE> ) { if( $file_line =~ m/<toolsforpersonal>/ ) { $in_section = 1; } if( $file_line =~ m/<\/toolsforpersonal>/ ) { $in_section = 0; } if( ($file_line =~ m/<top>/) && $in_section ) { print "\t\t<ul>\n"; $in_top = 1; while( ($file_line = <INFILE>) && $in_top ) { if( $file_line =~ m/<\/top>/ ) { $in_top = 0; } elsif( $file_line =~ m/<file>(.*)<\/file>/ ) { my $file = $1; my $display_name = $file; $display_name =~ s/\.\w{3}$//; $file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/toolsforpersonal/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n"; } } print "\t\t</ul>\n"; } if( ($file_line =~ m/<subsection>/) && $in_section ) { &Do_Subsection( \*INFILE, "toolsforpersonal" ); } } close( INFILE ); print<<"HTML"; </td> </tr> </table> HTML } sub Links { print<<"HTML"; <table class="section_table" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="corner">\ \;</td> <td class="header" align="left">Links\ \;\ \;\ \;<span class="top_anchor">/ <a name="links" href="#top">top</a> /</span></td> <td>\ \;</td> </tr> <tr> <td align="left" valign="top">\ \;</td> <td colspan="2" class="content_column"> This section displays all the links throughout the DtN site. This includes all e-mail addresses and web addresses being linked to from here. The links are arranged according to which page they are found on.<br /> <br /> HTML open( INFILE, "./data/links_data.txt" ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open links_data.txt file.</span>"; my $col_count = 0; print "<table cellpadding='15' cellspacing='0' style=\"font-size: 12px;\">\n\t<tr>\n"; while( my $fl = <INFILE> ) { my @links = splice( @links ); if( $fl =~ m/<page name="(.*)">/ ) { my $page_name = $1; my $path = $1; $page_name =~ s/(.*)\.\w{2,3}/$1/; $in_page = 1; if( $page_name eq 'whoweare' ) { $page_name = "Who We Are"; } elsif( $page_name eq 'resources' ) { $page_name = "Resources"; } elsif( $page_name eq 'prayer' ) { $page_name = "Prayer Requests"; } elsif( $page_name eq 'travel' ) { $page_name = "Mission & Travel"; } elsif( $page_name eq 'media' ) { $page_name = "Photos / Videos"; } if( $col_count == 2 ) { print "\t</tr>\n\t<tr>\n"; $col_count = 0; } if( $col_count == 0 ) { print "\t\t<td align='left' valign='top' width='50%' style='border: #000000 solid; border-width: 0px 1px 0px 0px;'><b style='text-decoration: underline'>$page_name page:</b><br />\n"; } else { print "\t\t<td align='left' valign='top' width='50%'><b style='text-decoration: underline'>$page_name page:</b><br />\n"; } while( $in_page ) { $fl = <INFILE>; if( $fl =~ m/<\/page>/ ) { $in_page = 0; } else { $fl =~ s/.*<(.*)>(.*)<\/.*>.*/$2/; my $link = $2; $link =~ s/\\@/@/g; push( @links, $link ); } } foreach my $pair ( sort @links ) { my ($name, $link) = split( /=/, $pair ); if( $link =~ m/@/ ) { print "<a href=\"mailto:$link\">$name</a><br />\n"; } elsif( $link =~ m/#/ ) { print "<a href=\"./$path$link\">$name</a><br />\n"; } else { print "<a href=\"$link\">$name</a><br />\n"; } } print "\t\t</td>\n"; $col_count++; } } print "\t</tr>\n</table>\n"; close( INFILE ); print<<"HTML"; </td> </tr> </table> HTML } ###############processes subsections for both "tools" sections#################### sub Do_Subsection { my $fh = shift; my $line = 0; my $in_sub = 1; my $main_folder = shift; my $file_path = shift; while( $in_sub ) { $line = <$fh>; if( $line =~ m/<subsection>/ ) { &Do_Subsection( \*$fh, $main_folder, $file_path ); } if( $line =~ m/<\/subsection>/ ) { $in_sub = 0; } if( $line =~ m/<name>(.*)<\/name>/ ) { print "<blockquote>\n<b style='text-decoration: underline'>$1:</b>\n"; print "\t\t<ul>\n"; $file_path .= $1 . '/'; } elsif( $line =~ m/<file>(.*)<\/file>/ ) { my $file = $1; my $display_name = $file; $display_name =~ s/\.\w{3}$//; $file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg; print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/$main_folder/$file_path$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n"; } } print "\t\t</ul>\n"; print "</blockquote>\n"; } ################################################################################################################################################ # SUB ROUTINES FOR PRINTING GENERIC HTML ################################################################################################################################################ ##############displays top of media page############## sub Print_Top_HTML { print <<"HTML"; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Disciple the Nations - Resources
    \ \; home | who we are | resources | prayer requests | mission & travel | photos/videos


    HTML } ##############displays bottom of media page############## sub Print_Bottom_HTML { print <<"HTML";
    who we are | resources | prayer requests | mission & travel | photos/videos \ \;
    all site content copyright of Disciple the Nations, all rights reserved | site designed by ramey design
    HTML }