diff -r f00ed34eca17 -r ee9b57cbbefc genorg.pl
--- a/genorg.pl Mon Dec 16 22:51:52 2024 +1000
+++ b/genorg.pl Tue Dec 17 01:49:39 2024 +1000
@@ -19,6 +19,7 @@
# Print required elisp code it is in $req_config
# Add config option for $max_rss and $max_cat
# Sort cataogirs by entires
+# Document link to file x from file x no work
# Variable for map_css
# Remove the desc
# Domain thing as well
@@ -31,14 +32,16 @@
my $dir = "blog";
my $outdir = "out/";
my $emacs = "emacs";
-my $css = "style.css";
-my $map_css ="other.css";
+my $art_css = "astyle.css";
+my $cat_css ="cstyle.css";
my $no_name_dir = "c";
my $cache_file = "genorg-cache/cache.xml";
my $domain = "p.bauherren.ovh";
my $max_rss = 30;
# The first page has one less article. Think of it as a feature.
my $max_cat = 7;
+my $main_title= "";
+my $blog_title = "Pranshu's blog";
my $username = $ENV{LOGNAME} || $ENV{USER} || getpwuid ($<);
my $template = <<"END";
@@ -77,6 +80,14 @@
my $custom_code = "(list 1)";
+my $navbar = <<"END" =~ s/\n\s+//gr;
+
-
All articles
+
All articles
SPLIT
- TITLE DATE
- DESCREPTION
- CATAG
+ TITLE DATE CATAG
SPLIT
TITLE DATE
- DESCREPTION
SPLIT
@@ -165,7 +174,7 @@
my %config_vars =
(
'emacs-path' => \$emacs,
- css => \$css,
+ css => \$art_css,
indir => \$dir,
outdir => \$outdir,
no_name_dir => \$no_name_dir
@@ -279,23 +288,24 @@
my $cache_dom;
sub main {
- -d $cdir or help_and_bye;
- mkdir $outdir;
- chdir $cdir or die "Couldn't access $cdir\n";
- read_config $config_file;
- -d $dir or die "$dir doesn't exist \n";
- find (\&wanted, $dir);
- for (@files_to_move) {
- copy $_, s#$dir/?#$outdir#er;
- }
- mkdir for @files_to_make;
- values %{conv_files()};
- $cache_dom = XML::LibXML->load_xml(location => $cache_file) if $cache && -f $cache_file;
- chdir $outdir;
- @arts = sort { $b->{date} <=> $a->{date}} map { html_fixup($_) } @org_exps;
- finalise_html();
- chdir '..';
- populate_cache();
+ $outdir =~ s!/*$!/!;
+ -d $cdir or help_and_bye;
+ mkdir $outdir;
+ chdir $cdir or die "Couldn't access $cdir\n";
+ read_config $config_file;
+ -d $dir or die "$dir doesn't exist \n";
+ find (\&wanted, $dir);
+ for (@files_to_move) {
+ copy $_, s#$dir/?#$outdir#er;
+ }
+ mkdir for @files_to_make;
+ values %{conv_files()};
+ $cache_dom = XML::LibXML->load_xml(location => $cache_file) if $cache && -f $cache_file;
+ chdir $outdir;
+ @arts = sort { $b->{date} <=> $a->{date}} map { html_fixup($_) } @org_exps;
+ finalise_html();
+ chdir '..';
+ populate_cache();
}
sub populate_cache {
@@ -304,12 +314,13 @@
my %c_els;
for my $art (@arts) {
# We need the: related, file, date
- my ($art_el, $date, $title, $ca, $related) =
- map {$dom->createElement($_)} ("art", "date", "title", "catag", "related");
+ my ($art_el, $date, $title, $ca, $related, $utitle) =
+ map {$dom->createElement($_)} ("art", "date", "title", "catag", "related", "utitle");
$art_el->{path} = $art->{file};
$ca->appendText($art->{catag});
$title->appendText($art->{title});
$date->appendText($art->{date}->text_easy);
+ $utitle->appendText($art->{utitle});
my @ll = @{$art->{links}};
if (@ll) {
my $links = $dom->createElement('links');
@@ -329,7 +340,7 @@
$related->appendText("\"$catag\"" . ($artt && "->\"$artt\" "));
}
}
- $art_el->appendChild($_) for ($date, $ca, $related, $title);
+ $art_el->appendChild($_) for ($date, $ca, $related, $title, $utitle);
$root->appendChild($art_el);
}
$root->appendChild($_) for values %c_els;
@@ -345,7 +356,7 @@
? ($h_en_cat =~ s/CATAG/$data->{catag}/er) : $h_en;
my $prel_path = "/$no_name_dir/" . (defined $catagory ? "c" : "c/b");
$str =~ s/DATE/$data->{date}->fmt/er
- =~ s/TITLE/$data->{title}/er
+ =~ s/TITLE/$data->{utitle}/er
=~ s|LINK|prel_path($prel_path, '/'. $data->{file})|er
}
@@ -357,8 +368,9 @@
DESC
END
- $thing =~ s|LINK|"$domain/" . $data->{file}|er
- =~ s/TITLE/$data->{title}/er;
+ $thing
+ =~ s|LINK|"$domain/" . $data->{file}|er
+ =~ s/TITLE/$data->{utitle}/er;
}
sub min ($x, $y) {
@@ -370,7 +382,7 @@
my $page = shift;
'
' . join ("", map {
my ($str, $file) = @{$_};
- $str = "---$str" if $file && ($file == $page);
+ $str = "$str" if $file && ($file == $page);
defined $file ?
"- $str" : $str
} ((["←", $page - 1]) x!! ($page - 1),
@@ -416,14 +428,22 @@
}
}
+sub cssbs($s,$t,$p){
+ $s =~ s|CSS|prel_path("/$p","/$cat_css")|er
+ =~ s/TITLE|BTIT/$t/ger
+ =~ s/NAV/$navbar/er;
+}
+
sub finalise_html {
mkdir $no_name_dir;
open my $fh, '>', "$no_name_dir/1.html";
open my $mrss, '>', "$no_name_dir/rss.xml"; # The master rss file
print $mrss $rss_entry;
- print $fh $h_intro . $h_c_intro;
+ print $fh cssbs($h_intro . $h_c_intro, $blog_title, "a/c");
my (%c_files, %r_files); # Cataogry files and rss
- while (my ($cat, $num) = each %catags) {
+
+ for my $cat (sort { $catags{$b} <=> $catags{$a} } keys(%catags)) {
+ my $num = $catags{$cat};
# ($h_intro, $h_c_intro, $h_cat_li, $h_chap, $h_en_cat, $h_en, $h_end)
print $fh $h_cat_li =~ s/NUMBER/$num/re
=~ s/CATAG/$cat/er
@@ -432,7 +452,8 @@
open $c_files{$cat}, '>', "$no_name_dir/$cat/1.html";
open $r_files{$cat}, '>', "$no_name_dir/$cat/rss.xml";
print {$r_files{$cat}} $rss_entry;
- print {$c_files{$cat}} $h_intro;
+ print {$c_files{$cat}}
+ cssbs($h_intro, "$cat