Ticket #8956: credits.pl.patch

File credits.pl.patch, 6.6 KB (added by SF/fredrik_w, 15 years ago)

credits.pl patch to generate credits.xml for the new site.

  • credits.pl

    old new  
    66# - The AUTHORS file
    77# - The gui/credits.h header file
    88# - The credits.xml file, part of the DocBook manual
    9 # - Finally, credits.inc, from the website
     9# - Finally, credits.xml, for use on the website (different format than the DocBook one)
    1010# And maybe in the future, also "doc/10.tex", the LaTeX version of the README.
    1111# Although that might soon be obsolete, if the manual evolves enough.
    1212#
     
    3333
    3434if ($#ARGV >= 0) {
    3535        $mode = "TEXT" if ($ARGV[0] eq "--text");       # AUTHORS file
    36         $mode = "HTML" if ($ARGV[0] eq "--html");       # credits.inc (for use on the website)
     36        $mode = "XML-WEB" if ($ARGV[0] eq "--xml-website");     # credits.xml (for use on the website)
    3737        $mode = "CPP" if ($ARGV[0] eq "--cpp");         # credits.h (for use by about.cpp)
    38         $mode = "XML" if ($ARGV[0] eq "--xml");         # credits.xml (DocBook)
     38        $mode = "XML-DOC" if ($ARGV[0] eq "--xml-docbook");             # credits.xml (DocBook)
    3939        $mode = "RTF" if ($ARGV[0] eq "--rtf");         # Credits.rtf (Mac OS X About box)
    4040        $mode = "TEX" if ($ARGV[0] eq "--tex");         # 10.tex (LaTeX)
    4141}
    4242
    4343if ($mode eq "") {
    44         print STDERR "Usage: $0 [--text | --html | --cpp | --xml | --rtf]\n";
    45         print STDERR " Just pass --text / --html / --cpp / --xml / --rtf as parameter, and credits.pl\n";
     44        print STDERR "Usage: $0 [--text | --xml-website | --cpp | --xml-docbook | --rtf]\n";
     45        print STDERR " Just pass --text / --xml-website / --cpp / --xml-docbook / --rtf as parameter, and credits.pl\n";
    4646        print STDERR " will print out the corresponding version of the credits to stdout.\n";
    4747        exit 1;
    4848}
     
    178178        } elsif ($mode eq "CPP") {
    179179                print "// This file was generated by credits.pl. Do not edit by hand!\n";
    180180                print "static const char *credits[] = {\n";
    181         } elsif ($mode eq "XML") {
     181        } elsif ($mode eq "XML-DOC") {
    182182                print "<?xml version='1.0'?>\n";
    183183                print "<!-- This file was generated by credits.pl. Do not edit by hand! -->\n";
    184184                print "<!DOCTYPE appendix PUBLIC '-//OASIS//DTD DocBook XML V4.2//EN'\n";
     
    191191                print "  <colspec colname='name' colwidth='4cm'/>\n";
    192192                print "  <colspec colname='job'/>\n";
    193193                print "  <tbody>\n";
    194         } elsif ($mode eq "HTML") {
     194        } elsif ($mode eq "XML-WEB") {
     195                print "<?xml version='1.0'?>\n";
    195196                print "<!-- This file was generated by credits.pl. Do not edit by hand! -->\n";
     197                print "<credits>\n";
    196198        }
    197199}
    198200
     
    205207                print "}\n";
    206208        } elsif ($mode eq "CPP") {
    207209                print "};\n";
    208         } elsif ($mode eq "XML") {
     210        } elsif ($mode eq "XML-DOC") {
    209211                print "  </tbody>\n";
    210212                print "  </tgroup>\n";
    211213                print "  </informaltable>\n";
    212214                print "</appendix>\n";
    213         } elsif ($mode eq "HTML") {
    214                 print "\n";
     215        } elsif ($mode eq "XML-WEB") {
     216                print "</credits>\n";
    215217        }
    216218}
    217219
     
    270272                  $title = html_entities_to_cpp($title);
    271273                  print '"C1""'.$title.'",' . "\n";
    272274                }
    273         } elsif ($mode eq "XML") {
     275        } elsif ($mode eq "XML-DOC") {
    274276                print "  <row><entry namest='start' nameend='job'>";
    275277                print "<emphasis role='bold'>" . $title . ":</emphasis>";
    276278                print "</entry></row>\n";
    277         } elsif ($mode eq "HTML") {
     279        } elsif ($mode eq "XML-WEB") {
    278280                if ($section_level eq 0) {
    279                         print "<div class='par-item'><div class='par-head'>$title</div><div class='par-content'>&nbsp;\n";
     281                        print "\t<section>\n";
     282                        print "\t\t<title>" . $title . "</title>\n";
    280283                } elsif ($section_level eq 1) {
    281                         print "<div class='par-subhead'>$title</div>\n";
    282                         print "<div class='par-subhead-dots'>&nbsp;</div>\n";
    283                         print "<div class='par-subhead-content'>\n"
     284                        print "\t\t<subsection>\n";
     285                        print "\t\t\t<title>" . $title . "</title>\n";
    284286                } else {
    285                         print "<span style='font-weight: bold'>$title:</span>\n";
     287                        #print "\t\t\t<group>" . $title . "</group>\n";
     288                        #print "\t\t\t\t<name>" . $title . "</name>\n";
    286289                }
    287290        }
    288291
    289292        # Implicit start of person list on section level 2
    290293        if ($section_level >= 2) {
    291                 begin_persons();
     294                begin_persons($title);
    292295        }
    293296        @section_count[$section_level]++;
    294297        $section_level++;
     
    311314                # nothing
    312315        } elsif ($mode eq "CPP") {
    313316                print '"",' . "\n";
    314         } elsif ($mode eq "XML") {
     317        } elsif ($mode eq "XML-DOC") {
    315318                print "  <row><entry namest='start' nameend='job'> </entry></row>\n\n";
    316         } elsif ($mode eq "HTML") {
     319        } elsif ($mode eq "XML-WEB") {
    317320                if ($section_level eq 0) {
    318                         print "</div></div>\n";
     321                        print "\t</section>\n";
    319322                } elsif ($section_level eq 1) {
    320                         print "</div>\n";
     323                        print "\t\t</subsection>\n";
     324                } else {
     325                        #print "\t\t\t</group>\n";
    321326                }
    322327        }
    323328}
    324329
    325330sub begin_persons {
    326         if ($mode eq "HTML") {
    327                 print "<table style='margin-left:2em; margin-bottom: 1em'>\n";
     331        my $title = shift;
     332        if ($mode eq "XML-WEB") {
     333                print "\t\t\t<group>\n";
     334                print "\t\t\t\t<name>" . $title . "</name>\n";
     335                #print "\t\t\t\t<persons>\n";
    328336        } elsif ($mode eq "TEX") {
    329337                print '\item  \begin{tabular}[h]{p{0.3\linewidth}p{0.6\linewidth}}' . "\n";
    330338        }
     
    337345                print '  \end{tabular}' . "\n";
    338346        } elsif ($mode eq "RTF") {
    339347                # nothing
    340         } elsif ($mode eq "HTML") {
    341                 print "</table>\n";
     348        } elsif ($mode eq "XML-WEB") {
     349                #print "\t\t\t\t</persons>\n";
     350                print "\t\t\t</group>\n";
    342351        }
    343352}
    344353
     
    396405                        $desc = html_entities_to_cpp($desc);
    397406                        print '"C2""'.$desc.'",' . "\n";
    398407                }
    399         } elsif ($mode eq "XML") {
     408        } elsif ($mode eq "XML-DOC") {
    400409                $name = $nick if $name eq "";
    401410                print "  <row><entry namest='name'>" . $name . "</entry>";
    402411                print "<entry>" . $desc . "</entry></row>\n";
    403         } elsif ($mode eq "HTML") {
     412        } elsif ($mode eq "XML-WEB") {
    404413                $name = "???" if $name eq "";
    405                 print "<tr>";
    406                 print "<td style='width:13em; padding:2px;'>".$name."</td>";
    407                 if ($nick ne "") {
    408                         print "<td style='width:10em; text-align: left;' class='news-author'>".$nick."</td>";
    409                 } else {
    410                         print "<td></td>";
    411                 }
    412                 print "<td>".$desc."</td>\n";
     414                print "\t\t\t\t<person>\n";
     415                print "\t\t\t\t\t<name>" . $name . "</name>\n";
     416                print "\t\t\t\t\t<alias>" . $nick . "</alias>\n";
     417                print "\t\t\t\t\t<description>" . $desc . "</description>\n";
     418                print "\t\t\t\t</person>\n";
    413419        }
    414 
    415 
    416420}
    417421
    418422sub add_paragraph {
     
    437441                my $line_end = '",';
    438442                print $line_start . $text . $line_end . "\n";
    439443                print $line_start . $line_end . "\n";
    440         } elsif ($mode eq "XML") {
     444        } elsif ($mode eq "XML-DOC") {
    441445                print "  <row><entry namest='start' nameend='job'>" . $text . "</entry></row>\n";
    442446                print "  <row><entry namest='start' nameend='job'> </entry></row>\n\n";
    443         } elsif ($mode eq "HTML") {
    444                 print "<p style='margin-left:2em; margin-bottom: 1em'>";
    445                 print $text;
    446                 print "</p>\n";
     447        } elsif ($mode eq "XML-WEB") {
     448                print "\t\t<paragraph>" . $text . "</paragraph>\n";
    447449        }
    448450}
    449451