### Author: Reinhold Kainhofer <reinhold@kainhofer.com>, 2008.
### Some code parts copied from texi2html and adapted. These functions
### were written mainly by Patrice Dumas
-### License: GPLv2+
+### License: GPLv3+
###
###
### Features implemented here:
### FUNCTIONALITY FOR MAIN WEB PAGES
#############################################################################
-my $web_manual = 0;
-sub lilypond_init_web_manual ()
-{
- if (exists($main::value{'web_manual'}))
- {
- print STDERR "Initializing settings for web site\n";
- $web_manual = 1;
- web_settings();
- }
-}
-push @Texi2HTML::Config::command_handler_process, \&lilypond_init_web_manual;
+our $web_manual;
#############################################################################
### SETTINGS FOR TEXI2HTML
# Validation fix for texi2html<=1.82
$Texi2HTML::Config::DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
-sub web_settings() {
- if ($web_manual) {
- @Texi2HTML::Config::CSS_REFS = (
- {FILENAME => "lilypond-web.css", TITLE => "Default style"}
- );
- } else {
- @Texi2HTML::Config::CSS_REFS = (
- {FILENAME => "lilypond-mccarty.css", TITLE => "Patrick McCarty's design"}
+@Texi2HTML::Config::CSS_REFS = (
+ {FILENAME => "lilypond-mccarty.css", TITLE => "Default style"}
);
- }
-}
@Texi2HTML::Config::ALT_CSS_REFS = (
{FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
{FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
);
+
+sub web_settings() {
+ print STDERR "Initializing settings for web site\n";
+ $Texi2HTML::Config::BODYTEXT = "";
+ @Texi2HTML::Config::CSS_REFS = (
+ {FILENAME => "lilypond-web.css", TITLE => "Patrick McCarty's design"}
+ );
+ @Texi2HTML::Config::ALT_CSS_REFS = (
+ {FILENAME => "lilypond-web-alt1.css", TITLE => "Alternate style 1"},
+ {FILENAME => "lilypond-web-alt2.css", TITLE => "Alternate style 2"},
+ );
+}
+
+# web_settings() if (exists($main::value{'web_manual'}));
+
$Texi2HTML::Config::USE_ACCESSKEY = 1;
$Texi2HTML::Config::USE_LINKS = 1;
$Texi2HTML::Config::USE_REL_REV = 1;
$Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
if ($Texi2HTML::Config::SPLIT eq 'section' or
- $Texi2HTML::Config::SPLIT eq 'subsubsection') {
+ $Texi2HTML::Config::SPLIT eq 'node') {
$Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
}
# '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
if (open(XREFFILE,'<', $mapfile)) {
my $line;
+ # print STDERR "*** PRINTING MAP FILE LINES ***\n";
while ( $line = decode ('UTF-8', <XREFFILE>) ) {
# parse the tab-separated entries and insert them into the map:
chomp($line);
my @entries = split(/\t/, $line);
if (scalar (@entries) == 3) {
$node_map->{$entries[0]} = [$entries[1], $entries[2]];
+ $, = " ";
+ # print STDERR @entries;
+ # print STDERR "\n";
} else {
print STDERR "Invalid entry in the node file $mapfile: $line\n";
}
}
- # print STDERR %{$node_map};
close (XREFFILE);
} else {
print STDERR "WARNING: Unable to load the map file $mapfile\n";
if (exists ($node_to_filename_map->{$node_name})) {
(my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
$filename .= ".$docu_ext" if (defined($docu_ext));
+ $filename = lc($filename);
# unnumbered sections (except those at top-level!) always go to the same
# file as the previous numbered section
- if (not ($element->{number}) and not ($lastfilename eq '') and ($element->{level} > 1)) {
+ if (not $docu_name == "web" and not ($element->{number})
+ and not ($lastfilename eq '') and ($element->{level} > 1)) {
$filename = $lastfilename;
}
if (($filename eq $lastfilename)) {
$$element{doc_nr} = $docnr;
$lastfilename = $filename;
}
- # print STDERR "File name: $filename\n";
- return lc($filename);
+ print STDERR "Output file name: $filename\n";
+ return $filename;
} elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or $type eq "stoc" or $type eq "foot" or $type eq "about") {
return;
}
my $filename = texinfo_file_name($node_name);
$filename .= ".$docu_ext" if (defined($docu_ext));
+ $filename = lc($filename);
$docnr += 1;
$$element{doc_nr} = $docnr;
$lastfilename = $filename;
print STDERR "File name: $filename\n";
- return lc($filename);
+ return $filename;
} else {
$$element{doc_nr} = $docnr;
+ $filename = lc ($filename);
print STDERR "File name: $filename\n";
- return lc($filename);
+ return $filename;
}
}
my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
|| main::locate_include_file ("${docu_name}.xref-map");
print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
+ if ($docu_name eq 'web') {
+ $web_manual = 1;
+ web_settings();
+ }
$node_to_filename_map = load_map_file ($map_filename);
}
push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
# Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
sub lilypond_init_toc_depth ()
{
- if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})) {
+ if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
+ and not $web_manual) {
$page_toc_depth = 1;
}
}
-# Set the TOC-depth (depending on a texinfo variable short_toc) in a
+# Set the TOC-depth (depending on a texinfo variable short_toc) in a
# command-handler, so we have them available when creating the pages
push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
+
# recursively generate the TOC entries for the element and its children (which
# are only shown up to maxlevel. All ancestors of the current element are also
# shown with their immediate children, irrespective of their level.
-# Unnumbered entries are only printed out if they are at top-level or 2nd level
+# Unnumbered entries are only printed out if they are at top-level or 2nd level
# or their parent element is an ancestor of the currently viewed node.
# The conditions to call this method to print the entry for a child node is:
# -) the parent is an ancestor of the current page node
-# -) the parent is a numbered element at top-level toplevel (i.e. show numbered
+# -) the parent is a numbered element at top-level toplevel (i.e. show numbered
# and unnumbered 2nd-level children of numbered nodes)
# -) the child element is a numbered node below level maxlevel
sub generate_ly_toc_entries($$$)
my @color_3 = (
"Productions", "Testimonials",
"Source", "Old downloads",
- "FAQ", "Changes", "Extend", "Internals",
+ "Web", "FAQ", "Changes", "Extend", "Internals",
"Publications", "Old news"
);
my @color_4 = (
- "Text input", "Alternate input",
+ "Text input", "Easier editing",
"GPL",
"Translated", "All", "FDL"
);
push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
if ($web_manual) {
push (@result, "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}","(main)"));
- } else {
- push (@result, @child_result);
}
+ push (@result, @child_result);
push (@result, "$ind</ul>\n");
}
}
# Create the toc entries recursively
my @toc_entries = "";
if ($web_manual) {
- push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
+ @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
# FIXME: add link to main page, really hackily.
if ($element->{'sectionup'}) {
# it's not the top element
push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth));
}
# search box
+ local $/=undef;
+ my $name = "search-box.html";
+ open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name" or die "no such file: $name: $!";
+ my $search_string = <FILE>;
+ $search_string = "<li>\n" . $search_string . "</li>\n";
+ push (@toc_entries, $search_string);
+ close FILE;
+
+ push (@toc_entries, "</ul>\n");
if ($web_manual) {
- # WTF, perl needs 6 lines of magic to do: ' ' + open ('file-name').read ()?
- local $/=undef;
- my $name = "search-box.html";
- open FILE, "$ENV{SRC_DIR}/$name" or open FILE, "$ENV{SRC_DIR}/../$name" or die die "no such file: $name: $!";
-
- my $string = <FILE>;
- $string = "<li>\n" . $string . "</li>\n";
- push (@toc_entries, $string);
- close FILE;
+ push (@toc_entries, "\n");
+ } else {
+ push (@toc_entries, "</div>\n");
}
- push (@toc_entries, "</ul>\n");
- push (@toc_entries, "</div>\n");
return @toc_entries;
}
# use default TOC if no custom lines have been generated
@lines = @default_toc if (not @lines);
if (@lines) {
-
+
print $fh "\n\n<div id=\"tocframe\">\n";
-
+
# Remove the leading "GNU LilyPond --- " from the manual title
my $topname = $Texi2HTML::NAME{'Top'};
$topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
-
+
# construct the top-level Docs index (relative path and including language!)
my $lang = $Texi2HTML::THISDOC{current_lang};
if ($lang and $lang ne "en") {
$reldir = "../" if ($Texi2HTML::Config::SPLIT eq 'section');
my $uplink = $reldir."web/manuals.${lang}html";
- if ($web_manual) {
- } else {
- print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
+ if (not $web_manual) {
+ print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
title=\"Documentation Index\"><< " .
&ly_get_string ('Back to Documentation Index') .
"</a></p>\n";
my $text = $button->[1];
my $button_href = $button->[0];
# verify that $button_href is simple text and text is a reference
- if (defined($button_href) and !ref($button_href)
+ if (defined($button_href) and !ref($button_href)
and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
{ # use given text
if ($Texi2HTML::HREF{$button_href})
}
elsif ($button eq ' ')
{ # handle space button
- $result .=
+ $result .=
($ICONS && $ACTIVE_ICONS{' '}) ?
&$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
$NAVIGATION_TEXT{' '};
}
else
{ # use text
- $result .=
+ $result .=
'[' .
&$anchor('',
$Texi2HTML::HREF{$button},
}
else
{ # button is passive
- $result .=
+ $result .=
$ICONS && $PASSIVE_ICONS{$button} ?
&$button_icon_img($BUTTONS_NAME{$button},
$PASSIVE_ICONS{$button},
#############################################################################
# For split pages, use index.html as start page!
-if ($Texi2HTML::Config::SPLIT eq 'section') {
+if ($Texi2HTML::Config::SPLIT eq 'section' or
+ $Texi2HTML::Config::SPLIT eq 'node') {
$Texi2HTML::Config::TOP_FILE = 'index.html';
}
-if ($web_node) {
-} else {
- push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
-}
return 1;