George S. Baugh %!s(int64=4) %!d(string=hai) anos
pai
achega
9da24f4449
Modificáronse 4 ficheiros con 35 adicións e 15 borrados
  1. 25 6
      bin/migrate2.pl
  2. 5 0
      lib/Trog/DataModule.pm
  3. 5 6
      lib/Trog/Routes/HTML.pm
  4. 0 3
      www/templates/posts.tx

+ 25 - 6
bin/migrate2.pl

@@ -26,7 +26,24 @@ sub uuid { return UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_V1, UUID::T
 # Modify these variables to suit your installation.
 my $user = 'george';
 my @extra_series = (
-     {
+        {
+            "aclname"    => "news",
+            "acls"       => [],
+            aliases      => [],
+            "callback"   => "Trog::Routes::HTML::series",
+            method       => 'GET',
+            "data"       => "News",
+            "href"       => "/news",
+            "local_href" => "/news",
+            "preview"    => "/img/sys/testpattern.jpg",
+            "tags"       => [qw{series topbar public}],
+            visibility   => 'public',
+            "title"      => "News",
+            user         => $user,
+            form         => 'series.tx',
+            child_form   => 'microblog.tx',
+        },
+        {
             "aclname"    => "blog",
             "acls"       => [],
             aliases      => [],
@@ -61,18 +78,18 @@ my @extra_series = (
             child_form   => 'file.tx',
         },
         {
-            "aclname"    => "files",
+            "aclname"    => "images",
             "acls"       => [],
             aliases      => [],
             "callback"   => "Trog::Routes::HTML::series",
             method       => 'GET',
-            "data"       => "Downloads",
-            "href"       => "/files",
-            "local_href" => "/files",
+            "data"       => "Images",
+            "href"       => "/images",
+            "local_href" => "/images",
             "preview"    => "/img/sys/testpattern.jpg",
             "tags"       => [qw{series topbar public}],
             visibility   => 'public',
-            "title"      => "Downloads",
+            "title"      => "Images",
             user         => $user,
             form         => 'series.tx',
             child_form   => 'file.tx',
@@ -130,6 +147,8 @@ foreach my $timestamp (keys(%posts)) {
             $post->{child_form} = 'file.tx' if $post->{title} =~ m/^video\//;
             $post->{child_form} = 'file.tx' if $post->{title} =~ m/^audio\//;
             $post->{child_form} = 'file.tx' if $post->{title} =~ m/^image\//;
+            $post->{local_href} = "/$post->{aclname}";
+            $post->{aliases}    = ["/series/$timestamp", "/series/$new_id"];
         }
 
         $search_info->write([$post]);

+ 5 - 0
lib/Trog/DataModule.pm

@@ -242,6 +242,11 @@ sub add ($self, @posts) {
     foreach my $post (@posts) {
         $post->{id} //= UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_V1, UUID::Tiny::UUID_NS_DNS);
         $post->{local_href} //= "/posts/$post->{id}";
+        if ($post->{aclname}) {
+            # Then this is a series
+            $post->{local_href} = "/$post->{aclname}";
+            $post->{aliases} = ["/posts/$post->{id}","/series/$post->{id}"];
+        }
         $post->{method}     //= 'GET';
         $post->{callback}   //= 'Trog::Routes::HTML::posts';
         $post->{created}    = time();

+ 5 - 6
lib/Trog/Routes/HTML.pm

@@ -704,6 +704,7 @@ sub series ($query, $render_cb) {
     #we are either viewed one of two ways, /post/$id or /$aclname
     my (undef,$aclname,$id) = split(/\//,$query->{route});
     $query->{aclname} = $aclname if !$id;
+    $query->{id}      = $id      if $id;
 
     # Don't show topbar series on the series page.  That said, don't exclude it from direct series view.
     $query->{exclude_tags} = ['topbar'] if !$is_admin && $aclname && $aclname eq 'series';
@@ -724,6 +725,7 @@ sub series ($query, $render_cb) {
     $query->{title} = $posts[0]->{title};
     $query->{tag} = $posts[0]->{aclname};
     $query->{primary_post} = $posts[0];
+    $query->{in_series} = 1;
 
     return posts($query,$render_cb);
 }
@@ -784,11 +786,10 @@ Display multi or single posts, supports RSS and pagination.
 sub posts ($query, $render_cb, $direct=0) {
     #Process the input URI to capture tag/id
     $query->{route} //= $query->{to};
-    my (undef, $tag, $id) = split(/\//, $query->{route});
+    my (undef, undef, $id) = split(/\//, $query->{route});
 
     my $tags = _coerce_array($query->{tag});
-    push(@$tags, $tag) if $tag && $tag ne 'posts';
-    $query->{id} = $id if $id;
+    $query->{id} = $id if $id && !$query->{in_series};
 
     my $is_admin = grep { $_ eq 'admin' } @{$query->{acls}};
     push(@{$query->{acls}}, 'public');
@@ -937,7 +938,7 @@ sub posts ($query, $render_cb, $direct=0) {
         style     => $query->{style},
         posts     => \@posts,
         like      => $query->{like},
-        in_series => exists $query->{in_series} || !!($query->{route} =~ m/\/series\/\d*$/),
+        in_series => exists $query->{in_series} || !!($query->{route} =~ m/^\/series\//),
         route     => $query->{route},
         limit     => $limit,
         pages     => scalar(@posts) == $limit,
@@ -1047,8 +1048,6 @@ sub sitemap ($query, $render_cb) {
                 my $true_uri = "http://$query->{domain}$url";
                 if (ref $url eq 'HASH') {
                     my $is_user_page = grep { $_ eq 'about' } @{$url->{tags}};
-                    use Data::Dumper;
-                    print Dumper($url);
                     $true_uri = "http://$query->{domain}/posts/$url->{id}";
                     $true_uri = "http://$query->{domain}/users/$url->{title}" if $is_user_page;
                 }

+ 0 - 3
www/templates/posts.tx

@@ -43,9 +43,6 @@
 <hr class="divider" />
 : }
 : for $posts -> $post {
-    : if ( $post.aclname && $in_series ) {
-    :     next;
-    : }
     : if ( !$post.form ) {
     :     next;
     : }