#!/usr/local/bin/perl # # index.html generator # nostromo, Mon Mar 7 19:57:11 2005 # # index.html mobile generator # nostromo, Fri 24 Apr 22:09:29 2015 # # $Id: gen_index 17 2023-03-07 09:45:49Z root $ # use constant PI => 4 * atan2(1, 1); use POSIX qw(ceil floor); use Getopt::Std; use LWP::Simple; use Digest::MD5 qw(md5_hex); my $length; my $tot_length; my $back = "/"; my $back_r = "../../"; my $header = " | "; my $scheme = "https"; my $cgi_url = "$scheme://nostromo.joeh.org/cgi-bin"; my $c55_url = "$scheme://nostromo.joeh.org/cgi-c55"; my $file_p = "/var/www/nostromo.joeh.org/htdocs"; my $index_h = "index.html"; my $index_s = "index.shtml"; my $index_m = "index_m.shtml"; my @empty_d = ( "content", # "content/holidays", "content/images", "content/making_of", "content/parties" ); my %offsets = ( category => '9', # 22 / 3 alphabetical => '23', # 23 / 1 chronological => '15', # 21 / 4 line_06 => "=*", # ... signature => '21',); # 23 / 1 my @new_gen; open(IN_FH, "< $file_p/../index.in") or die "$!"; while () { s/\$cgi_url/$cgi_url/g; s/\$c55_url/$c55_url/g; next if (/^#/); my ($ti_temp, $file_temp, $cat_temp, $y_temp, $des_temp, $url_temp) = split(/;/, $_); if ($cat_temp =~ /,/) { foreach my $i (split(/,/, $cat_temp)) { push(@in_all, "$ti_temp; $file_temp; $i; $y_temp; $des_temp; $url_temp"); if ($cat_temp =~ /,holidays$/) { my $filepath_temp = $file_temp . "/"; $filepath_temp =~ s/^\s+|\s+$//g; push(@holidays_all, "/usr/local/www/nostromo.joeh.org/htdocs/content/$filepath_temp"); } } } else { push(@in_all, $_); my $filepath_temp = $file_temp . "/"; my $url = $url_temp; $url =~ s/^\s+|\s+$//g; $filepath_temp =~ s/^\s+|\s+$//g; if ($url =~ /http:\/\//i) { next; } if ($url =~ /,/) { ($url, undef) = split(/,/, $url); } if ($url =~ /::/) { ($url, undef) = split(/::/, $url); } push(@files_all, "/usr/local/www/nostromo.joeh.org/htdocs/content/$filepath_temp") if ($filepath_temp && $url ne /\.\.html/); } } close IN_FH; my $latest_site; my @sorted_files = sort { -M $a <=> -M $b } @files_all; ($latest_site = $sorted_files[0]) =~ s/^(.*\/htdocs\/)(.*)$/$2/; chomp($latest_site); my $latest_holidays; my @sorted_holidays = sort { -M $a <=> -M $b } @holidays_all; ($latest_holidays = $sorted_holidays[0]) =~ s/^(.*\/htdocs\/)(.*)$/$2/; chomp($latest_holidays); my $i = 0; my $counter = 0; @in_all = map { $_ =~ s/;\ */; /g; $_ } @in_all; my @out_all = grep { ! $seen{$_} ++ } (sort { my ($aa, $bb); $a =~ /^(.*);\ *(.*);\ *(.*);\ *(\d{4});\ *(.*);\ *(.*)$/ and $aa = $4; $b =~ /^(.*);\ *(.*);\ *(.*);\ *(\d{4});\ *(.*);\ *(.*)$/ and $bb = $4; push (@in_year, $aa); return $aa <=> $bb } @in_all); @out_all = grep { ! $seen{$_} ++ } (sort { my ($aa, $bb); $a =~ /^(.*);\ *(.*);\ *(.*);\ *(\d{4});\ *(.*);\ *(.*)$/ and $aa = $3; $b =~ /^(.*);\ *(.*);\ *(.*);\ *(\d{4});\ *(.*);\ *(.*)$/ and $bb = $3; push (@in_category, $bb); return $aa <=> $bb; } @in_all); my %seen = (); @in_year = grep { ! $seen{$_} ++ } sort (@in_year); @in_category = grep { ! $seen{$_} ++ } sort (@in_category); @in_all = sort { $a cmp $b } @in_all; $| = 1; my @in_all_d; $counter_d = 0; while($counter_d < $#in_all) { @in_all_d[$counter_d] = (@in_all[$counter_d]); @in_all_d[$counter_d + 1] = (@in_all[$#in_all - $counter_d]); $counter_d += 2; } my %hash_y = map { $_ => $i++ } @in_year; $i = 0; my %hash_c = map { $_ => $i++ } @in_category; $i = 0; # -- main ---------------------------------------------------------------------- my %opts = (); getopts('dmsh', \%opts); if (keys %opts) { foreach my $option ( keys %opts ) { if ($option eq "h") { print_help(); } elsif ($option eq "d") { create_desktop(); } elsif ($option eq "m") { create_mobile(); } elsif ($option eq "s") { create_sitemap(); } } } else { create_desktop(); create_mobile(); create_sitemap(); if (@new_gen) { print STDOUT "new items generated:\n"; foreach my $new_item (@new_gen) { print STDOUT "$new_item"; } } } # -- subs ---------------------------------------------------------------------- sub create_desktop { print STDOUT "creating desktop: "; open(OUT_FH, "> $file_p/$index_h.gen_index.tmp") or die "$!"; select OUT_FH; &summarize_misc( ); &summarize_alphabetical( \@in_all ); &summarize_category( \@in_category, \@in_all); &summarize_chronological( \@in_year, \@in_all); &print_all; close OUT_FH; rename("$file_p/$index_h.gen_index.tmp", "$file_p/$index_s"); chown 80, 80, "$file_p/$index_s"; &gen_html( \@in_all ); &gen_yindex( \@in_all, \@in_year ); &gen_cindex( \@in_all, \@in_category); &gen_ymain( \@in_all, \@in_year ); &gen_cmain( \@in_all, \@in_category); &gen_amain( \@in_all ); &fill_emply_dirs(); print STDOUT "done\n"; } sub create_mobile { print STDOUT "creating mobile: "; open(OUT_FH, "> $file_p/$index_h.gen_index_m.tmp") or die "$!"; select OUT_FH; &gen_mobile( \@in_all, \@in_year, \@in_category ); close OUT_FH; rename("$file_p/$index_h.gen_index_m.tmp", "$file_p/$index_m"); chown 80, 80, "$file_p/$index_m"; print STDOUT "done\n"; } sub create_sitemap { # sitemap... print STDOUT "creating sitemap.xml"; open(OUT_FH, "> $file_p/sitemap.xml") or die "$!"; select OUT_FH; &gen_sitemap( \@in_all ); close OUT_FH; # image sitemap... print STDOUT ", image_sitemap: "; open(OUT_FH, "> $file_p/sitemap_images.xml") or die "$!"; select OUT_FH; &gen_imagesitemap(); close OUT_FH; chown 80, 80, "$file_p/sitemap_images.xml"; print STDOUT "done\n"; } sub fill_emply_dirs { foreach my $i (@empty_d) { open(FILLER_OUT, "> /var/www/nostromo.joeh.org/htdocs/$i/index.html_xxx") or die "$!"; select FILLER_OUT; print < please proceed into android hell... EO_FILLER close FILLER_OUT; compare_md5("/var/www/nostromo.joeh.org/htdocs/$i/index.html", "/var/www/nostromo.joeh.org/htdocs/$i/index.html_xxx"); } } sub summarize_misc { push(@misc_array, " |\n", " +--=[ miscellaneous ]=--+\n", " | |\n", " | `-++++\n", " | ||||\n", " | |||`-----------=[vertical layout]=--------------.\n", " | ||| |\n", " | ||`-----------=[latest bLog entry]=------------.|\n" , " | |`------------=[latest site entry<\/a>]=-----------.||\n" , " | `-----------=[latest holidays entry<\/a>]=--------.|||\n" , " | ||||\n" , " | *=~------------------------------------------++++\n" , " |\n" , " |\n" ,); } sub summarize_alphabetical { my ($in_c_ref) = @_; my @in; # my @in = @{$in_c_ref}; foreach $i (@{$in_c_ref}) { next if ($i =~ /olidays;\ /); push (@in, $i); } my $i = $j = 0; $spacer = " | "; $line_01 = $line_02 = $line_03 = $line_04 = $line_05 = $spacer; $line_00 = " | `--"; $offset_length = length($line_00); while($i < @in) { my $item_01 = $in[$i+0]; my $item_02 = $in[$i+1]; my $item_03 = $in[$i+2]; my ($index_01, $path_01, undef, undef, undef, undef) = split(/;\ */, $item_01); my ($index_02, $path_02, undef, undef, undef, undef) = split(/;\ */, $item_02); my ($index_03, $path_03, undef, undef, undef, undef) = split(/;\ */, $item_03); # if (($path_01 =~ /holiday/) || # ($path_02 =~ /holiday/) || # ($path_03 =~ /holiday/)); $path_01 = "content/$path_01/"; $path_02 = "content/$path_02/"; $path_03 = "content/$path_03/"; $sub_01 = (substr($index_01, 0, 1)); $sub_03 = (substr($index_02, 0, 1)) if $index_02; $sub_03 = (substr($index_03, 0, 1)) if $index_03; $indicator = "-=[" . $sub_01; if(($sub_01 ne $sub_03) && ($index_02 || $index_03)) { $indicator .= "-" . $sub_03; } $indicator .= "]=-"; if($j % 2) { $line_00 .= "+" if $index_02; $line_00 .= "+" if $index_03; $line_00 .= "+"; $line_00 .= $indicator . "-"x(25 - length($indicator)) if ($i+3 < @in); $line_01 .= "|" if $index_02; $line_01 .= "|" if $index_03; $line_01 .= "|" . " "x23; $line_02 .= "|" if $index_02; $line_02 .= "|" if $index_03; $line_02 .= "`- $index_01 " . "-"x(15 - length($index_01)) . "---." if $index_01; $line_02 .= " "; $line_03 .= " "x22 . "|" unless $index_02; $line_03 .= "|" if $index_03; $line_03 .= "`-- $index_02 " . "-"x(15 - length($index_02)) . "---." if $index_02; $line_03 .= " "; $line_04 .= " "x22 . "|" unless ($index_02 && $index_03); $line_04 .= "|" if ($index_01 && $index_02 && !$index_03); $line_04 .= "`--- $index_03 " . "-"x(15 - length($index_03)) . "---." if $index_03; $line_04 .= " "; $line_05 .= " "x22 . "|" unless ($index_02 && $index_03); $line_05 .= "|" if ($index_01 && $index_02 && !$index_03); $line_05 .= " " . " "x(length($index_03)) . " " . " "x(15 - length($index_03)) . " |" if $index_03; $line_05 .= " "; $line_06 .= "~----" . "-"x(length($index_03)) . "-" . "-"x(15 - length($index_03)) . "--~+" if $index_03; $line_06 .= "=" if $index_03; } else { $line_00 .= "-"x(20 - length($indicator)) . $indicator . "+" if $index_01; $line_00 .= "+" if $index_02; $line_00 .= "+" if $index_03; $line_00 .= "--" if($i+3 < @in); $line_01 .= " "x22 . "|"; $line_01 .= "|" if $index_02; $line_01 .= "|" if $index_03; $line_01 .= " "; $line_02 .= ".---" . "-"x(17 - length($index_01) - 2) . " $index_01 -'" if $index_01; $line_02 .= "|" if $index_02; $line_02 .= "|" if $index_03; $line_02 .= " "; $line_03 .= "|" if($index_01 && ($i >= (@in-1))); $line_03 .= ".---" . "-"x(17 - length($index_02) - 2) . " $index_02 --'" if $index_02; $line_03 .= "|" if $index_03; $line_03 .= " "; $line_04 .= "|" if($index_01 && ($i >= (@in-2))); $line_04 .= "|" if($index_02 && ($i >= (@in-2))); $line_04 .= ".---" . "-"x(17 - length($index_03) - 2) . " $index_03 ---'" if $index_03; $line_04 .= " "; $line_05 .= "|" if($index_01 && ($i >= (@in-2))); $line_05 .= "|" if($index_02 && ($i >= (@in-2))); $line_05 .= "| " . " "x(17 - length($index_03) - 2) . " " . " "x(length($index_03)) . " " if $index_03; $line_05 .= " "; $line_06 .= "+~--" . "-"x(17 - length($index_03) - 2) . "-" . "-"x(length($index_03)) . "----~" if $index_03; $line_06 .= "==" if $index_03; } $index_01 = $index_02 = $index_03 = ""; $i += 3; $j += 1; } ($length = $line_04) =~ s/(<[^>]+>)//g; $length = (length($length) - $offset_length); $line_06 = (substr($line_06, 1, ($length - 1))); $line_06 = " | `" . $line_06; $line_06 .= $offsets{line_06}; push(@alpha_array, " |\n", " +--=[ alphabetical ]=--+\n", " | |\n", "$line_00" . "-"x01 . "*\n", "$line_01\n" , "$line_01\n" , "$line_02\n" , "$line_03\n" , "$line_04\n" , "$line_05\n" , "$line_05\n" , "$line_06\n" , " |\n" , " |\n" ,); } sub summarize_category { my ($cat_ref, $in_c_ref) = @_; my @in_c = @{$in_c_ref}; my @cat = @{$cat_ref}; my $i = 0; my %seen = (); my @u_cat = grep { ! $seen{$_} ++ } @cat; my $spacer_c = " | "; my @array_c; my $x_c; my $y_c; my $target_ic; my $target_xc; my $target_icc = 3; $line_00c = $line_00; $line_01c = $line_01; $line_00c = $spacer_c; $line_cat_c = " | `" . "-"x$offsets{category}; push(@categ_array, " |\n", " +----=[ category ]=----+\n", " | |\n"); ($ca_dummy = $categ_array[1]) =~ s/(<[^>]+>)//g; $cl_length_c = (((length(substr($line_01c, (length($line_cat_c)))))) - (length($ca_dummy))); $length_c = $cl_length_c + length($line_cat_c); while ($i < ($#cat + 1)) { $i_cat = $cat[$i]; $c_length = length("-=[" . $i_cat . "]=-"); $line_cat_c .= ("-"x(floor(($length / ($#cat + 1)) / 2) - (floor($c_length / 2))) . "-=[$i_cat]=-" . "-"x(ceil(($length / ($#cat + 1)) / 2) - ((ceil($c_length / 2)) - 0))); $i++; } push(@categ_array, substr($line_cat_c, 0, (length($line_cat_c) - 4)) . "*\n", # - 0)) " |\n"); $target_ic = 0; $line_01c = substr($line_01c, (length($spacer_c) + 2)); } sub summarize_chronological { $target_i = 0; $line_05 = substr($line_05, (length($spacer)-1)); my ($date_ref, $in_ref) = @_; my @in = @{$in_ref}; my @date = @{$date_ref}; my $i = 0; my $sig = "nostromo.joeh.org"; $spacer = " | "; $line_date = " | `-" . "-"x$offsets{chronological}; while ($i < ($#date + 1)) { $i_date = $date[$#date - $i]; # ascending # $i_date = $date[$i]; # descending $i_length = length("-=[" . $i_date . "]=-"); $indicator = "-=[$i_date]=-"; $line_date .= ("-"x((ceil($length/($#date + 1)) - ($i_length))/2) . $indicator . "-"x((floor($length/($#date + 1)) - ($i_length))/2 - 1)); $i++; } $tot_length = length (" "x111 . ("-"x(length($line_05) - 89 - (length($sig)))) . "-"x$offsets{signature} . "$sig-" . "* "); push(@chrono_array, " +-=[ chronological ]=--+\n", " | |\n", "$line_date" . "-"x(11) . "*\n", " |\n", " |\n", " |\n", " |\n", " |\n", " |\n", " +-=[ (c) nostromo_ ]=--+\n", " | |\n", " | `----------=[normal]=----------=[inverted]=----------=[colouring]=----------=[rotated]=----------=[flipped]=-" . ("-"x(length($line_05) - 132 - (length($sig)))) . "-"x$offsets{signature} . "$sig-" . "* \n", " |\n", " |\n", " |\n", " |\n", " |\n", " `-=[ random images ]=--+\n", " |\n", " `" . " --*\n"); } sub print_all { print < nostromo

