Skip to content

Commit

Permalink
fixes to layouts and others I forgot
Browse files Browse the repository at this point in the history
  • Loading branch information
lordfeck committed Apr 22, 2023
1 parent ef1cf24 commit 2ba3540
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ rsru/*
entries/*
feed.xml
todo.txt
.DS_Store
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ What are the directories and what is inside each?

![RSRU Screenshot](misc/blandblog.png)

![RSRU Screenshot](misc/linkcat.png)

2 changes: 1 addition & 1 deletion conf_samples/conf_linkcat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
siteHomepageHeader => "Linkcat",
siteHomepageDesc => "Interesting websites I found.",
maxPerPage => 10,
maxHpHighlights => 6,
maxHpHighlights => 10,
showCatTotal => 1,

# RSS Configuration (requires XML::RSS)
Expand Down
2 changes: 1 addition & 1 deletion entries_samples/softcat/bamplesoft.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ order: 3
date: 2021-01-01
img_src: ebay-2002.png
dl_url: http://www.themostamazingwebsiteontheinternet.com/
is_highlight: yes
is_highlight: no
# Lines beginning '#' are skipped
# The rest of the file is the description in HTML
Sample soft offers no convenience to the user. It only exists to provide a sample for RSRU.
Expand Down
Binary file modified misc/linkcat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified misc/rsru3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions rsru.pl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env perl

#===============================================================================
# Thransoft RSRU Release 3.1 (with multimedia extensions)
# Thransoft RSRU Release 3.2 (with multimedia extensions)
# A static catalogue-style website generator, freely given
# Licence: GPLv3. See "licence.txt" for full details.
# Author: Thran. Authored: 09/09/2020 - 07/05/2022
# Author: Thran. Authored: 09/09/2020 - 22/04/2023
# WWW: http://soft.thran.uk
#
# With Thanks: https://stackoverflow.com/questions/63835994/
#===============================================================================

use strict;
use warnings;
use v5.10;
use v5.16;

use File::Copy;
use File::Path qw(make_path remove_tree);
Expand Down Expand Up @@ -73,7 +73,7 @@
my $DATE_FORMAT = "%Y-%m-%d";
my $MAX_CATS = 8;
my $MIN_ENTRIES = 2;
my $MAX_ENTRIES = 5;
my $MAX_ENTRIES = 8;
my $YES = 'yes';
my $NO_SUMMARY = '';
my $TPL_EMPTY_CAT = "<h1>Notice</h1><p>This category is currently empty. Finely-curated entries are forthcoming!</p>";
Expand Down Expand Up @@ -339,7 +339,7 @@ sub entrykvs_to_html {
} elsif ($key eq "is_highlight" && defined $entryKvs{$entryId}{is_highlight} && $entryKvs{$entryId}{is_highlight} eq $YES) {
$filledEntry =~ s/{% IS_HIGHLIGHT %}/highlight/g;
$wasHighlight = 1;
} else {
} elsif ($entryKvs{$entryId}{$key}) {
$filledEntry =~ s/{% $key %}/$entryKvs{$entryId}{$key}/g;
}
}
Expand Down Expand Up @@ -435,12 +435,11 @@ sub prep_navbar {
my ($catName, $pgIdx, $isLast) = @_;
my $cwNavbar = $tplNav;
my %url;
my ($max, $next);
my ($max, $next) = (calculate_max_page($catName), 0);

my $prev = $pgIdx - 1;
my $baseURL = $baseURL eq "." ? ".." : $baseURL;

$max = calculate_max_page($catName);
say "Max page for $catName is $max" if $uc{debug};

if ($max == 1) {
Expand Down Expand Up @@ -616,20 +615,18 @@ sub paint_homepage {
$tplHp .= "<p>Current total entries: " . scalar %entryKvs . "</p>";

print $fh $tplHp;
my $totalEntries = scalar (%entryKvs);

if ( $totalEntries >= $MIN_ENTRIES ){
my $max = ($totalEntries < $MAX_ENTRIES) ? $totalEntries : $MAX_ENTRIES;
@latest = sort_all_entries($totalEntries);
print $fh '<h2>Latest Entries</h2>';
if (scalar (%entryKvs) >= $MIN_ENTRIES){
@latest = sort_all_entries($MAX_ENTRIES);
print $fh '<h2 class="hpHeader">Latest Entries</h2>';
print $fh generate_entries_hp(@latest);
} else {
say "Total entries are below $MIN_ENTRIES. Skipping latest on homepage.";
}

@highlights = get_highlighted_entries;
if (@highlights) {
print $fh '<h2>Highlights</h2>';
print $fh '<h2 class="hpHeader">Highlights</h2>';
print $fh generate_entries_hp(@highlights);
}
print $fh $tplBottom;
Expand Down Expand Up @@ -665,6 +662,7 @@ sub sort_entries {
sub sort_all_entries {
my $max = shift;
my %entryDate;

for my $entry (keys %entryKvs) {
say "entry $entry and $entryKvs{$entry}{'date'}" if $uc{debug};
$entryDate{$entry} = $entryKvs{$entry}{"date"};
Expand All @@ -673,16 +671,18 @@ sub sort_all_entries {
my @sorted = sort keys %entryDate;
@sorted = sort { $entryDate{$b} <=> $entryDate{$a} } @sorted;
say "Sorted are @sorted." if $uc{debug};
return @sorted[0..$max-1];
return @sorted;
}

sub get_highlighted_entries {
my @highlights;

my $idx = $uc{maxHpHighlights} - 1;
foreach (keys %entryKvs) {
last if (scalar @highlights ge $uc{maxHpHighlights});
last if $idx < 0;
next unless ($entryKvs{$_}{is_highlight});
push (@highlights, $_) if ($entryKvs{$_}{is_highlight} eq $YES);
$idx--;
}
return @highlights;
}
Expand Down
4 changes: 2 additions & 2 deletions tpl/common/rsru_hp_entry.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<h3 class="entryName">{% ENTRY_NAME %}</h3>
<p class="entryDesc">{% ENTRY_DESC %} [{% ENTRY_DATE %}] [<a href="{% ENTRY_CAT_URL %}">{% ENTRY_CAT %}</a>]</p>
<h3 class="entryName"><a href="{% ENTRY_CAT_URL %}">{% ENTRY_NAME %}</a></h3>
<p class="entryDesc">{% ENTRY_DESC %} [{% ENTRY_DATE %}] [{% ENTRY_CAT %}]</p>
2 changes: 1 addition & 1 deletion tpl/linkcat/rsru_entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<td class="ecc" title="Eccentricity" colspan="1"><b>Eccentricity:</b> {% ecc %}/10</td>
</tr>
<tr>
<td class="siteUrl" colspan="1"><a href="{% url %}" target="_blank">Visit {% title %}</a></td>
<td class="date" title="Submission date"> {% date %}</td>
<td class="siteUrl" colspan="1"><a href="{% url %}" target="_blank">Visit {% title %}</a></td>
</tr>
</table>
2 changes: 1 addition & 1 deletion tpl/linkcat/rsru_entry_img.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<td class="ecc" title="Eccentricity" colspan="1"><b>Eccentricity:</b> {% ecc %}/10</td>
</tr>
<tr>
<td class="siteUrl" colspan="1"><a href="{% url %}" target="_blank">Visit {% title %}</a></td>
<td class="date" title="Submission date"> {% date %}</td>
<td class="siteUrl" colspan="1"><a href="{% url %}" target="_blank">Visit {% title %}</a></td>
</tr>
</table>
4 changes: 2 additions & 2 deletions tpl/linkcat/static/rsru.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ table.rsru .ecc {

table.rsru .siteUrl {
height: 1.2em;
text-align: left;
text-align: right;
vertical-align: bottom;
}

table.rsru .date {
text-align: right;
text-align: left;
vertical-align: bottom;
}

Expand Down

0 comments on commit 2ba3540

Please sign in to comment.