Browse Source

Work on #130: transform categories into series

George S. Baugh 4 years ago
parent
commit
d5d1f6575b
5 changed files with 11 additions and 14 deletions
  1. 0 0
      data/DUMMY-dist.json
  2. 0 4
      lib/Trog/DataModule.pm
  3. 7 1
      lib/Trog/Routes/HTML.pm
  4. 3 8
      www/templates/categories.tx
  5. 1 1
      www/templates/index.tx

File diff suppressed because it is too large
+ 0 - 0
data/DUMMY-dist.json


+ 0 - 4
lib/Trog/DataModule.pm

@@ -125,13 +125,9 @@ sub filter ($self, $query, @filtered) {
     $request{older} =~ s/[^0-9]//g if $request{older};
     @filtered = grep { $_->{created} < $request{older} } @filtered if $request{older};
 
-    #XXX Heal bad data -- probably not needed
-    @filtered = map { my $t = $_->{tags}; @$t = grep { defined $_ } @$t; $_ } @filtered;
-
     # Next, handle the query, tags and ACLs
     @filtered = grep { my $tags = $_->{tags}; grep { my $t = $_; grep {$t eq $_ } @{$request{tags}} } @$tags } @filtered if @{$request{tags}};
     @filtered = grep { my $tags = $_->{tags}; grep { my $t = $_; grep {$t eq $_ } @{$request{acls}} } @$tags } @filtered unless grep { $_ eq 'admin' } @{$request{acls}};
-
     @filtered = grep { $_->{title} =~ m/\Q$request{like}\E/i || $_->{data} =~ m/\Q$request{like}\E/i } @filtered if $request{like};
 
     @filtered = grep { $_->{user} eq $request{author} } @filtered if $request{author};

+ 7 - 1
lib/Trog/Routes/HTML.pm

@@ -249,6 +249,12 @@ sub index ($query,$render_cb, $content = '', $i_styles = []) {
     #TODO allow theming of print css
 
     my $search_info = Trog::Data->new($conf);
+    my @series = $search_info->get(
+        acls    => [qw{public}],
+        tags    => [qw{topbar}],
+        limit   => 10,
+        page    => 1,
+    );
 
     my $title = $query->{primary_post}{title} // $query->{title} // $Theme::default_title // 'tCMS';
 
@@ -272,7 +278,7 @@ sub index ($query,$render_cb, $content = '', $i_styles = []) {
         rightbar       => _pick_processor("templates/$rightbar"  ,$processor,$t_processor)->render($rightbar,$query),
         leftbar        => _pick_processor("templates/$leftbar"   ,$processor,$t_processor)->render($leftbar,$query),
         footbar        => _pick_processor("templates/$footbar"   ,$processor,$t_processor)->render($footbar,$query),
-        category_links => _pick_processor("templates/categories.tx", $processor,$t_processor)->render("categories.tx",$query),
+        categories     => \@series,
         stylesheets    => \@styles,
         show_madeby    => $Theme::show_madeby ? 1 : 0,
         embed          => $query->{embed} ? 1 : 0,

+ 3 - 8
www/templates/categories.tx

@@ -1,8 +1,3 @@
-<a href="/news"   title="Micro Blog" class="topbar">News</a>
-<a href="/blog"   title="Blog" class="topbar">Blog</a>
-<a href="/image" title="Images" class="topbar">Images</a>
-<a href="/video"  title="Video" class="topbar">Video</a>
-<a href="/audio"  title="Audio" class="topbar">Audio</a>
-<a href="/files"  title="Files" class="topbar">Files</a>
-<a href="/series" title="Series" class="topbar">Series</a>
-<a href="/about"  title="About" class="topbar">About</a>
+: for $categories -> $category { 
+<a href="<: $category.href :>"   title="<: $category.title :>" class="topbar"><: $category.title :></a>
+: }

+ 1 - 1
www/templates/index.tx

@@ -7,7 +7,7 @@
     </div>
     <span title="Menu" id="clickme" onclick="this.focus()">🌐</span>
     <div id="righttitle" class="toplel">
-        <: $category_links | mark_raw :>
+        : include "categories.tx";
         <a href="/sitemap" title="Sitemap" class="topbar">🗺️</a>
         <form action="<: $route :>" method="GET" class="inline">
             <input required type="search" class="coolbutton topform" name="like"></input>

Some files were not shown because too many files changed in this diff