*=+-- choose:
  |
  |
EO_HEADER

    foreach $m_item (@misc_array)
    {
        print $m_item;
    }

    foreach $c_item (@categ_array)
    {
        print $c_item;
    }

    foreach $a_item (@alpha_array)
    {
        print $a_item;
    }

    foreach $d_item (@chrono_array)
    {
        print $d_item;
    }

    print <





EO_FOOTER
}

sub gen_html {
    my ($in_c_ref) = @_;
    my @in_c       = @{$in_c_ref};
    my $index_xxx;

    foreach $in (@in_all)
    {
        my($title, $path, $cat, $year, $info, $links) = split(/;\ */, $in);
        next if ($title eq "bLog");
        mkdir "content/$path" unless
            (-d "content/$path"); 

        # $index_xxx  = "content/$path/.__index.html_xxx";
        $index_xxx  = "../tmp/$title-$cat-index.html";
        open(OUT, "> $index_xxx") || die "oh nos - $path!\n$!\n";

        select OUT;

        print <


  
  
      $title
  
  
  
  
  



*=+-- $title:
  |
  |
  |
  +----=[ summary ]=-----+ 
  |                      |
EO_HTML1

        my $line_01 = "$header+" . 
                      "-"x(20 - (floor((length($cat) + length($year) + 1)/2))) .
                      "=[$cat/"        .
                      "$year]="  .
                      "-"x(20 - ( ceil((length($cat) + length($year) + 1)/2))) .
                      "*\n";

        my $line_02 = "$header|\n";
        my $line_03 = "$header`--+" . "-"x39 . "+-*\n";

           $line_05 = "$header   `" . "-"x39 . "'\n  |\n  |\n";
        my $line_06 = "  +-----=[ links ]=------+\n" .
                      " "x25 . "|\n";

        foreach $i (split(/, /, $links))
        {
            my ($url, $text) = split(/::/, $i);
            next unless($url);
            chomp($url);
            $text     = $title unless $text;
            chomp($text);
            $line_07 .= " "x25 . "+" . "-"x(20 - (floor((length($text)/2))))  .
                        "=["    :
                                                 "$url\">")                   .
                        "$text]=" . "-"x(20 - (ceil((length($text)/2)))) .
                        "*\n" . " "x25 . "|\n";
        }
        my $line_08 = " "x25 . "`------------------=[" .
                      "back]=------------------*\n";

        print "$line_01";
        print "$line_02";
        print "$line_03";
        print "  |" . " "x25 . "|" . " "x39 . "|\n";

        if($info =~ /§/)
        {
            foreach $info_i (split(/§/, $info))
            {
                formline <<'END', $info_i;
~~|                         | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
END
            }
        }
        else
        {
            formline <<'END', $info;
~~|                         | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
END
        }
        print "$^A";
        print "  |" . " "x25 . "|" . " "x39 . "|\n";

        print "$line_05";
        print "$line_06";
        print "$line_07";
        undef  $line_07;
        print "$line_08";
        undef  $^A;
        print <


EO_FOOTER

        close OUT;

        if ($cat !~ /olidays/) {
            if (compare_md5("content/$path/$index_h",
                            "$index_xxx") != 0) {
                push(@new_gen, "  * content/$path/$index_h - $cat\n");
            }
        }

        undef $title;
        undef $path;
        undef $cat;
        undef $year;
        undef $info;
        undef $links;
    }
}

