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, "< $ht_root/htdocs/robots.txt") || die "$!";
while() {
next unless (/^Disallow:/);
$_ =~ m/Disallow: (.*)$/;
push(@disallow, $1);
}
close IN;
chown 80, 80, "$ht_root/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)/) || ($url !~ /\.html$/) || ($url =~ /\.\.\//));
chomp($url);
# $url =~ s/\.\.html$//;
# $url .= "/" if ($url && ($url !~ m{/$}));
push(@in_sitemap, "$scheme://$h_name/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 {
my $image_parenturl;
my $image_parenturl_old;
open(IN, "< $ht_root/random_images.in") || die "$!";
print "\n";
print "" .
"\n \n $scheme://$h_name/ \n";
while() {
next if (/^\d+/);
$_ =~ m#^$ht_root/htdocs/content/(.*?)/.llgal/thumb_([^/]*)$#;
my $img_path = $1;
my $img_name = $2;
$image_parenturl = "$ht_root/htdocs/content/$img_path/index.html" if (-e ("$ht_root/htdocs/content/$img_path/index.html"));
$image_parenturl = "$ht_root/htdocs/content/$img_path/..html" if (-e ("$ht_root/htdocs/content/$img_path/..html"));
if ($image_parenturl ne $image_parenturl_old) {
($image_parenturl_tmp = $image_parenturl) =~ s#^$ht_root/htdocs/content/(.*?)$#$1#;
print " \n \n $scheme://$h_name/content/$image_parenturl_tmp \n";
}
$image = "$scheme://$h_name/content/$img_path/$img_name"; chomp($image);
print " \n $image \n" .
" \n";
$image_parenturl_old = $image_parenturl;
undef $image_parenturl;
}
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" .
" \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;
}