# # htmlizer.conf.pl # J. Uckelman (uckelman@nomic.net) # 20 February 2001 # # Targets for htmlizer.pl @all = qw( Event_Log Judgments_Archive Judgments_Archive_Index Judgments_Live Motions_Archive Motions_Archive_Index Motions_Live Motions_Voting Proposals_Archive Proposals_Archive_Index Proposals_Live Proposals_Voting Officers_Historical Officers_Live Officers_Voting Roster Rules_Categorical Rules_Categorical_Index Rules_Changes Rules_Changes_Index Rules_Historical Rules_Historical_Index Rules_Numerical Rules_Numerical_Index Standings ); # Records per page for multipage targets $Judgments_Archive_perpage = 25; $Motions_Archive_perpage = 25; $Proposals_Archive_perpage = 25; $Rules_Historical_perpage = 100; $Rules_Numerical_perpage = 100; # Category hierarchy for Rules_Categorical* @Rules_Categorical_hierarchy = ( [ "Actions", -1 ], [ "Agents" , -1 ], [ "Players", 1 ], [ "The Bank", -1 ], [ "Contests", -1 ], [ "Contracts", -1 ], [ "Definitions, Conventions, and Protocols", -1 ], [ "Fora", -1 ], [ "Judiciary", -1 ], [ "Motions", -1 ], [ "Proposals", 9 ], [ "Objects", -1 ], [ "Offices and Officers", -1 ], [ "Orders", -1 ], [ "Scoring", -1 ], [ "The Game", -1 ], [ "The Rules", -1 ], [ "Voting", -1 ], [ "Winning", -1 ], [ "Miscellaneous", -1 ] ); # Target functions sub Event_Log { my $head = interpolate_file("$TPL/standard.header", 'pagetitle', 'Event Log') . "
$text\n$history\n"; } $body = add_break_tags($body); my $foot = interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Changes.$page.html", "$head$links$body$links$foot"); } return 'ok'; } sub Rules_Changes_Index { my $head = interpolate_file("$TPL/standard.header", 'pagetitle', 'Rules Changes Index') . "
Statement:\n
\$statement\n
Ruling:\n
\$ruling\n
Plaintiff's Analysis:\n
\$p_analysis\n
Judge's Analysis and Orders:\n
\$j_analysis\n\$history\n", "select judgment0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from judgment0history, event where judgment0history.number = \$number and judgment0history.id = event.id order by event.date", "\$revision. \$event, \$date
/gs; $out .= $body . "
Statement:\n
\$statement\n
Ruling:\n
\$ruling<\blockquote>\nPlaintiff's Analysis:\n
\$p_analysis\nJudge's Analysis and Orders:\n
\$j_analysis\n\n\$history\n
\n", "select judgment0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from judgment0history, event where judgment0history.number = \$number and judgment0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Judgments.Live.html", $out); return 'ok'; } sub Motions_Archive { my @page = (split / /, single_query("select distinct ceiling(number/$Motions_Archive_perpage)as page from motion", "\$page ")); my $page; foreach $page (@page) { my $from = ($page-1)*$Motions_Archive_perpage+1; my $to = $page*$Motions_Archive_perpage; my $out = interpolate_file("$TPL/paged.header", 'pagetitle', "Motions Archive, $from-$to") . "
\n" . page_links_old($page, "[Motions $from-$to]", "[Motions \@{[(\$page-1)*$Motions_Archive_perpage+1]}-\@{[\$page*$Motions_Archive_perpage]}] ", @page) . " \n
\n"; my $body = history_number_query("select motion.number, motion.revision, if(isnull(motion.end), concat(' : ', elt(motion.activity+1, 'inactive', 'active', 'withdrawn')), '') as activity, motion.title, motion.text from motion where number between $from and $to order by motion.number, motion.revision", "Motion \$number/\$revision : \$title\$activity\n\$text\n\$history\n", "select motion0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from motion0history, event where motion0history.number = \$number and motion0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history', "\n", "\n
", "select max(revision) as maxrev from motion where number = \$number", "\$maxrev", 'revision'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . "
\n" . page_links_old($page, "[Motions $from-$to] ", "[Motions \@{[(\$page-1)*$Motions_Archive_perpage+1]}-\@{[\$page*$Motions_Archive_perpage]}] ", @page) . " \n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Motions.Archive.$page.html", $out); } return 'ok'; } sub Motions_Archive_Index { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Motions Archive Index') . "
\n" . single_query("select number, revision, title, ceiling(number/$Motions_Archive_perpage) as page from motion order by number, revision", "\$number/\$revision: \$title
\n") . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Motions.Archive.Index.html", $out); return 'ok'; } sub Motions_Live { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Live Motions') . "
\n"; my $body = history_all_query("select motion.number, motion.revision, if(motion.activity = 1, 'active', 'inactive') as activity, motion.title, motion.text from motion where isnull(motion.end) order by number, revision", "Motion \$number/\$revision : \$title : \$activity\n\$text\n\\n\$history\n
\n", "select motion0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from motion0history, event where motion0history.number = \$number and motion0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Motions.Live.html", $out); return 'ok'; } sub Motions_Voting { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Motions Voting') . "
\n" . (voting_summary("select distinct date from motion0voting order by date", "\$date\n", 'binary', "select max(length(concat(number, '/', revision))) as length from motion0voting where date = '\$date'", "select distinct name.name from name, motion0voting where name.id = motion0voting.id and motion0voting.date = '\$date' and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) order by name.name", 3, "select distinct number, revision from motion0voting where date = '\$date' order by number, revision", "\$number/\$revision", "\n", "select motion0voting.vote from motion0voting, name where motion0voting.date = '\$date' and motion0voting.id = name.id and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) and motion0voting.number = \$number and motion0voting.revision = \$revision order by motion0voting.number, motion0voting.revision, name.name", "\$column_fill\$vote", "", "") or '') . "\n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Motions.Voting.html", $out); return 'ok'; } sub Officers_Historical { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Officers Past') . "
\n" . list_query("select id, office from office order by office", "\$office\n\n", "
\n", "select if(officer.vacant, 'vacant', name.name) as name, date_format(officer.start, '%d %b %Y %T') as start, ifnull(date_format(officer.end, '%d %b %Y %T'), 'present') as end from officer, office, name where name.id = officer.id and office.id = officer.office and officer.office = \$id and ((officer.end between name.start and name.end) or (isnull(name.end) and (name.start <= officer.end or isnull(officer.end)))) order by officer.start", "\$name, \$start - \$end \n") . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Officers.Historical.html", $out); return 'ok'; } sub Officers_Live { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Current Officers') . "
\n" . single_query("select office.office, name.name, date_format(officer.start, '%d %b %Y %T') as start, if(office.elected, concat('term ends ', date_format(date_add(officer.start, interval 50 day), '%d %b %Y %T')), 'no fixed term') as end from office, officer, name where officer.office = office.id and isnull(officer.end) and name.id = officer.id and isnull(name.end) order by office.office", "\$office: \$name, since \$start, \$end
\n") . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Officers.Live.html", $out); return 'ok'; } sub Officers_Voting { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Election Voting') . "
\n\n" . voting_summary("select distinct date from election0voting order by date", "\$date\n", 'election', "select max(length(office.office)) as length from office, election0voting where date = '\$date' and election0voting.office = office.id", "select distinct name.name from name, election0voting where name.id = election0voting.id and election0voting.date = '\$date' and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) order by name.name", 3, "select distinct office.office, repeat(' ', \$max_issue_length - length(office.office)) as padding from office, election0voting where date = '\$date' and election0voting.office = office.id order by office.office", "\$office\$padding", "\n", "select lpad(election0voting.vote, 2, ' ') as vote from election0voting, name, office where election0voting.date = '\$date' and election0voting.id = name.id and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) and election0voting.office = office.id and office.office = '\$office' order by office.office, name.name", "\$column_fill\$vote", "select distinct name.name, election0voting.vote from election0voting, name where election0voting.date = '\$date' and election0voting.vote = name.id and election0voting.vote <> '-' and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) order by name.name", "\$name, \$vote\n") . "\n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Elections.Voting.html", $out); return 'ok'; } sub Proposals_Archive { my @page = (split / /, single_query("select distinct ceiling(number/$Proposals_Archive_perpage) as page from proposal order by page", '$page ')); my $page; foreach $page (@page) { my $from = ($page-1)*$Proposals_Archive_perpage+1; my $to = $page*$Proposals_Archive_perpage; my $out = interpolate_file("$TPL/paged.header", 'pagetitle', "Proposals Archive, $from-$to") . "\n" . page_links_old($page, "[Proposals $from-$to] ", "[Proposals \@{[(\$page-1)*$Proposals_Archive_perpage+1]}-\@{[\$page*$Proposals_Archive_perpage]}] ", @page) . " \n
\n" ; my $body = history_number_query("select proposal.number, proposal.revision, if(isnull(proposal.end), concat(' : ', elt(proposal.activity+1, 'inactive', 'active', 'withdrawn')), '') as activity, proposal.title, proposal.text from proposal where number between $from and $to order by proposal.number, proposal.revision", "Proposal \$number/\$revision : \$title\$activity\n\$text\n\$history\n", "select proposal0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from proposal0history, event where proposal0history.number = \$number and proposal0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history', "\n", "\n
", "select max(revision) as maxrev from proposal where number = \$number", "\$maxrev", 'revision'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . "
\n" . page_links_old($page, "[Proposals $from-$to] ", "[Proposals \@{[(\$page-1)*$Proposals_Archive_perpage+1]}-\@{[\$page*$Proposals_Archive_perpage]}] ", @page) . " \n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Proposals.Archive.$page.html", $out); } return 'ok'; } sub Proposals_Archive_Index { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Proposals Archive Index') . "
\n" . single_query("select number, revision, title, ceiling(number/$Proposals_Archive_perpage) as page from proposal order by number, revision", "\$number/\$revision: \$title
\n") . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Proposals.Archive.Index.html", $out); return 'ok'; } sub Proposals_Live { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Live Proposals') . "
\n"; my $body = history_all_query("select proposal.number, proposal.revision, if(proposal.activity = 1, 'active', 'inactive') as activity, proposal.title, proposal.text from proposal where isnull(proposal.end) order by number, revision", "Proposal \$number/\$revision : \$title : \$activity\n\$text\n\\n\$history\n
\n", "select proposal0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from proposal0history, event where proposal0history.number = \$number and proposal0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Proposals.Live.html", $out); return 'ok'; } sub Proposals_Voting { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Proposals Voting') . "
\n" . voting_summary("select distinct date from proposal0voting order by date", "\$date\n", 'binary', "select max(length(concat(number, '/', revision))) as length from proposal0voting where date = '\$date'", "select distinct name.name from name, proposal0voting where name.id = proposal0voting.id and proposal0voting.date = '\$date' and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) order by name.name", 3, "select distinct number, revision from proposal0voting where date = '\$date' order by number, revision", "\$number/\$revision", "\n", "select proposal0voting.vote from proposal0voting, name where proposal0voting.date = '\$date' and proposal0voting.id = name.id and name.start <= '\$date' and (isnull(name.end) or '\$date' <= name.end) and proposal0voting.number = \$number and proposal0voting.revision = \$revision order by proposal0voting.number, proposal0voting.revision, name.name", "\$column_fill\$vote", "", "") . "\n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Proposals.Voting.html", $out); return 'ok'; } sub Rules_Categorical { my @page = col(0, @Rules_Categorical_hierarchy); my $i; for $i (0 .. $#page) { my $out = interpolate_file("$TPL/paged.header", 'pagetitle', "Categorical Ruleset, $page[$i]") . "\n" . page_links_old($page[$i], "[$page[$i]] ", "[\$page] ", @page) . " \n
\n"; my $body = history_all_query("select rule.number, rule.revision, rule.title, rule.text from rule, rule0category, category where isnull(rule.end) and rule.number = rule0category.number and rule.revision = rule0category.revision and rule0category.category = category.id and category.category = '$page[$i]' order by rule.number, rule.revision", "Rule \$number/\$revision : \$title\n\$text\n\n\$history\n
\n", "select rule0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from rule0history, event where rule0history.number = \$number and rule0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . "
\n" . page_links_old($page[$i], "[$page[$i]] ", "[\$page] ", @page) . " \n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Categorical.@{[$i+1]}.html", $out); } return 'ok'; } sub Rules_Categorical_Index { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Categorical Ruleset Index') . "
\n" . list_unpack(-1, "\n", "
\n", "select rule.number, rule.revision, rule.title from rule, rule0category, category where isnull(rule.end) and rule.number = rule0category.number and rule.revision = rule0category.revision and rule0category.category = category.id and category.category = '\$category' order by rule.number", "- \$element
\n", "\$number/\$revision: \$title \n", @Rules_Categorical_hierarchy) . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Categorical.Index.html", $out); return 'ok'; } sub Rules_Historical { my @page = (split / /, single_query("select distinct ceiling(number/$Rules_Historical_perpage) as page from rule order by page", '$page ')); my $page; foreach $page (@page) { my $from = ($page-1)*$Rules_Historical_perpage+1; my $to = $page*$Rules_Historical_perpage; my $out = interpolate_file("$TPL/paged.header", 'pagetitle', "Historical Ruleset, $from-$to") . "\n" . page_links_old($page, "[Rules $from-$to] ", "[Rules \@{[(\$page-1)*$Rules_Historical_perpage+1]}-\@{[\$page*$Rules_Historical_perpage]}] ", @page) . " \n
\n"; my $body = history_number_query("select rule.number, rule.revision, rule.title, rule.text from rule where number between $from and $to order by rule.number, rule.revision", "Rule \$number/\$revision : \$title\n\$text\n\$history\n", "select rule0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from rule0history, event where rule0history.number = \$number and rule0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history', "\n", "\n
", "select max(revision) as maxrev from rule where number = \$number", "\$maxrev", 'revision'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . "
\n" . page_links_old($page, "[Rules $from-$to] ", "[Rules \@{[(\$page-1)*$Rules_Historical_perpage+1]}-\@{[\$page*$Rules_Historical_perpage]}] ", @page) . " \n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Historical.$page.html", $out); } return 'ok'; } sub Rules_Historical_Index { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Historical Ruleset Index') . "
\n" . single_query("select number, revision, title, ceiling(number/$Rules_Numerical_perpage) as page from rule order by number, revision", "\$number/\$revision: \$title
\n") . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Historical.Index.html", $out); return 'ok'; } sub Rules_Numerical { my @page = (split / /, single_query("select distinct ceiling(number/$Rules_Numerical_perpage) as page from rule order by page", '$page ')); my $page; foreach $page (@page) { my $from = ($page-1)*$Rules_Numerical_perpage+1; my $to = $page*$Rules_Numerical_perpage; my $out = interpolate_file("$TPL/paged.header", 'pagetitle', "Numerical Ruleset, $from-$to") . "\n" . page_links_old($page, "[Rules $from-$to] ", "[Rules \@{[(\$page-1)*$Rules_Numerical_perpage+1]}-\@{[\$page*$Rules_Numerical_perpage]}] ", @page) . " \n
\n"; my $body = history_all_query("select rule.number, rule.revision, rule.title, rule.text from rule where isnull(rule.end) and number between $from and $to order by rule.number, rule.revision", "Rule \$number/\$revision : \$title\n\$text\n\n\$history\n
\n", "select rule0history.revision, event.event, date_format(event.date, '%d %b %Y %T') as date from rule0history, event where rule0history.number = \$number and rule0history.id = event.id order by event.date", "\$revision. \$event, \$date
\n", 'history'); $body =~ s/([^>])\n([^<])/$1
\n$2/gs; $body =~ s/\n{2}/\n\n/gs; $out .= $body . "
\n" . page_links_old($page, "[Rules $from-$to] ", "[Rules \@{[(\$page-1)*$Rules_Numerical_perpage+1]}-\@{[\$page*$Rules_Numerical_perpage]}] ", @page) . " \n
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Numerical.$page.html", $out); } return 'ok'; } sub Rules_Numerical_Index { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Numerical Ruleset Index') . "
\n" . single_query("select number, revision, title, ceiling(number/$Rules_Numerical_perpage) as page from rule where isnull(rule.end) order by number, revision", "\$number/\$revision: \$title
\n") . "
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Rules.Numerical.Index.html", $out); return 'ok'; } sub Roster { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Roster') . "
\nCurrent Players\n\n
\n\n" . single_query("select name.name, mail.address, date_format(player.start, '%d %b %Y %T') as start from player, name, mail where isnull(player.end) and player.id = name.id and name.id = mail.id and isnull(name.end) and isnull(mail.end) order by name.name", " name since \n") . " \$name \$address \$start Former Players\n
\n
\n\n" . single_query("select name.name, mail.address, date_format(player.start, '%d %b %Y %T') as start, date_format(player.end, '%d %b %Y %T') as end from player, name, mail where player.end and player.id = name.id and name.id = mail.id and isnull(name.end) and isnull(mail.end) order by name.name", " name from to \n") . " \$name \$address \$start \$end
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); $out =~ s/@/ @ /gs; write_file("$WWW/Roster.html", $out); return 'ok'; } sub Standings { my $out = interpolate_file("$TPL/standard.header", 'pagetitle', 'Standings') . "
\nNOTE: These are, at present, completely inaccurate.\n\n
\n \n" . single_query("select name.name, entity.score from entity, name where name.id = entity.id and isnull(name.end) order by entity.score desc", " name score \n") . " \$name \$score
\n" . interpolate_file("$TPL/standard.footer", 'pagedate', @{[`date -u '+%a %d %b %Y %T %Z'`]}); write_file("$WWW/Standings.html", $out); return 'ok'; } # Do not remove the last line. File must return true. 1