sub gen_yindex {
    my ($in_ref, $year_ref) = @_;
    my @in     = @{$in_ref};
    my @date   = @{$year_ref};
    my $index_xxx  = "index.html_xxx";

    foreach $d (@date)
    {
        mkdir "$file_p/chronological/$d" unless
            ( -d "$file_p/chronological/$d" );

        open(OUT_Y, "> $file_p/chronological/$d/$index_xxx");
        select OUT_Y;

        print <


  
  
      $d
  
  
  
  



*=+-- $d:
  |
  |
  |
  +----=[ elements ]=----+
  |                      |
  |                      `--+---------------------------------------+-*
  |                         |                                       |
EO_HEADER

            @tmp = (grep(/$d/, @in));
            my $dbl_info, $dbl_path;

            @tmp = grep { ! $seen{$_} ++ } sort (@tmp);
            @tmp = sort { $a cmp $b } @tmp;

            foreach $t (@tmp)
            {
                next unless ($t =~ /$d/);
                my ($title, $path, $cat, $year, $info, $links) = split(/;\ */, $t);
                if(($dbl_info eq $info) && ($dbl_path eq $path)) {
                    $dbl_info = "";
                    $dbl_path = "";
                    next;
                }
                $dbl_info = $info;
                $dbl_path = $path;
                print "  |" . " "x25 . "| $title" .
                      "" .
                      " "x(37 - (length($cat) + (length($title)))) . 
                      "$cat |\n" if ($year eq $d);
            }
        print <back]=------------------*
EO_FOOTER

        close OUT_Y;

        compare_md5("$file_p/chronological/$d/$index_h",
                    "$file_p/chronological/$d/$index_xxx");

    }
}

sub gen_cindex {
    my ($in_ref, $cat_ref) = @_;
    my @in     = @{$in_ref};
    my @cat    = @{$cat_ref};
    my $index_xxx  = "index.html_xxx";

    foreach $c (@cat)
    {
        mkdir "$file_p/category/$c" unless
            ( -d "$file_p/category/$c" );

        open(OUT_C, "> $file_p/category/$c/$index_xxx");
        select OUT_C;

        print <


  
  
      $c
  
  
  
  



*=+-- $c:
  |
  |
  |
  +----=[ elements ]=----+
  |                      |
  |                      `--+---------------------------------------+-*
  |                         |                                       |
EO_HEADER

            @tmp = (grep(/$c/, @in));

            my @new;

            if($c eq "holidays")
            {
                # @tmp = reverse sort { (split(/;\ /, $a))[3] cmp (split(/;\ /, $b))[3] } @tmp;
                @tmp = reverse sort { (split(/_/, $a))[1] cmp (split(/_/, $b))[1] } @tmp;
                # foreach $item (@new) { print STDOUT ">>> $item\n"; }
            }
    
            foreach $t (@tmp)
            {
                next unless ($t =~ /$c/);
                my ($title, $path, $cat, $year, $info, $links) = split(/;\ */, $t);
                print "  |" . " "x25 . "| $title" .
                      "" .
                      " "x(37 - (length($year) + (length($title)))) . 
                      "$year |\n" if ($cat eq $c);
            }
        print <back]=------------------*
EO_FOOTER

        close OUT_C;

        compare_md5("$file_p/category/$c/$index_h",
                    "$file_p/category/$c/$index_xxx");

    }
}

sub gen_cmain {
    my ($in_ref, $cat_ref) = @_;
    my @in     = @{$in_ref};
    my @cat    = @{$cat_ref};
    my $index_xxx  = "index.html_xxx";

    open(OUT_C, "> $file_p/category/$index_xxx");
    select OUT_C;

    print <


  
  
      category
  
  
  
  



*=+-- category:
  |
  |
  |
  +----=[ elements ]=----+
  |                      |
  |                      `--+---------------------------------------+-*
  |                         |                                       |
EO_HEADER

    foreach $c (@cat)
    {
        print "  |" . " "x25 . "| $c" .
              "" .
              " "x(37 - (length($c))) . " |\n";

        @tmp = (grep(/$c/, @in));

        foreach $t (@tmp)
        {
            next unless ($t =~ /$c/);
            my ($title, $path, $cat, $year, $info, $links) = split(/;\ */, $t);
            print "  |" . " "x25 . "| - $title" .
                  "" .
                  " "x(35 - (length($year) + (length($title)))) . 
                  "$year |\n" if ($cat eq $c);
        }
        print "  |" . " "x25 . "|" . " "x38 . " |\n";
    }

    print <back]=------------------*
EO_FOOTER

    close OUT_C;

    compare_md5("$file_p/category/$index_h",
                "$file_p/category/$index_xxx");

}

sub gen_ymain {
    my ($in_ref, $year_ref) = @_;
    my @in     = @{$in_ref};
    my @date   = @{$year_ref};
    my $index_xxx  = "index.html_xxx";

    open(OUT_Y, "> $file_p/chronological/$index_xxx");
    select OUT_Y;

    print <


  
  
      chronological
  
  
  
  



*=+-- chronological:
  |
  |
  |
  +----=[ elements ]=----+
  |                      |
  |                      `--+---------------------------------------+-*
  |                         |                                       |
EO_HEADER

    # foreach $y (@date)        # ascending
    foreach $y (reverse @date)  # descending
    {
        print "  |" . " "x25 . "| $y" .
              "" .
              " "x(37 - (length($y))) . " |\n";

        @tmp = (grep(/$y/, @in));
        my $dbl_info, $dbl_path;

        foreach $t (@tmp)
        {
            next unless ($t =~ /$y/);
            my ($title, $path, $cat, $year, $info, $links) = split(/;\ */, $t);
            if(($dbl_info eq $info) && ($dbl_path eq $path)) {
                $dbl_info = "";
                $dbl_path = "";
                next;
            }
            $dbl_info = $info;
            $dbl_path = $path;
            print "  |" . " "x25 . "| - $title" .
                  "" .
                  " "x(35 - (length($cat) + (length($title)))) . 
                  "$cat |\n";
        }
        print "  |" . " "x25 . "|" . " "x38 . " |\n";
    }

    print <back]=------------------*
EO_FOOTER

    close OUT_Y;

    compare_md5("$file_p/chronological/$index_h",
                "$file_p/chronological/$index_xxx");

}

sub gen_amain {
    my ($in_ref) = @_;
    my @in       = @{$in_ref};
    my $index_xxx  = "index.html_xxx";

    open(OUT_A, "> $file_p/alphabetical/$index_xxx");
    select OUT_A;

    print <


  
  
      alphabetical
  
  
  
  



*=+-- alphabetical:
  |
  |
  |
  +----=[ elements ]=----+
  |                      |
  |                      `--+---------------------------------------+-*
  |                         |                                       |
EO_HEADER

    my $dbl_info, $dbl_path;

    @tmp = grep { ! $seen{$_} ++ } sort (@in);
    @tmp = sort { $a cmp $b } @in;

    foreach $a (@in)
    {
        my ($title, $path, $cat, $year, $info, $links) = split(/;\ */, $a);
        if(($dbl_info eq $info) && ($dbl_path eq $path)) {
            $dbl_info = "";
            $dbl_path = "";
            next;
        }
        $dbl_info = $info;
        $dbl_path = $path;
        print "  |" . " "x25 . "| - $title" .
              "" .
              " "x(32 - (length($year) + length($cat) + length($title))) .
              "$cat / " . 
              "$year |\n";
    }

    print <back]=------------------*
EO_FOOTER

    close OUT_A;

    compare_md5("$file_p/alphabetical/$index_h",
                "$file_p/alphabetical/$index_xxx");

}

sub gen_sitemap {
    my ($in_ref) = @_;

    my @in_all = @{$in_ref};

    open(IN, "< /var/www/nostromo.joeh.org/htdocs/robots.txt") || die "$!";
    while() {
        next unless (/^Disallow:/);
        $_ =~ m/Disallow: (.*)$/;
        push(@disallow, $1);
    }
    close IN;
    chown 80, 80, "/var/www/nostromo.joeh.org/htdocs/robots.txt";

    foreach $in (@in_all)
    {
        my($title, $path, $cat, $year, $info, $links) = split(/;\ */, $in);
        if ($title eq "bLog") {
            chomp($links);
            push(@in_sitemap, "\l$links\E")
        }

        foreach $i (split(/, /, $links))
        {
            my ($url, undef) = split(/::/, $i);
            next if((!$url) || ($url =~ /^((h|H)ttp(s)?:\/\/|\/blog)/));
            chomp($url);
            $url =~ s/\.\.html$//;
            $url .= "/" if ($url && ($url !~ m{/$}));
            push(@in_sitemap, "$scheme://nostromo.joeh.org/content/$path/$url")
                unless ( grep /($path|$url)/, @disallow);
        }
    }
    print "\n";
    print "\n";
    print map "  \n    $_\n  \n", sort keys %{ {map {$_ => 1} @in_sitemap} };
    print "\n";
}

sub gen_imagesitemap {
    open(IN, "< /var/www/nostromo.joeh.org/random_images.in") || die "$!";

    print "\n";
    print "" .
          "\n  \n    $scheme://nostromo.joeh.org/\n";

    while() {
        next if (/^\d+/);
        $_ =~ m/^\/var\/www\/nostromo.joeh.org\/htdocs\/content\/(.*?)\/.llgal\/thumb_([^\/]*)$/;

        $image = "$scheme://nostromo.joeh.org/content/$1/$2"; chomp($image);
        print "    \n      $image\n" .
              "    \n";
    }

    close IN;
    print "  \n\n";
}

sub gen_mobile {
    my ($in_ref, $year_ref, $category_ref) = @_;

    my @in_all;      # = @{$in_ref};
    my @in_year      = reverse @{$year_ref};
    my @in_category  = @{$category_ref};

    foreach $i (@{$in_ref})
    {
        next if ($i =~ /olidays;\ /);
        push (@in_all, $i);
    }

    my $time       = ($#in_all);
    my $years      = ($#in_year + 1);
    my $cats       = ($#in_category + 1);

    my $two_pi     = (PI * 2);

    my $seg_length = 21;
    my $padding    = 15;
    my $amplitude  = 5;
    my $period     = 100;
    my $period_a   = 30;
    my $cur_line   = "";

    my @cur_lines_y;
    my @cur_lines_c;
    my @cur_lines_a;

    my $counter_a;
    my $counter_y;
    my $counter_c;

    my $counter_lines_a = 0;
    my $counter_lines_y = 0;
    my $counter_lines_c = 0;

    for $i ( 0 .. $time ) {
        $cur_line   = "";
        $cur_length = 0;

        $curr_a  = ( $amplitude * sin(2 * $two_pi *  $i     /
                    ($time * 2 / $period_a) ));
        $next_a = ( $amplitude * sin(2 * $two_pi * ($i + 1) /
                    ($time * 2 / $period_a) ));
        $prev_a = ( $amplitude * sin(2 * $two_pi * ($i - 1) /
                    ($time * 2 / $period_a) ));
        $curr_c = ( $amplitude * sin(2 * $two_pi *  $i      /
                    ($time * 2 / $cats) ));
        $next_c = ( $amplitude * sin(2 * $two_pi * ($i + 1) /
                    ($time * 2 / $cats) ));
        $prev_c = ( $amplitude * sin(2 * $two_pi * ($i - 1) /
                    ($time * 2 / $cats) ));
        $curr_y = ( $amplitude * sin(2 * $two_pi *  $i      /
                    ($time * 2 / $years) ));
        $next_y = ( $amplitude * sin(2 * $two_pi * ($i + 1) /
                    ($time * 2 / $years) ));
        $prev_y = ( $amplitude * sin(2 * $two_pi * ($i - 1) /
                    ($time * 2 / $years) ));

        $length_a = ($padding + ( $amplitude * sin(2 * $two_pi * $i /
                    ($time * 2 / $period_a) )));
        $length_y = ($padding + ( $amplitude * sin(2 * $two_pi * $i /
                    ($time * 2 / $years) )));
        $length_c = ($padding + ( $amplitude * sin(2 * $two_pi * $i /
                    ($time * 2 / $cats) )));

        my $fill_a = "X";
        my $fill_c = "=";
        my $fill_y = "^";
        my $fill_r = ".";

        #   zoo;       zoo;      cat;   year;  desc; zoo_linz_0310::zoo_linz_0310,
        my ($index_01, $path_01, undef, undef, undef, $path_02) =
            split(/;\ */, @in_all[$counter_a]);

        # alphabet...
        if (($path_02 =~ s/(,)/\1/g) > 1) {
            $link_a    = "";
        } elsif ($path_02 =~ /^Http/) {
            $link_a    = "";
        } else {
            ($path_02, undef) = split(/:/, $path_02);
            $link_a    = "";
        }

        my $length_balancer_a = 0;
        if ( length("$fill_a"x($padding + ($length_a - (length($index_01) + 4))) .
            "[$index_01]==" . "$fill_c"x($seg_length - $length_a) . " ")  > 36 ) {
            $length_balancer_a = 1;
        }
        $cur_line_a .= "$fill_a"x($padding + ($length_a - (length($index_01) + 4))) .
            "[$link_a$index_01]==" . "$fill_c"x($seg_length - $length_a -
            $length_balancer_a) . " ";

        $cur_line_a .= $fill_c if ($counter_lines_a < 1);
        $counter_lines_a++;
        $counter_a++;

        # category...
        $cur_length = length($cur_line_a);
        my $length_balancer_c = 0;

        $length_balancer_string_c = " " if ($counter_lines_c < 1);
        $counter_lines_c++;

        if (( $prev_c < $curr_c ) && ( $curr_c > $next_c )) {
            if (length( "$fill_c"x($padding + ($length_c -
                (length(@in_category[$counter_c]) + 4))) . "[" .
                @in_category[$counter_c] . "]" . "$fill_y"x2 .
                "."x($seg_length - $length_c) . " ") > 36 ) {
                $length_balancer_c = 1;
            }
            $link_c    = "";
            $cur_line_c .= "$fill_c"x($padding + ($length_c - 
                (length(@in_category[$counter_c]) + 4))) .
                "[$link_c" . @in_category[$counter_c] . "]" . "$fill_c"x2 .
                "$fill_y"x($seg_length - $length_c - $length_balancer_c) . " ";
            $counter_c++;
        } else {
            if (length("$fill_c"x($padding + $length_c) .
                "$fill_y"x($seg_length - $length_c) . " ") > 36 ) {
                $length_balancer_c = 1;
            }
            $cur_line_c .= "$fill_c"x($padding + $length_c) .
                "$fill_y"x($seg_length - $length_c - $length_balancer_c) .
                $length_balancer_string_c . " ";
        }

        # year...
        $cur_length = length($cur_line_a);
        my $length_balancer_y = 0;

        $length_balancer_string_y = " " if ($counter_lines_y < 1);
        $counter_lines_y++;

        if (( $prev_y < $curr_y ) && ( $curr_y > $next_y )) {
            $link_y    = "";
            $cur_line_y .= "$fill_y"x($padding + ($length_y - 
                (length(@in_year[$counter_y]) + 4))) . "[$link_y" .
                @in_year[$counter_y] . "]" . "$fill_y"x2 . $fill_r;
            $counter_y++;
        }
        else {
            if (length("$fill_y"x($padding + $length_y) .
                "$fill_r"x($seg_length - $length_y) . " ") > 36 ) {
                $length_balancer_y = 1;
            }
            $cur_line_y .= "$fill_y"x($padding + $length_y) .
                "$fill_r"x($seg_length - $length_y - $length_balancer_y) .
                $length_balancer_string_y . " ";
        }
        
        if ($cur_line_a) {
            push (@cur_lines_a, $cur_line_a);
            $cur_line_a = "";
        }
        if ($cur_line_y) {
            push (@cur_lines_y, $cur_line_y);
            $cur_line_y = "";
        }
        if ($cur_line_c) {
            push (@cur_lines_c, $cur_line_c);
            $cur_line_c = "";
        }
    }
    print <


  
   
  
      nostromo 
  
  
  
  
  


    EO_HEADER # http://tympanus.net/codrops/2012/02/21/accordion-with-css3/ # http://jsfiddle.net/m_raffaele/Fzuz7/ # http://www.script-tutorials.com/css3-onclick-vertical-metal-menu/ # http://www.w3avenue.com/2010/04/02/cross-browser-pure-css3-vertical-accordion/ ## alphabet XX== category ==^^ chronology ^^.. misc .. my $header_line_a = "X"x4 . "aXXlXXpXXhXXaXXbXXeXXtXXiXXcXXaXXlX" . "X"x($#cur_lines_a - 18); $header_line_a .= "X"x(($time * 3) - length($header_line_a)); print "
  • \n" . "

    $header_line_a

    \n" . "
    ";
    
        $cur_lines_a[0] = substr($cur_lines_a[0], 0, -2) . " ";
        foreach my $line_a (@cur_lines_a) {
            print "$line_a\n";
        }
    
        my $header_line_c = "="x7 . "c==a==t==e==g==o==r==i==e==s=" .
                            "="x($#cur_lines_c - 18);
        $header_line_c .= "="x(($time * 3) - length($header_line_c));
    
        print "
    \n" . "
  • \n" . "
  • \n" . "

    $header_line_c

    \n" . "
    ";
    
        $cur_lines_c[0] = substr($cur_lines_c[0], 0, -2) . " ";
        foreach my $line_c (@cur_lines_c) {
            print "$line_c\n";
        }
    
        my $header_line_y = "^"x10 . "c^^h^^r^^o^^n^^o^^l^^o^^g^^i^^c^^a^^l^" .
                            "^"x($#cur_lines_y - 16);
        $header_line_y .= "^"x(($time * 3) - length($header_line_y));
    
        print "
    \n" . "
  • \n" . "
  • \n" . "

    $header_line_y

    \n" . "
    \n";
    
        $cur_lines_y[0] = substr($cur_lines_y[0], 0, -2) . " ";
        foreach my $line_y (@cur_lines_y) {
            print "$line_y\n";
        }
    
        my $header_line_m = "."x13 . "m..i..s..c..e..l..l..a..n.." .
                            "e..o..u..s..." .  "."x($#cur_lines_a - 35);
        $header_line_m .= "."x(($time * 3) - length($header_line_m));
    
        my $latest_holidays_string = "latest holidays entry";
        my $latest_holidays_line   = "."x(floor($seg_length - (length($latest_holidays_string) / 2))) .
                                     "$latest_holidays_string<\/a>"      .
                                     "."x(ceil($seg_length - (length($latest_holidays_string) / 2)))  ;
    
        my $latest_site_string      = "latest site entry";
        my $latest_site_line        = "."x(floor($seg_length - (length($latest_site_string) / 2))) .
                                     "$latest_site_string"            .
                                     "."x(ceil($seg_length - (length($latest_site_string) / 2)))  ;
    
        my $latest_blog            = "$scheme://nostromo.joeh.org/blog/index.latest";
        my $latest_blog_string     = "latest bLog entry";
        my $latest_blog_line       = "."x(floor($seg_length - (length($latest_blog_string) / 2))) .
                                     "$latest_blog_string"           .
                                     "."x(ceil($seg_length - (length($latest_blog_string) / 2)))  ;
    
        print "
    \n" . "
  • \n" . "
  • \n" . "

    $header_line_m

    \n" . "
    \n"                                            .
              "."x11 . "horizontal layout" . "."x11 . "\n"  .
              "."x($seg_length * 2) . "\n"                                    .
              "$latest_blog_line\n"                                           .
              "$latest_site_line\n"                                            .
              "$latest_holidays_line\n"                                       .
              "."x($seg_length * 2) . "\n"                                    .
              ""                  .
              "" .
              ""                                                .
              "" .
              "\n" ;
    
        print "
    \n" . "
  • \n" . "
\n" . "
\n" ; print < EO_FOOTER } sub print_help { print <>', "$file_orig") or die "warning: can not touch $file_orig: $!"; close NEW; } open (my $md5_orig, '<', "$file_orig") or die "warning: can not hash $file_orig: $!" if (-f "$file_orig"); binmode ($md5_orig); $file_orig_hash = Digest::MD5->new->addfile($md5_orig)->hexdigest; close $md5_orig; open (my $md5_new, '<', "$file_new") or die "warning: can not hash $file_new: $!" if (-f "$file_new"); binmode ($md5_new); $file_new_hash = Digest::MD5->new->addfile($md5_new)->hexdigest; close $md5_new; if ($file_orig_hash eq $file_new_hash) { unlink "$file_new" or warn "could not unlink $file_new : $!"; $return_val = 0; } else { # print STDOUT " O> $file_orig: $file_orig_hash\n"; # print STDOUT " N> $file_new: $file_new_hash\n"; rename("$file_new", "$file_orig") or warn "could not rename $file_new: $!"; chown 80, 80, "$file_orig"; $return_val = 1; } return $return_val; }